mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-04-05 16:56:35 +08:00
feat:新增pure-admin前端
This commit is contained in:
15
Yi.Pure.Vue3/src/directives/auth/index.ts
Normal file
15
Yi.Pure.Vue3/src/directives/auth/index.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { hasAuth } from "@/router/utils";
|
||||
import type { Directive, DirectiveBinding } from "vue";
|
||||
|
||||
export const auth: Directive = {
|
||||
mounted(el: HTMLElement, binding: DirectiveBinding<string | Array<string>>) {
|
||||
const { value } = binding;
|
||||
if (value) {
|
||||
!hasAuth(value) && el.parentNode?.removeChild(el);
|
||||
} else {
|
||||
throw new Error(
|
||||
"[Directive: auth]: need auths! Like v-auth=\"['btn.add','btn.edit']\""
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user