usePageAccess.ts 425 B

12345678910111213141516
  1. /*
  2. * 按页面解析按钮权限的封装
  3. */
  4. export function getPagePermissions(access: any, pathname: string): Set<string> {
  5. try {
  6. if (!access || typeof access.whatCanIDoInThisPage !== 'function') return new Set();
  7. const tabs = access.whatCanIDoInThisPage(pathname);
  8. const codes = Array.isArray(tabs) ? tabs.map((t: any) => t.code) : [];
  9. return new Set(codes);
  10. } catch {
  11. return new Set();
  12. }
  13. }