From 3eeace94ddd709b8bbb0cf629076f5d1572bf440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=92=E8=8F=9C=E7=99=BD=E7=8E=89=E6=B1=A4?= <79054161+Azir-11@users.noreply.github.com> Date: Sat, 15 Jun 2024 00:39:53 +0800 Subject: [PATCH] fix(projects): Fix the issue of abnormal tab caching after logout. fixed #495 --- src/store/modules/auth/index.ts | 3 +++ src/store/modules/tab/index.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/store/modules/auth/index.ts b/src/store/modules/auth/index.ts index 7cf79b0a2..a8fb41d35 100644 --- a/src/store/modules/auth/index.ts +++ b/src/store/modules/auth/index.ts @@ -7,12 +7,14 @@ import { useRouterPush } from '@/hooks/common/router'; import { fetchGetUserInfo, fetchLogin } from '@/service/api'; import { localStg } from '@/utils/storage'; import { $t } from '@/locales'; +import { useTabStore } from '@/store/modules/tab'; import { useRouteStore } from '../route'; import { clearAuthStorage, getToken } from './shared'; export const useAuthStore = defineStore(SetupStoreId.Auth, () => { const route = useRoute(); const routeStore = useRouteStore(); + const tabStore = useTabStore(); const { toLogin, redirectFromLogin } = useRouterPush(false); const { loading: loginLoading, startLoading, endLoading } = useLoading(); @@ -47,6 +49,7 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => { await toLogin(); } + tabStore.cacheTabs(); routeStore.resetStore(); } diff --git a/src/store/modules/tab/index.ts b/src/store/modules/tab/index.ts index d1b68c550..85add103e 100644 --- a/src/store/modules/tab/index.ts +++ b/src/store/modules/tab/index.ts @@ -290,6 +290,7 @@ export const useTabStore = defineStore(SetupStoreId.Tab, () => { resetTabLabel, isTabRetain, updateTabsByLocale, - getTabIdByRoute + getTabIdByRoute, + cacheTabs }; });