diff --git a/frontend/src/core/directives/action.js b/frontend/src/core/directives/action.js
index 7ea921e..57f5dd3 100644
--- a/frontend/src/core/directives/action.js
+++ b/frontend/src/core/directives/action.js
@@ -14,16 +14,26 @@ import store from '../../store'
*
* @see https://github.com/sendya/ant-design-pro-vue/pull/53
*/
+/**
+ * 创建一个 Vue 自定义指令 'action',用于控制元素基于用户权限的显示
+ */
const action = Vue.directive('action', {
inserted: function (el, binding, vnode) {
+ // 获取指令的参数,即动作名称
const actionName = binding.arg
+ // 从 Vuex store 中获取当前用户的角色信息
const roles = store.getters.roles
+ // 获取当前路由的权限配置
const elVal = vnode.context.$route.meta.permission
+ // 确保权限配置为数组形式
const permissionId = elVal instanceof String && [elVal] || elVal
+ // 遍历用户角色的权限列表
roles.permissions.forEach(p => {
+ // 如果当前权限ID不在元素的权限配置中,直接返回
if (!permissionId.includes(p.permissionId)) {
return
}
+ // 如果当前权限有动作列表限制,且动作列表中不包含指令的参数,移除或隐藏元素
if (p.actionList && !p.actionList.includes(actionName)) {
el.parentNode && el.parentNode.removeChild(el) || (el.style.display = 'none')
}
diff --git a/frontend/src/layouts/BlankLayout.vue b/frontend/src/layouts/BlankLayout.vue
index 1bfbfbf..2032e13 100644
--- a/frontend/src/layouts/BlankLayout.vue
+++ b/frontend/src/layouts/BlankLayout.vue
@@ -1,16 +1,20 @@
+
diff --git a/frontend/src/layouts/PageView.vue b/frontend/src/layouts/PageView.vue
index 32ce5c2..05fbaea 100644
--- a/frontend/src/layouts/PageView.vue
+++ b/frontend/src/layouts/PageView.vue
@@ -1,10 +1,16 @@
+
+
+
+
+
+
{{ description }}
@@ -15,12 +21,15 @@
+
+
+
+
+
+