Skip to content

Commit b7662b1

Browse files
authored
Merge pull request #53 from aqa510415008/patch-1
feat: add `v-action:add` action permission directive
2 parents 8688c8e + c18ae7b commit b7662b1

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

β€Žsrc/permission.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,37 @@ router.beforeEach((to, from, next) => {
6666
router.afterEach(() => {
6767
NProgress.done() // finish progress bar
6868
})
69+
70+
71+
72+
73+
/**Action ζƒι™ζŒ‡δ»€**/
74+
const action = Vue.directive('action', {
75+
bind: function (el, binding, vnode) {
76+
const actionName = binding.arg
77+
const roles = store.getters.roles
78+
const permissionId = vnode.context.$route.meta.permission
79+
let actions = []
80+
roles.permissions.forEach(p => {
81+
if (p.permissionId != permissionId) {
82+
return
83+
}
84+
actions = p.actionList
85+
})
86+
if (actions.indexOf(actionName) < 0) {
87+
setTimeout(() => {
88+
if(el.parentNode == null){
89+
el.style.display = 'none'
90+
}
91+
else{
92+
el.parentNode.removeChild(el)
93+
}
94+
}, 10)
95+
96+
}
97+
}
98+
})
99+
100+
export {
101+
action
102+
}

0 commit comments

Comments
Β (0)