Skip to content

Commit

Permalink
perf: respect the writing style of pinia getters (vbenjs#2645)
Browse files Browse the repository at this point in the history
  • Loading branch information
loosheng authored Mar 24, 2023
1 parent d620758 commit 74ded8a
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 44 deletions.
16 changes: 8 additions & 8 deletions src/store/modules/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ export const useAppStore = defineStore({
beforeMiniInfo: {},
}),
getters: {
getPageLoading(): boolean {
return this.pageLoading;
getPageLoading(state): boolean {
return state.pageLoading;
},
getDarkMode(): 'light' | 'dark' | string {
return this.darkMode || localStorage.getItem(APP_DARK_MODE_KEY_) || darkMode;
getDarkMode(state): 'light' | 'dark' | string {
return state.darkMode || localStorage.getItem(APP_DARK_MODE_KEY_) || darkMode;
},

getBeforeMiniInfo(): BeforeMiniState {
return this.beforeMiniInfo;
getBeforeMiniInfo(state): BeforeMiniState {
return state.beforeMiniInfo;
},

getProjectConfig(): ProjectConfig {
return this.projectConfig || ({} as ProjectConfig);
getProjectConfig(state): ProjectConfig {
return state.projectConfig || ({} as ProjectConfig);
},

getHeaderSetting(): HeaderSetting {
Expand Down
8 changes: 4 additions & 4 deletions src/store/modules/errorLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export const useErrorLogStore = defineStore({
errorLogListCount: 0,
}),
getters: {
getErrorLogInfoList(): ErrorLogInfo[] {
return this.errorLogInfoList || [];
getErrorLogInfoList(state): ErrorLogInfo[] {
return state.errorLogInfoList || [];
},
getErrorLogListCount(): number {
return this.errorLogListCount;
getErrorLogListCount(state): number {
return state.errorLogListCount;
},
},
actions: {
Expand Down
8 changes: 4 additions & 4 deletions src/store/modules/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export const useLocaleStore = defineStore({
localInfo: lsLocaleSetting,
}),
getters: {
getShowPicker(): boolean {
return !!this.localInfo?.showPicker;
getShowPicker(state): boolean {
return !!state.localInfo?.showPicker;
},
getLocale(): LocaleType {
return this.localInfo?.locale ?? 'zh_CN';
getLocale(state): LocaleType {
return state.localInfo?.locale ?? 'zh_CN';
},
},
actions: {
Expand Down
4 changes: 2 additions & 2 deletions src/store/modules/lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const useLockStore = defineStore({
lockInfo: Persistent.getLocal(LOCK_INFO_KEY),
}),
getters: {
getLockInfo(): Nullable<LockInfo> {
return this.lockInfo;
getLockInfo(state): Nullable<LockInfo> {
return state.lockInfo;
},
},
actions: {
Expand Down
12 changes: 6 additions & 6 deletions src/store/modules/multipleTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ export const useMultipleTabStore = defineStore({
lastDragEndIndex: 0,
}),
getters: {
getTabList(): RouteLocationNormalized[] {
return this.tabList;
getTabList(state): RouteLocationNormalized[] {
return state.tabList;
},
getCachedTabList(): string[] {
return Array.from(this.cacheTabList);
getCachedTabList(state): string[] {
return Array.from(state.cacheTabList);
},
getLastDragEndIndex(): number {
return this.lastDragEndIndex;
getLastDragEndIndex(state): number {
return state.lastDragEndIndex;
},
},
actions: {
Expand Down
20 changes: 10 additions & 10 deletions src/store/modules/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ export const usePermissionStore = defineStore({
frontMenuList: [],
}),
getters: {
getPermCodeList(): string[] | number[] {
return this.permCodeList;
getPermCodeList(state): string[] | number[] {
return state.permCodeList;
},
getBackMenuList(): Menu[] {
return this.backMenuList;
getBackMenuList(state): Menu[] {
return state.backMenuList;
},
getFrontMenuList(): Menu[] {
return this.frontMenuList;
getFrontMenuList(state): Menu[] {
return state.frontMenuList;
},
getLastBuildMenuTime(): number {
return this.lastBuildMenuTime;
getLastBuildMenuTime(state): number {
return state.lastBuildMenuTime;
},
getIsDynamicAddedRoute(): boolean {
return this.isDynamicAddedRoute;
getIsDynamicAddedRoute(state): boolean {
return state.isDynamicAddedRoute;
},
},
actions: {
Expand Down
20 changes: 10 additions & 10 deletions src/store/modules/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ export const useUserStore = defineStore({
lastUpdateTime: 0,
}),
getters: {
getUserInfo(): UserInfo {
return this.userInfo || getAuthCache<UserInfo>(USER_INFO_KEY) || {};
getUserInfo(state): UserInfo {
return state.userInfo || getAuthCache<UserInfo>(USER_INFO_KEY) || {};
},
getToken(): string {
return this.token || getAuthCache<string>(TOKEN_KEY);
getToken(state): string {
return state.token || getAuthCache<string>(TOKEN_KEY);
},
getRoleList(): RoleEnum[] {
return this.roleList.length > 0 ? this.roleList : getAuthCache<RoleEnum[]>(ROLES_KEY);
getRoleList(state): RoleEnum[] {
return state.roleList.length > 0 ? state.roleList : getAuthCache<RoleEnum[]>(ROLES_KEY);
},
getSessionTimeout(): boolean {
return !!this.sessionTimeout;
getSessionTimeout(state): boolean {
return !!state.sessionTimeout;
},
getLastUpdateTime(): number {
return this.lastUpdateTime;
getLastUpdateTime(state): number {
return state.lastUpdateTime;
},
},
actions: {
Expand Down

0 comments on commit 74ded8a

Please sign in to comment.