From 74ded8aed7bd5f2e4f3008a4566d8e3dd0510566 Mon Sep 17 00:00:00 2001 From: LooSheng <30114549+loosheng@users.noreply.github.com> Date: Fri, 24 Mar 2023 17:48:35 +0800 Subject: [PATCH] perf: respect the writing style of pinia getters (#2645) --- src/store/modules/app.ts | 16 ++++++++-------- src/store/modules/errorLog.ts | 8 ++++---- src/store/modules/locale.ts | 8 ++++---- src/store/modules/lock.ts | 4 ++-- src/store/modules/multipleTab.ts | 12 ++++++------ src/store/modules/permission.ts | 20 ++++++++++---------- src/store/modules/user.ts | 20 ++++++++++---------- 7 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index 72f9bf6c..39563b68 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -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 { diff --git a/src/store/modules/errorLog.ts b/src/store/modules/errorLog.ts index a4b0b8c5..ffbdc0b0 100644 --- a/src/store/modules/errorLog.ts +++ b/src/store/modules/errorLog.ts @@ -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: { diff --git a/src/store/modules/locale.ts b/src/store/modules/locale.ts index 8d72ffc7..78202eaa 100644 --- a/src/store/modules/locale.ts +++ b/src/store/modules/locale.ts @@ -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: { diff --git a/src/store/modules/lock.ts b/src/store/modules/lock.ts index 6c22dbd1..da5ea003 100644 --- a/src/store/modules/lock.ts +++ b/src/store/modules/lock.ts @@ -16,8 +16,8 @@ export const useLockStore = defineStore({ lockInfo: Persistent.getLocal(LOCK_INFO_KEY), }), getters: { - getLockInfo(): Nullable { - return this.lockInfo; + getLockInfo(state): Nullable { + return state.lockInfo; }, }, actions: { diff --git a/src/store/modules/multipleTab.ts b/src/store/modules/multipleTab.ts index 2062c931..f742c2fc 100644 --- a/src/store/modules/multipleTab.ts +++ b/src/store/modules/multipleTab.ts @@ -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: { diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index 10097861..ef72681e 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -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: { diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 8461efdc..ea16c40d 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -40,20 +40,20 @@ export const useUserStore = defineStore({ lastUpdateTime: 0, }), getters: { - getUserInfo(): UserInfo { - return this.userInfo || getAuthCache(USER_INFO_KEY) || {}; + getUserInfo(state): UserInfo { + return state.userInfo || getAuthCache(USER_INFO_KEY) || {}; }, - getToken(): string { - return this.token || getAuthCache(TOKEN_KEY); + getToken(state): string { + return state.token || getAuthCache(TOKEN_KEY); }, - getRoleList(): RoleEnum[] { - return this.roleList.length > 0 ? this.roleList : getAuthCache(ROLES_KEY); + getRoleList(state): RoleEnum[] { + return state.roleList.length > 0 ? state.roleList : getAuthCache(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: {