|
@@ -11,18 +11,20 @@ const auth: Directive = {
|
|
|
const all_permission = '*:*:*'
|
|
|
const permissions = useUserStore().permissionCodes
|
|
|
|
|
|
- if (value && value instanceof Array && value.length > 0) {
|
|
|
- const permissionFlag = value
|
|
|
-
|
|
|
- const hasPermissions = permissions.some(permission => {
|
|
|
- return all_permission === permission || permissionFlag.includes(permission)
|
|
|
- })
|
|
|
+ if (typeof value === 'string') {
|
|
|
+ if (!permissions.includes(value)) {
|
|
|
+ el.parentNode && el.parentNode.removeChild(el)
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
+ if (value && value instanceof Array && value.length > 0) {
|
|
|
+ const hasPermissions = value.every(item => all_permission === item || permissions.includes(item))
|
|
|
if (!hasPermissions) {
|
|
|
el.parentNode && el.parentNode.removeChild(el)
|
|
|
}
|
|
|
} else {
|
|
|
- throw new Error(`请设置操作权限标签值`)
|
|
|
+ return false
|
|
|
}
|
|
|
}
|
|
|
}
|