import { computed } from "vue";
import { useAuthStore } from "@/stores/modules/auth";

/**
 * @description 页面按钮权限
 * */
interface Params {
  [key: string]: string[];
}
export const useAuthButtons = (params: Params) => {
  const authStore = useAuthStore();

  const BUTTONS = computed(() => {
    let currentPageAuthButton: { [key: string]: boolean } = {};
    Object.keys(params).forEach(key => {
      currentPageAuthButton[key] = authStore.authButtonListGet.some(item => item === "*:*:*" || params[key].includes(item));
    });
    return currentPageAuthButton;
  });

  return {
    BUTTONS
  };
};
