初始化 ui.

This commit is contained in:
lijiahang
2023-07-27 18:48:15 +08:00
parent ee53ec6486
commit 5be2c7fda2
185 changed files with 1107 additions and 17815 deletions

View File

@@ -4,17 +4,16 @@ import { useUserStore } from '@/store';
function checkPermission(el: HTMLElement, binding: DirectiveBinding) {
const { value } = binding;
const userStore = useUserStore();
const { role } = userStore;
// TODO TEST
if (Array.isArray(value)) {
if (value.length > 0) {
const hasPermission = value.includes(role);
const hasPermission = userStore.permission?.includes(value as any as string);
if (!hasPermission && el.parentNode) {
el.parentNode.removeChild(el);
}
}
} else {
throw new Error(`need roles! Like v-permission="['admin','user']"`);
throw new Error(`need permission! Like v-permission="['permission']"`);
}
}
@@ -24,5 +23,5 @@ export default {
},
updated(el: HTMLElement, binding: DirectiveBinding) {
checkPermission(el, binding);
}
},
};