/**
 * v-auth
 * 按钮权限指令
 */
import { useAuthButtons } from "@/hooks/useAuthButtons";
import type { Directive, DirectiveBinding } from "vue";

const auth: Directive = {
  mounted(el: HTMLElement, binding: DirectiveBinding) {
    const { value } = binding;
    const { BUTTONS } = useAuthButtons({ hasAuth: Array.isArray(value) ? value : [value] });
    if (!BUTTONS.value.hasAuth) {
      el.remove();
    }
  }
};

export default auth;
