import { sessionStore } from './store';
//按钮权限
// 按钮全部存在
export function isTrue(...buttons: string[]) {
  const userInfo = sessionStore.get('user-info');
  const { admin } = userInfo?.user || {};
  if (admin) return true;
  const buttonList = sessionStore.get('button-list') || [];
  return buttons.every((button) => {
    return buttonList.includes(button);
  });
}
// 按钮全部不存在
export function isFalse(...buttons: string[]) {
  const userInfo = sessionStore.get('user-info');
  const { admin } = userInfo?.user || {};
  if (admin) return false;
  const buttonList = sessionStore.get('button-list') || [];
  return buttons.every((button) => {
    return !buttonList.includes(button);
  });
}

// 按钮有存在
export function isSomeTrue(...buttons: string[]) {
  const userInfo = sessionStore.get('user-info');
  const { admin } = userInfo?.user || {};
  if (admin) return true;
  const buttonList = sessionStore.get('button-list') || [];
  return buttons.some((button) => {
    return buttonList.includes(button);
  });
}
// 按钮有不存在
export function isSomeFalse(...buttons: string[]) {
  const buttonList = sessionStore.get('button-list') || [];
  const userInfo = sessionStore.get('user-info');
  const { admin } = userInfo?.user || {};
  if (admin) return false;
  return buttons.some((button) => {
    return !buttonList.includes(button);
  });
}
