This commit is contained in:
qsh
2024-08-01 18:41:37 +08:00
parent feccb2a1fa
commit 605151c5c8
17 changed files with 143 additions and 137 deletions

View File

@@ -1,4 +1,5 @@
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
import { CACHE_KEY } from '@/hooks/web/useCache'
import cache from '@/plugins/cache'
const { t } = useI18n() // 国际化
@@ -9,10 +10,9 @@ const { t } = useI18n() // 国际化
*/
export function checkPermi(value: string[]) {
if (value && value instanceof Array && value.length > 0) {
const { wsCache } = useCache()
const permissionDatas = value
const all_permission = '*:*:*'
const permissions = wsCache.get(CACHE_KEY.USER).permissions
const permissions = cache.local.get(CACHE_KEY.USER).permissions
const hasPermission = permissions.some((permission) => {
return all_permission === permission || permissionDatas.includes(permission)
})
@@ -30,10 +30,9 @@ export function checkPermi(value: string[]) {
*/
export function checkRole(value: string[]) {
if (value && value instanceof Array && value.length > 0) {
const { wsCache } = useCache()
const permissionRoles = value
const super_admin = 'admin'
const roles = wsCache.get(CACHE_KEY.USER).roles
const roles = cache.local.get(CACHE_KEY.USER).roles
const hasRole = roles.some((role) => {
return super_admin === role || permissionRoles.includes(role)
})