feat: 1. 修改完善全局路由检测。 2. 完善统一的token认证管理,token失效自动跳转到登录页。
This commit is contained in:
@@ -17,6 +17,7 @@ interface PreviousRouteData {
|
||||
|
||||
interface Handle {
|
||||
breadcrumb: string | ((data: unknown) => string);
|
||||
to?: string; // 自定义面包屑链接
|
||||
previousRoute?: PreviousRouteData | ((data: unknown) => PreviousRouteData | undefined);
|
||||
breadcrumbClassName?: string;
|
||||
}
|
||||
@@ -36,10 +37,10 @@ export function Breadcrumb({ items = [], className = '' }: BreadcrumbProps) {
|
||||
.map((match, index, array) => {
|
||||
// 当前路由的面包屑
|
||||
const current = {
|
||||
title: typeof match.handle?.breadcrumb === 'function'
|
||||
title: typeof match.handle?.breadcrumb === 'function'
|
||||
? match.handle.breadcrumb(match.data)
|
||||
: match.handle?.breadcrumb as string,
|
||||
to: match.pathname
|
||||
to: match.handle?.to || match.pathname // 优先使用 handle.to,否则使用 pathname
|
||||
};
|
||||
|
||||
// 如果当前路由有previousRoute属性且该路由是数组中的最后一个
|
||||
|
||||
@@ -11,29 +11,10 @@ interface SidebarProps {
|
||||
selectedApp?: string; // 添加所选应用模块参数
|
||||
}
|
||||
|
||||
// 定义不同应用模块下显示的菜单路径(使用路由路径进行匹配)
|
||||
const APP_MENU_MAP = {
|
||||
'contract': [
|
||||
'/home', // 系统概览
|
||||
'/documents', // 文档管理
|
||||
'/contract-template', // 合同模板
|
||||
'/rules', // 评查规则库
|
||||
'/cross-checking', // 交叉评查
|
||||
// '/chat-with-llm', // AI法务助手
|
||||
'/settings' // 系统设置
|
||||
],
|
||||
'record': [
|
||||
'/home', // 系统概览
|
||||
'/documents', // 文档管理
|
||||
'/rules', // 评查规则库
|
||||
'/cross-checking', // 交叉评查
|
||||
// '/chat-with-llm', // AI法务助手
|
||||
'/settings' // 系统设置
|
||||
],
|
||||
'model': [
|
||||
'/chat-with-llm' // AI法务助手
|
||||
]
|
||||
};
|
||||
// 已移除 APP_MENU_MAP:路由的显示/隐藏由后端 is_hidden 字段控制
|
||||
// 只保留特殊规则:
|
||||
// - /chat-with-llm 只在 model 模块中显示
|
||||
// - /contract-template 只在 contract 模块中显示
|
||||
|
||||
// 应用模块名称映射
|
||||
const APP_NAME_MAP: Record<string, string> = {
|
||||
@@ -257,12 +238,7 @@ export function Sidebar({ onToggle, collapsed, userRole, frontendJWT = '', selec
|
||||
// console.log('子菜单点击:', child.title, '路径:', child.path);
|
||||
};
|
||||
|
||||
// 获取当前应用模式下应显示的菜单路径列表
|
||||
const visibleMenuPaths = APP_MENU_MAP[currentApp as keyof typeof APP_MENU_MAP] || APP_MENU_MAP['contract'];
|
||||
// console.log('当前应用模式:', currentApp, '可见菜单路径:', visibleMenuPaths);
|
||||
|
||||
// 检查是否通过51707端口访问(省局)
|
||||
// const isPort51708 = typeof window !== 'undefined' && window.location.port === '51708';
|
||||
const isPort51707 = typeof window !== 'undefined' && window.location.port === '51707';
|
||||
|
||||
// 根据当前应用模式过滤菜单项
|
||||
@@ -278,11 +254,17 @@ export function Sidebar({ onToggle, collapsed, userRole, frontendJWT = '', selec
|
||||
}
|
||||
}
|
||||
|
||||
// 检查当前菜单是否在所选应用模式中显示(使用路径匹配)
|
||||
if (!visibleMenuPaths.includes(item.path)) {
|
||||
return false;
|
||||
// 特殊规则1:/chat-with-llm 只在 model 模块中显示
|
||||
if (item.path === '/chat-with-llm' || item.path?.startsWith('/chat-with-llm/')) {
|
||||
return currentApp === 'model';
|
||||
}
|
||||
|
||||
// 特殊规则2:/contract-template 只在 contract 模块中显示
|
||||
if (item.path === '/contract-template' || item.path?.startsWith('/contract-template/')) {
|
||||
return currentApp === 'contract';
|
||||
}
|
||||
|
||||
// 其他路由:后端已通过 is_hidden 控制显示/隐藏,这里全部保留
|
||||
return true;
|
||||
})
|
||||
.map(item => {
|
||||
|
||||
Reference in New Issue
Block a user