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 @@