Commit 74ded8aed7bd5f2e4f3008a4566d8e3dd0510566

Authored by LooSheng
Committed by GitHub
1 parent d620758c

perf: respect the writing style of pinia getters (#2645)

src/store/modules/app.ts
... ... @@ -36,19 +36,19 @@ export const useAppStore = defineStore({
36 36 beforeMiniInfo: {},
37 37 }),
38 38 getters: {
39   - getPageLoading(): boolean {
40   - return this.pageLoading;
  39 + getPageLoading(state): boolean {
  40 + return state.pageLoading;
41 41 },
42   - getDarkMode(): 'light' | 'dark' | string {
43   - return this.darkMode || localStorage.getItem(APP_DARK_MODE_KEY_) || darkMode;
  42 + getDarkMode(state): 'light' | 'dark' | string {
  43 + return state.darkMode || localStorage.getItem(APP_DARK_MODE_KEY_) || darkMode;
44 44 },
45 45  
46   - getBeforeMiniInfo(): BeforeMiniState {
47   - return this.beforeMiniInfo;
  46 + getBeforeMiniInfo(state): BeforeMiniState {
  47 + return state.beforeMiniInfo;
48 48 },
49 49  
50   - getProjectConfig(): ProjectConfig {
51   - return this.projectConfig || ({} as ProjectConfig);
  50 + getProjectConfig(state): ProjectConfig {
  51 + return state.projectConfig || ({} as ProjectConfig);
52 52 },
53 53  
54 54 getHeaderSetting(): HeaderSetting {
... ...
src/store/modules/errorLog.ts
... ... @@ -20,11 +20,11 @@ export const useErrorLogStore = defineStore({
20 20 errorLogListCount: 0,
21 21 }),
22 22 getters: {
23   - getErrorLogInfoList(): ErrorLogInfo[] {
24   - return this.errorLogInfoList || [];
  23 + getErrorLogInfoList(state): ErrorLogInfo[] {
  24 + return state.errorLogInfoList || [];
25 25 },
26   - getErrorLogListCount(): number {
27   - return this.errorLogListCount;
  26 + getErrorLogListCount(state): number {
  27 + return state.errorLogListCount;
28 28 },
29 29 },
30 30 actions: {
... ...
src/store/modules/locale.ts
... ... @@ -21,11 +21,11 @@ export const useLocaleStore = defineStore({
21 21 localInfo: lsLocaleSetting,
22 22 }),
23 23 getters: {
24   - getShowPicker(): boolean {
25   - return !!this.localInfo?.showPicker;
  24 + getShowPicker(state): boolean {
  25 + return !!state.localInfo?.showPicker;
26 26 },
27   - getLocale(): LocaleType {
28   - return this.localInfo?.locale ?? 'zh_CN';
  27 + getLocale(state): LocaleType {
  28 + return state.localInfo?.locale ?? 'zh_CN';
29 29 },
30 30 },
31 31 actions: {
... ...
src/store/modules/lock.ts
... ... @@ -16,8 +16,8 @@ export const useLockStore = defineStore({
16 16 lockInfo: Persistent.getLocal(LOCK_INFO_KEY),
17 17 }),
18 18 getters: {
19   - getLockInfo(): Nullable<LockInfo> {
20   - return this.lockInfo;
  19 + getLockInfo(state): Nullable<LockInfo> {
  20 + return state.lockInfo;
21 21 },
22 22 },
23 23 actions: {
... ...
src/store/modules/multipleTab.ts
... ... @@ -48,14 +48,14 @@ export const useMultipleTabStore = defineStore({
48 48 lastDragEndIndex: 0,
49 49 }),
50 50 getters: {
51   - getTabList(): RouteLocationNormalized[] {
52   - return this.tabList;
  51 + getTabList(state): RouteLocationNormalized[] {
  52 + return state.tabList;
53 53 },
54   - getCachedTabList(): string[] {
55   - return Array.from(this.cacheTabList);
  54 + getCachedTabList(state): string[] {
  55 + return Array.from(state.cacheTabList);
56 56 },
57   - getLastDragEndIndex(): number {
58   - return this.lastDragEndIndex;
  57 + getLastDragEndIndex(state): number {
  58 + return state.lastDragEndIndex;
59 59 },
60 60 },
61 61 actions: {
... ...
src/store/modules/permission.ts
... ... @@ -60,20 +60,20 @@ export const usePermissionStore = defineStore({
60 60 frontMenuList: [],
61 61 }),
62 62 getters: {
63   - getPermCodeList(): string[] | number[] {
64   - return this.permCodeList;
  63 + getPermCodeList(state): string[] | number[] {
  64 + return state.permCodeList;
65 65 },
66   - getBackMenuList(): Menu[] {
67   - return this.backMenuList;
  66 + getBackMenuList(state): Menu[] {
  67 + return state.backMenuList;
68 68 },
69   - getFrontMenuList(): Menu[] {
70   - return this.frontMenuList;
  69 + getFrontMenuList(state): Menu[] {
  70 + return state.frontMenuList;
71 71 },
72   - getLastBuildMenuTime(): number {
73   - return this.lastBuildMenuTime;
  72 + getLastBuildMenuTime(state): number {
  73 + return state.lastBuildMenuTime;
74 74 },
75   - getIsDynamicAddedRoute(): boolean {
76   - return this.isDynamicAddedRoute;
  75 + getIsDynamicAddedRoute(state): boolean {
  76 + return state.isDynamicAddedRoute;
77 77 },
78 78 },
79 79 actions: {
... ...
src/store/modules/user.ts
... ... @@ -40,20 +40,20 @@ export const useUserStore = defineStore({
40 40 lastUpdateTime: 0,
41 41 }),
42 42 getters: {
43   - getUserInfo(): UserInfo {
44   - return this.userInfo || getAuthCache<UserInfo>(USER_INFO_KEY) || {};
  43 + getUserInfo(state): UserInfo {
  44 + return state.userInfo || getAuthCache<UserInfo>(USER_INFO_KEY) || {};
45 45 },
46   - getToken(): string {
47   - return this.token || getAuthCache<string>(TOKEN_KEY);
  46 + getToken(state): string {
  47 + return state.token || getAuthCache<string>(TOKEN_KEY);
48 48 },
49   - getRoleList(): RoleEnum[] {
50   - return this.roleList.length > 0 ? this.roleList : getAuthCache<RoleEnum[]>(ROLES_KEY);
  49 + getRoleList(state): RoleEnum[] {
  50 + return state.roleList.length > 0 ? state.roleList : getAuthCache<RoleEnum[]>(ROLES_KEY);
51 51 },
52   - getSessionTimeout(): boolean {
53   - return !!this.sessionTimeout;
  52 + getSessionTimeout(state): boolean {
  53 + return !!state.sessionTimeout;
54 54 },
55   - getLastUpdateTime(): number {
56   - return this.lastUpdateTime;
  55 + getLastUpdateTime(state): number {
  56 + return state.lastUpdateTime;
57 57 },
58 58 },
59 59 actions: {
... ...