perf: respect the writing style of pinia getters
parent
3eb17d283f
commit
de43d8b30b
|
@ -31,19 +31,19 @@ export const useAppStore = defineStore('app', {
|
|||
componentSize: 'middle'
|
||||
}),
|
||||
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 {
|
||||
|
@ -58,8 +58,8 @@ export const useAppStore = defineStore('app', {
|
|||
getMultiTabsSetting(): MultiTabsSetting {
|
||||
return this.getProjectConfig.multiTabsSetting
|
||||
},
|
||||
getComponentSize(): AppSizeType | undefined {
|
||||
return this.componentSize
|
||||
getComponentSize(state): AppSizeType | undefined {
|
||||
return state.componentSize
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
|
|
|
@ -17,15 +17,15 @@ export const useDictStore = defineStore({
|
|||
isSetDict: false
|
||||
}),
|
||||
getters: {
|
||||
getDictMap(): Recordable {
|
||||
getDictMap(state): Recordable {
|
||||
const dictMap = ls.get(DICT_KEY)
|
||||
if (dictMap) {
|
||||
this.dictMap = dictMap
|
||||
state.dictMap = dictMap
|
||||
}
|
||||
return this.dictMap
|
||||
return state.dictMap
|
||||
},
|
||||
getIsSetDict(): boolean {
|
||||
return this.isSetDict
|
||||
getIsSetDict(state): boolean {
|
||||
return state.isSetDict
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
|
|
|
@ -19,11 +19,11 @@ export const useErrorLogStore = defineStore('app-error-log', {
|
|||
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: {
|
||||
|
|
|
@ -20,11 +20,11 @@ export const useLocaleStore = defineStore('app-locale', {
|
|||
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: {
|
||||
|
|
|
@ -15,8 +15,8 @@ export const useLockStore = defineStore('app-lock', {
|
|||
lockInfo: Persistent.getLocal(LOCK_INFO_KEY)
|
||||
}),
|
||||
getters: {
|
||||
getLockInfo(): Nullable<LockInfo> {
|
||||
return this.lockInfo
|
||||
getLockInfo(state): Nullable<LockInfo> {
|
||||
return state.lockInfo
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
|
|
|
@ -46,14 +46,14 @@ export const useMultipleTabStore = defineStore('app-multiple-tab', {
|
|||
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: {
|
||||
|
|
|
@ -54,20 +54,20 @@ export const usePermissionStore = defineStore('app-permission', {
|
|||
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: {
|
||||
|
|
|
@ -42,23 +42,23 @@ export const useUserStore = defineStore('app-user', {
|
|||
lastUpdateTime: 0
|
||||
}),
|
||||
getters: {
|
||||
getUserInfo(): GetUserInfoModel {
|
||||
return this.userInfo || getAuthCache<GetUserInfoModel>(USER_INFO_KEY) || {}
|
||||
getUserInfo(state): GetUserInfoModel {
|
||||
return state.userInfo || getAuthCache<GetUserInfoModel>(USER_INFO_KEY) || {}
|
||||
},
|
||||
getAccessToken(): string {
|
||||
return this.accessToken || getAuthCache<string>(ACCESS_TOKEN_KEY)
|
||||
getAccessToken(state): string {
|
||||
return state.accessToken || getAuthCache<string>(ACCESS_TOKEN_KEY)
|
||||
},
|
||||
getRefreshToken(): string {
|
||||
return this.refreshToken || getAuthCache<string>(REFRESH_TOKEN_KEY)
|
||||
getRefreshToken(state): string {
|
||||
return state.refreshToken || getAuthCache<string>(REFRESH_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: {
|
||||
|
|
Loading…
Reference in New Issue