Files
smart-admin/smart-admin-web-javascript/src/directives/privilege.js

30 lines
742 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* 权限
*
* @Author: 1024创新实验室-主任:卓大
* @Date: 2022-09-06 20:00:40
* @Wechat: zhuda1024
* @Email: lab1024@163.com
* @Copyright 1024创新实验室 https://1024lab.net Since 2012
*/
import { useUserStore } from '/@/store/modules/system/user';
import _ from 'lodash';
export function privilegeDirective(el, binding) {
// 超级管理员
if (useUserStore().administratorFlag) {
return true;
}
// 获取功能点权限
let userPointsList = useUserStore().getPointList;
if (!userPointsList) {
return false;
}
// 如果没有权限,删除节点
if (!_.some(userPointsList, ['webPerms', binding.value])) {
el.parentNode.removeChild(el);
}
return true;
}