feat: 1. 完善全局路由的访问权限的验证。 2. 完善接口返回的树形路由结构 3.优化评查点列表的查询,改用表连接的方式,废弃使用数据库的rpc函数,同时进行地区隔离和权限隔离。
4. 删除冗余的评查文件列表。 5.完善上传文档 页面初始化查询数据的时候 查询文件类型(改成动态指定) 6. 添加获取入口模块的查询接口。 7.完善服务端中判断token的有效性,失效则跳转到登录页。 8. 重构layout和sidebar的页面,改成由动态权限路由来渲染对应的菜单栏。 9.重构入口页面,通过动态查询根据不同地区的人返回不同的入口。
This commit is contained in:
@@ -96,24 +96,29 @@ function mergeAuthHeaders(
|
||||
explicitToken?: string
|
||||
): Record<string, string> {
|
||||
const headers = { ...existingHeaders };
|
||||
|
||||
|
||||
// 如果已经有 Authorization 头部(不区分大小写),不覆盖
|
||||
const hasAuth = Object.keys(headers).some(
|
||||
key => key.toLowerCase() === 'authorization'
|
||||
);
|
||||
|
||||
|
||||
if (hasAuth) {
|
||||
console.log('🔑 [mergeAuthHeaders] 已存在 Authorization 头,不覆盖');
|
||||
return headers;
|
||||
}
|
||||
|
||||
|
||||
// 优先使用显式传入的 token,否则尝试从客户端 localStorage 获取
|
||||
const token = explicitToken || (typeof window !== 'undefined' ? localStorage.getItem('access_token') : undefined);
|
||||
|
||||
// 如果有有效的 token(显式传入或从客户端获取),添加到 Authorization 头部
|
||||
if (token && token !== 'undefined') {
|
||||
// console.log('🔑 [mergeAuthHeaders] 添加 Authorization 头,token 来源:', explicitToken ? 'explicitToken' : 'localStorage');
|
||||
// console.log('🔑 [mergeAuthHeaders] Token 前10位:', token.substring(0, 10));
|
||||
headers['Authorization'] = `Bearer ${token}`;
|
||||
} else {
|
||||
console.warn('⚠️ [mergeAuthHeaders] 没有可用的 token!explicitToken:', explicitToken, 'window:', typeof window);
|
||||
}
|
||||
|
||||
|
||||
return headers;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user