| | |
| | | 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 |
| | |
| | | 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) |
| | |
| | | await loginOut() |
| | | removeToken() |
| | | deleteUserCache() // 删除用户缓存 |
| | | deleteUserSessionCache() //删除路由缓存 |
| | | this.resetState() |
| | | }, |
| | | resetState() { |