Merge branch 'feature/bpm_fix_250121' of https://github.com/zws-code/yudao-ui-admin-vue3-fix into feature/bpm
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
|
||||
import {hasPermission} from "@/directives/permission/hasPermi";
|
||||
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
@ -7,21 +9,8 @@ const { t } = useI18n() // 国际化
|
||||
* @param {Array} value 校验值
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
export function checkPermi(value: string[]) {
|
||||
if (value && value instanceof Array && value.length > 0) {
|
||||
const { wsCache } = useCache()
|
||||
const permissionDatas = value
|
||||
const all_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
|
||||
} else {
|
||||
console.error(t('permission.hasPermission'))
|
||||
return false
|
||||
}
|
||||
export function checkPermi(permission: string[]) {
|
||||
return hasPermission(permission)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user