perf: respect the writing style of pinia getters
parent
3eb17d283f
commit
de43d8b30b
|
@ -31,19 +31,19 @@ export const useAppStore = defineStore('app', {
|
||||||
componentSize: 'middle'
|
componentSize: 'middle'
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
getPageLoading(): boolean {
|
getPageLoading(state): boolean {
|
||||||
return this.pageLoading
|
return state.pageLoading
|
||||||
},
|
},
|
||||||
getDarkMode(): 'light' | 'dark' | string {
|
getDarkMode(state): 'light' | 'dark' | string {
|
||||||
return this.darkMode || localStorage.getItem(APP_DARK_MODE_KEY_) || darkMode
|
return state.darkMode || localStorage.getItem(APP_DARK_MODE_KEY_) || darkMode
|
||||||
},
|
},
|
||||||
|
|
||||||
getBeforeMiniInfo(): BeforeMiniState {
|
getBeforeMiniInfo(state): BeforeMiniState {
|
||||||
return this.beforeMiniInfo
|
return state.beforeMiniInfo
|
||||||
},
|
},
|
||||||
|
|
||||||
getProjectConfig(): ProjectConfig {
|
getProjectConfig(state): ProjectConfig {
|
||||||
return this.projectConfig || ({} as ProjectConfig)
|
return state.projectConfig || ({} as ProjectConfig)
|
||||||
},
|
},
|
||||||
|
|
||||||
getHeaderSetting(): HeaderSetting {
|
getHeaderSetting(): HeaderSetting {
|
||||||
|
@ -58,8 +58,8 @@ export const useAppStore = defineStore('app', {
|
||||||
getMultiTabsSetting(): MultiTabsSetting {
|
getMultiTabsSetting(): MultiTabsSetting {
|
||||||
return this.getProjectConfig.multiTabsSetting
|
return this.getProjectConfig.multiTabsSetting
|
||||||
},
|
},
|
||||||
getComponentSize(): AppSizeType | undefined {
|
getComponentSize(state): AppSizeType | undefined {
|
||||||
return this.componentSize
|
return state.componentSize
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
|
|
@ -17,15 +17,15 @@ export const useDictStore = defineStore({
|
||||||
isSetDict: false
|
isSetDict: false
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
getDictMap(): Recordable {
|
getDictMap(state): Recordable {
|
||||||
const dictMap = ls.get(DICT_KEY)
|
const dictMap = ls.get(DICT_KEY)
|
||||||
if (dictMap) {
|
if (dictMap) {
|
||||||
this.dictMap = dictMap
|
state.dictMap = dictMap
|
||||||
}
|
}
|
||||||
return this.dictMap
|
return state.dictMap
|
||||||
},
|
},
|
||||||
getIsSetDict(): boolean {
|
getIsSetDict(state): boolean {
|
||||||
return this.isSetDict
|
return state.isSetDict
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
|
|
@ -19,11 +19,11 @@ export const useErrorLogStore = defineStore('app-error-log', {
|
||||||
errorLogListCount: 0
|
errorLogListCount: 0
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
getErrorLogInfoList(): ErrorLogInfo[] {
|
getErrorLogInfoList(state): ErrorLogInfo[] {
|
||||||
return this.errorLogInfoList || []
|
return state.errorLogInfoList || []
|
||||||
},
|
},
|
||||||
getErrorLogListCount(): number {
|
getErrorLogListCount(state): number {
|
||||||
return this.errorLogListCount
|
return state.errorLogListCount
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
|
|
@ -20,11 +20,11 @@ export const useLocaleStore = defineStore('app-locale', {
|
||||||
localInfo: lsLocaleSetting
|
localInfo: lsLocaleSetting
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
getShowPicker(): boolean {
|
getShowPicker(state): boolean {
|
||||||
return !!this.localInfo?.showPicker
|
return !!state.localInfo?.showPicker
|
||||||
},
|
},
|
||||||
getLocale(): LocaleType {
|
getLocale(state): LocaleType {
|
||||||
return this.localInfo?.locale ?? 'zh_CN'
|
return state.localInfo?.locale ?? 'zh_CN'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
|
|
@ -15,8 +15,8 @@ export const useLockStore = defineStore('app-lock', {
|
||||||
lockInfo: Persistent.getLocal(LOCK_INFO_KEY)
|
lockInfo: Persistent.getLocal(LOCK_INFO_KEY)
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
getLockInfo(): Nullable<LockInfo> {
|
getLockInfo(state): Nullable<LockInfo> {
|
||||||
return this.lockInfo
|
return state.lockInfo
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
|
|
@ -46,14 +46,14 @@ export const useMultipleTabStore = defineStore('app-multiple-tab', {
|
||||||
lastDragEndIndex: 0
|
lastDragEndIndex: 0
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
getTabList(): RouteLocationNormalized[] {
|
getTabList(state): RouteLocationNormalized[] {
|
||||||
return this.tabList
|
return state.tabList
|
||||||
},
|
},
|
||||||
getCachedTabList(): string[] {
|
getCachedTabList(state): string[] {
|
||||||
return Array.from(this.cacheTabList)
|
return Array.from(state.cacheTabList)
|
||||||
},
|
},
|
||||||
getLastDragEndIndex(): number {
|
getLastDragEndIndex(state): number {
|
||||||
return this.lastDragEndIndex
|
return state.lastDragEndIndex
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
|
|
@ -54,20 +54,20 @@ export const usePermissionStore = defineStore('app-permission', {
|
||||||
frontMenuList: []
|
frontMenuList: []
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
getPermCodeList(): string[] | number[] {
|
getPermCodeList(state): string[] | number[] {
|
||||||
return this.permCodeList
|
return state.permCodeList
|
||||||
},
|
},
|
||||||
getBackMenuList(): Menu[] {
|
getBackMenuList(state): Menu[] {
|
||||||
return this.backMenuList
|
return state.backMenuList
|
||||||
},
|
},
|
||||||
getFrontMenuList(): Menu[] {
|
getFrontMenuList(state): Menu[] {
|
||||||
return this.frontMenuList
|
return state.frontMenuList
|
||||||
},
|
},
|
||||||
getLastBuildMenuTime(): number {
|
getLastBuildMenuTime(state): number {
|
||||||
return this.lastBuildMenuTime
|
return state.lastBuildMenuTime
|
||||||
},
|
},
|
||||||
getIsDynamicAddedRoute(): boolean {
|
getIsDynamicAddedRoute(state): boolean {
|
||||||
return this.isDynamicAddedRoute
|
return state.isDynamicAddedRoute
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
|
|
@ -42,23 +42,23 @@ export const useUserStore = defineStore('app-user', {
|
||||||
lastUpdateTime: 0
|
lastUpdateTime: 0
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
getUserInfo(): GetUserInfoModel {
|
getUserInfo(state): GetUserInfoModel {
|
||||||
return this.userInfo || getAuthCache<GetUserInfoModel>(USER_INFO_KEY) || {}
|
return state.userInfo || getAuthCache<GetUserInfoModel>(USER_INFO_KEY) || {}
|
||||||
},
|
},
|
||||||
getAccessToken(): string {
|
getAccessToken(state): string {
|
||||||
return this.accessToken || getAuthCache<string>(ACCESS_TOKEN_KEY)
|
return state.accessToken || getAuthCache<string>(ACCESS_TOKEN_KEY)
|
||||||
},
|
},
|
||||||
getRefreshToken(): string {
|
getRefreshToken(state): string {
|
||||||
return this.refreshToken || getAuthCache<string>(REFRESH_TOKEN_KEY)
|
return state.refreshToken || getAuthCache<string>(REFRESH_TOKEN_KEY)
|
||||||
},
|
},
|
||||||
getRoleList(): RoleEnum[] {
|
getRoleList(state): RoleEnum[] {
|
||||||
return this.roleList.length > 0 ? this.roleList : getAuthCache<RoleEnum[]>(ROLES_KEY)
|
return state.roleList.length > 0 ? state.roleList : getAuthCache<RoleEnum[]>(ROLES_KEY)
|
||||||
},
|
},
|
||||||
getSessionTimeout(): boolean {
|
getSessionTimeout(state): boolean {
|
||||||
return !!this.sessionTimeout
|
return !!state.sessionTimeout
|
||||||
},
|
},
|
||||||
getLastUpdateTime(): number {
|
getLastUpdateTime(state): number {
|
||||||
return this.lastUpdateTime
|
return state.lastUpdateTime
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
|
Loading…
Reference in New Issue