hejianhao
2025-02-28 40f9b52ab3497cb2a7c643d9175c9d65b50f8c16
删除方法
2个文件已修改
32 ■■■■■ 已修改文件
management/config/env.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
management/src/utils/utils.js 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
management/config/env.ts
@@ -7,6 +7,6 @@
    SERVER_URL: '',
  },
  prod: {
    SERVER_URL: '',
    SERVER_URL: 'https://huacheng.psciio.com',
  },
};
management/src/utils/utils.js
@@ -1,5 +1,4 @@
// import { getToken } from '@/utils/authority';
import pathRegexp from 'path-to-regexp';
import { parse } from 'querystring';
import { uploadFile } from './service'
/* eslint no-useless-escape:0 import/prefer-default-export:0 */
@@ -120,32 +119,3 @@
    })
    .catch(error => console.error('Error downloading file:', error));
}
export const getAuthorityFromRouter = (router = [], pathname) => {
  const authority = router.find(
    ({ routes, path = '/' }) =>
      (path && pathRegexp(path).exec(pathname)) ||
      (routes && getAuthorityFromRouter(routes, pathname)),
  );
  if (authority) return authority;
  return undefined;
};
export const getRouteAuthority = (path, routeData) => {
  let authorities;
  routeData.forEach((route) => {
    // match prefix
    if (pathRegexp(`${route.path}/(.*)`).test(`${path}/`)) {
      if (route.authority) {
        authorities = route.authority;
      } // exact match
      if (route.path === path) {
        authorities = route.authority || authorities;
      } // get children authority recursively
      if (route.routes) {
        authorities = getRouteAuthority(path, route.routes) || authorities;
      }
    }
  });
  return authorities;
};