From 560a336f8cc17768de404cd2d754d090417a9a22 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 29 Feb 2024 22:23:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7=E9=80=80?= =?UTF-8?q?=E5=87=BA=E7=99=BB=E5=BD=95=E6=97=B6=EF=BC=8C=E6=8A=8A=20LANG?= =?UTF-8?q?=E3=80=81THEME=E3=80=81LAYOUT=E3=80=81IS=5FDARK=20=E7=BB=99?= =?UTF-8?q?=E6=B8=85=E7=A9=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/axios/service.ts | 5 ++--- src/hooks/web/useCache.ts | 6 ++++++ .../UserInfo/src/components/LockPage.vue | 6 ++---- src/store/modules/user.ts | 20 ++++++++++++++++--- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/config/axios/service.ts b/src/config/axios/service.ts index 19b8c979..25936068 100644 --- a/src/config/axios/service.ts +++ b/src/config/axios/service.ts @@ -13,7 +13,7 @@ import { getAccessToken, getRefreshToken, getTenantId, removeToken, setToken } f import errorCode from './errorCode' import { resetRouter } from '@/router' -import { useCache } from '@/hooks/web/useCache' +import { deleteUserCache } from '@/hooks/web/useCache' const tenantEnable = import.meta.env.VITE_APP_TENANT_ENABLE const { result_code, base_url, request_timeout } = config @@ -217,9 +217,8 @@ const handleAuthorized = () => { confirmButtonText: t('login.relogin'), type: 'warning' }).then(() => { - const { wsCache } = useCache() resetRouter() // 重置静态路由表 - wsCache.clear() + deleteUserCache() // 删除用户缓存 removeToken() isRelogin.show = false // 干掉token后再走一次路由让它过router.beforeEach的校验 diff --git a/src/hooks/web/useCache.ts b/src/hooks/web/useCache.ts index 6d2a9318..2850bd5c 100644 --- a/src/hooks/web/useCache.ts +++ b/src/hooks/web/useCache.ts @@ -25,3 +25,9 @@ export const useCache = (type: CacheType = 'localStorage') => { wsCache } } + +export const deleteUserCache = () => { + const { wsCache } = useCache() + wsCache.delete(CACHE_KEY.USER) + wsCache.delete(CACHE_KEY.ROLE_ROUTERS) +} diff --git a/src/layout/components/UserInfo/src/components/LockPage.vue b/src/layout/components/UserInfo/src/components/LockPage.vue index 1de18fe6..497dd37b 100644 --- a/src/layout/components/UserInfo/src/components/LockPage.vue +++ b/src/layout/components/UserInfo/src/components/LockPage.vue @@ -1,6 +1,6 @@