mirror of
https://gitee.com/anji-plus/report.git
synced 2026-03-20 09:38:35 +08:00
add v-permission
This commit is contained in:
13
report-ui/src/components/Permission/index.js
Normal file
13
report-ui/src/components/Permission/index.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import permission from './permission'
|
||||
|
||||
const install = function (Vue) {
|
||||
Vue.directive('permission', permission)
|
||||
}
|
||||
|
||||
if (window.Vue) {
|
||||
window['permission'] = permission
|
||||
Vue.use(install) // eslint-disable-line
|
||||
}
|
||||
|
||||
permission.install = install
|
||||
export default permission
|
||||
14
report-ui/src/components/Permission/permission.js
Normal file
14
report-ui/src/components/Permission/permission.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import store from '@/store'
|
||||
|
||||
export default {
|
||||
inserted(el, binding, vnode) {
|
||||
const { value } = binding // v-permission 绑定的权限值
|
||||
const auths = store.getters && store.getters.authorities // 拥有的权限列表
|
||||
if (value) {
|
||||
//auths.indexOf(value) === -1 && el.parentNode && el.parentNode.removeChild(el)
|
||||
} else {
|
||||
// 未绑定权限值或者绑定的权限值为 假
|
||||
return
|
||||
}
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user