Commit 59b13902 authored by 周远喜's avatar 周远喜

权限鉴定组件添加

parent a6b07f75
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<h1>总数:{{counter}}</h1> <h1>总数:{{counter}}</h1>
<h2>admin,user{{this.$store.state.admin.user.counter}}</h2> <h2>admin,user{{this.$store.state.admin.user.counter}}</h2>
<Button @click="increment">+</Button> <Button @click="increment">+</Button>
<Button type="error" @click="log">log</Button> <Button type="error" v-auth="['admin2']" @click="log">log</Button>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -4,6 +4,7 @@ import VueI18n from 'vue-i18n'; ...@@ -4,6 +4,7 @@ import VueI18n from 'vue-i18n';
import Languages from '@/i18n/locale'; import Languages from '@/i18n/locale';
// 插件 // 插件
import util from '@/libs/util'; import util from '@/libs/util';
import { includeArray } from '@/libs/system';
import VueDND from 'awe-dnd' //拖拽排序 import VueDND from 'awe-dnd' //拖拽排序
// import iViewPro from '@/libs/iViewPro/iview-pro.min.js'; // import iViewPro from '@/libs/iViewPro/iview-pro.min.js';
...@@ -76,6 +77,20 @@ export default ({ ...@@ -76,6 +77,20 @@ export default ({
} }
}) })
} }
Vue.directive('auth',{
inserted (el, binding, vnode) {
const { value } = binding;
const access = store.state.admin.user.info.access;
if (value && value instanceof Array && value.length && access && access.length) {
const isPermission = includeArray(value, access);
if (!isPermission) {
el.parentNode && el.parentNode.removeChild(el);
}
}
}
} )
// Vue.directive('paste', { // Vue.directive('paste', {
// bind(el, binding, vnode) { // bind(el, binding, vnode) {
// el.addEventListener('paste', function (event) { //这里直接监听元素的粘贴事件 // el.addEventListener('paste', function (event) { //这里直接监听元素的粘贴事件
......
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