From ca22cdd5550cfa0defb0f430c538698182cdaec1 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期一, 30 十二月 2024 16:42:49 +0800 Subject: [PATCH] Merge branch 'master' of http://dlindusit.com:53929/r/iailab-plat-ui-vue3 --- src/store/modules/user.ts | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 1e8ae63..e4c45fd 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -1,10 +1,17 @@ import { store } from '@/store' import { defineStore } from 'pinia' import { getAccessToken, removeToken } from '@/utils/auth' -import { CACHE_KEY, useCache, deleteUserCache } from '@/hooks/web/useCache' +import { + CACHE_KEY, + useCache, + deleteUserCache, + useSessionCache, + deleteUserSessionCache +} from '@/hooks/web/useCache' import { getInfo, loginOut } from '@/api/login' const { wsCache } = useCache() +const { wsSessionCache } = useSessionCache() interface UserVO { id: number @@ -61,9 +68,10 @@ this.roles = userInfo.roles this.user = userInfo.user this.isSetUser = true - console.log(userInfo.menus) wsCache.set(CACHE_KEY.USER, userInfo) - wsCache.set(CACHE_KEY.ROLE_ROUTERS, userInfo.menus) + if(!wsSessionCache.get(CACHE_KEY.ROLE_ROUTERS)) { + wsSessionCache.set(CACHE_KEY.ROLE_ROUTERS, userInfo.menus) + } }, async setUserAvatarAction(avatar: string) { const userInfo = wsCache.get(CACHE_KEY.USER) @@ -83,6 +91,7 @@ await loginOut() removeToken() deleteUserCache() // 删除用户缓存 + deleteUserSessionCache() //删除路由缓存 this.resetState() }, resetState() { -- Gitblit v1.9.3