Skip to content

Commit 9a83387

Browse files
authored
Merge pull request #110 from AClumsy/patch-1
fix: $route.meta.permission to Array type, invalid v-action management
2 parents b052d5e + bc8a4e3 commit 9a83387

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

β€Žsrc/permission.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,16 @@ const action = Vue.directive('action', {
8484
bind: function (el, binding, vnode) {
8585
const actionName = binding.arg
8686
const roles = store.getters.roles
87-
const permissionId = vnode.context.$route.meta.permission
88-
let actions = []
87+
const elVal = vnode.context.$route.meta.permission
88+
const permissionId = elVal instanceof String && [elVal] || elVal
8989
roles.permissions.forEach(p => {
90-
if (p.permissionId !== permissionId) {
90+
if (!permissionId.includes(p.permissionId)) {
9191
return
9292
}
93-
actions = p.actionList
93+
if (p.actionList && !p.actionList.includes(actionName)) {
94+
el.parentNode && el.parentNode.removeChild(el) || (el.style.display = 'none')
95+
}
9496
})
95-
if (actions.indexOf(actionName) < 0) {
96-
el.parentNode && el.parentNode.removeChild(el) || (el.style.display = 'none')
97-
}
9897
}
9998
})
10099

0 commit comments

Comments
Β (0)