From d0f4c2d4bb7a72b32fb9945de8908e1d4ab6509c Mon Sep 17 00:00:00 2001 From: 董国庆 <364620639@qq.com> Date: 星期五, 06 六月 2025 14:13:58 +0800 Subject: [PATCH] 提交 --- management/src/utils/utils.js | 34 ++-------------------------------- 1 files changed, 2 insertions(+), 32 deletions(-) diff --git a/management/src/utils/utils.js b/management/src/utils/utils.js index 6de0872..97e1584 100644 --- a/management/src/utils/utils.js +++ b/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 */ @@ -58,7 +57,7 @@ ...params, }), headers: { - Authorization: localStorage.getItem('token'), + Authorization:'Bearer ' + localStorage.getItem('token'), 'ConTent-Type': 'application/json;charset=UTF-8', timestamp: new Date().getTime(), client: localStorage.getItem('client') @@ -86,7 +85,7 @@ method: 'get', responseType: 'blob', headers: { - Authorization: localStorage.getItem('token'), + Authorization:'Bearer ' + localStorage.getItem('token'), 'ConTent-Type': 'application/json;charset=UTF-8', timestamp: new Date().getTime(), client: localStorage.getItem('client') @@ -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; -}; -- Gitblit v1.7.1