mirror of
https://gitee.com/hhyykk/ipms-sjy-ui.git
synced 2025-07-16 20:05:07 +08:00
🐞 fix:修复从“同时使用了用户信息和权限判断”的页面退出登录时异常问题
This commit is contained in:
@ -10,7 +10,8 @@ const RefreshTokenKey = 'REFRESH_TOKEN'
|
||||
// 获取token
|
||||
export const getAccessToken = () => {
|
||||
// 此处与TokenKey相同,此写法解决初始化时Cookies中不存在TokenKey报错
|
||||
return wsCache.get(AccessTokenKey) ? wsCache.get(AccessTokenKey) : wsCache.get('ACCESS_TOKEN')
|
||||
const accessToken = wsCache.get(AccessTokenKey)
|
||||
return accessToken ? accessToken : wsCache.get('ACCESS_TOKEN')
|
||||
}
|
||||
|
||||
// 刷新token
|
||||
|
@ -12,8 +12,9 @@ export function checkPermi(value: string[]) {
|
||||
const { wsCache } = useCache()
|
||||
const permissionDatas = value
|
||||
const all_permission = '*:*:*'
|
||||
const permissions = wsCache.get(CACHE_KEY.USER).permissions
|
||||
const hasPermission = permissions.some((permission) => {
|
||||
const userInfo = wsCache.get(CACHE_KEY.USER)
|
||||
const permissions = userInfo?.permissions || []
|
||||
const hasPermission = permissions.some((permission: string) => {
|
||||
return all_permission === permission || permissionDatas.includes(permission)
|
||||
})
|
||||
return !!hasPermission
|
||||
@ -33,8 +34,9 @@ export function checkRole(value: string[]) {
|
||||
const { wsCache } = useCache()
|
||||
const permissionRoles = value
|
||||
const super_admin = 'super_admin'
|
||||
const roles = wsCache.get(CACHE_KEY.USER).roles
|
||||
const hasRole = roles.some((role) => {
|
||||
const userInfo = wsCache.get(CACHE_KEY.USER)
|
||||
const roles = userInfo?.roles || []
|
||||
const hasRole = roles.some((role: string) => {
|
||||
return super_admin === role || permissionRoles.includes(role)
|
||||
})
|
||||
return !!hasRole
|
||||
|
Reference in New Issue
Block a user