修复路由meta.auth设置为''/[]时,权限判断为无权限的问题

This commit is contained in:
hooray 2023-02-22 21:01:54 +08:00
parent 108073b6e1
commit c253ef6fb4
2 changed files with 18 additions and 10 deletions

View File

@ -99,11 +99,15 @@ const useMenuStore = defineStore(
let isAuth = false
if (menu.meta && menu.meta.auth) {
isAuth = permissions.some((auth) => {
return typeof menu.meta?.auth === 'string'
? menu.meta.auth === auth
: typeof menu.meta?.auth === 'object'
? menu.meta.auth.includes(auth)
: false
if (typeof menu.meta?.auth === 'string') {
return menu.meta.auth !== '' ? menu.meta.auth === auth : true
}
else if (typeof menu.meta?.auth === 'object') {
return menu.meta.auth.length > 0 ? menu.meta.auth.includes(auth) : true
}
else {
return false
}
})
}
else {

View File

@ -111,11 +111,15 @@ const useRouteStore = defineStore(
let isAuth = false
if (route.meta?.auth) {
isAuth = permissions.some((auth) => {
return typeof route.meta?.auth === 'string'
? route.meta.auth === auth
: typeof route.meta?.auth === 'object'
? route.meta.auth.includes(auth)
: false
if (typeof route.meta?.auth === 'string') {
return route.meta.auth !== '' ? route.meta.auth === auth : true
}
else if (typeof route.meta?.auth === 'object') {
return route.meta.auth.length > 0 ? route.meta.auth.includes(auth) : true
}
else {
return false
}
})
}
else {