From 74ded8aed7bd5f2e4f3008a4566d8e3dd0510566 Mon Sep 17 00:00:00 2001 From: LooSheng <30114549+loosheng@users.noreply.github.com> Date: 星期五, 24 三月 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/multipleTab.ts | 12 +++--- src/store/modules/permission.ts | 20 +++++----- src/store/modules/errorLog.ts | 8 ++-- src/store/modules/user.ts | 20 +++++----- src/store/modules/locale.ts | 8 ++-- src/store/modules/lock.ts | 4 +- 7 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index 72f9bf6..39563b6 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -36,19 +36,19 @@ 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 a4b0b8c..ffbdc0b 100644 --- a/src/store/modules/errorLog.ts +++ b/src/store/modules/errorLog.ts @@ -20,11 +20,11 @@ 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 8d72ffc..78202ea 100644 --- a/src/store/modules/locale.ts +++ b/src/store/modules/locale.ts @@ -21,11 +21,11 @@ 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 6c22dbd..da5ea00 100644 --- a/src/store/modules/lock.ts +++ b/src/store/modules/lock.ts @@ -16,8 +16,8 @@ lockInfo: Persistent.getLocal(LOCK_INFO_KEY), }), getters: { - getLockInfo(): Nullable<LockInfo> { - return this.lockInfo; + getLockInfo(state): Nullable<LockInfo> { + return state.lockInfo; }, }, actions: { diff --git a/src/store/modules/multipleTab.ts b/src/store/modules/multipleTab.ts index 2062c93..f742c2f 100644 --- a/src/store/modules/multipleTab.ts +++ b/src/store/modules/multipleTab.ts @@ -48,14 +48,14 @@ 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 1009786..ef72681 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -60,20 +60,20 @@ 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 8461efd..ea16c40 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -40,20 +40,20 @@ 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: { -- Gitblit v1.8.0