优化 permission 相关的注释

This commit is contained in:
YunaiV
2022-10-23 20:21:04 +08:00
parent a13fb61359
commit 3cee922e69
8 changed files with 27 additions and 23 deletions

View File

@@ -2,22 +2,21 @@
* 操作权限处理
* Copyright (c) 2019 ruoyi
*/
import store from '@/store'
export default {
inserted(el, binding, vnode) {
const { value } = binding
const all_permission = "*:*:*";
const permissions = store.getters && store.getters.permissions
const all_permission = "*:*:*"; // 全部权限
const permissions = store.getters && store.getters.permissions // 用户拥有的权限标识的数组
if (value && value instanceof Array && value.length > 0) {
// 判断是否有权限
const permissionFlag = value
const hasPermissions = permissions.some(permission => {
return all_permission === permission || permissionFlag.includes(permission)
})
// 如果没有权限,则移除元素
if (!hasPermissions) {
el.parentNode && el.parentNode.removeChild(el)
}