/*
 * 按页面解析按钮权限的封装
 */

export function getPagePermissions(access: any, pathname: string): Set<string> {
  try {
    if (!access || typeof access.whatCanIDoInThisPage !== 'function')
      return new Set();
    const tabs = access.whatCanIDoInThisPage(pathname);
    const codes = Array.isArray(tabs) ? tabs.map((t: any) => t.code) : [];
    return new Set(codes);
  } catch {
    return new Set();
  }
}
