Unverified Commit b7662b1c by Anan Yang Committed by GitHub

Merge pull request #53 from aqa510415008/patch-1

feat: add `v-action:add`  action permission directive
parents 8688c8ea c18ae7bb
......@@ -66,3 +66,37 @@ router.beforeEach((to, from, next) => {
router.afterEach(() => {
NProgress.done() // finish progress bar
})
/**Action 权限指令**/
const action = Vue.directive('action', {
bind: function (el, binding, vnode) {
const actionName = binding.arg
const roles = store.getters.roles
const permissionId = vnode.context.$route.meta.permission
let actions = []
roles.permissions.forEach(p => {
if (p.permissionId != permissionId) {
return
}
actions = p.actionList
})
if (actions.indexOf(actionName) < 0) {
setTimeout(() => {
if(el.parentNode == null){
el.style.display = 'none'
}
else{
el.parentNode.removeChild(el)
}
}, 10)
}
}
})
export {
action
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment