You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
431 B

  1. import { hasAuth } from "@/router/utils";
  2. import { Directive, type DirectiveBinding } from "vue";
  3. export const auth: Directive = {
  4. mounted(el: HTMLElement, binding: DirectiveBinding) {
  5. const { value } = binding;
  6. if (value) {
  7. !hasAuth(value) && el.parentNode?.removeChild(el);
  8. } else {
  9. throw new Error(
  10. "[Directive: auth]: need auths! Like v-auth=\"['btn.add','btn.edit']\""
  11. );
  12. }
  13. }
  14. };