保存规则库 YAML 维护改造进展

This commit is contained in:
2026-04-28 22:00:00 +08:00
parent 7b86293263
commit dce5ac0c9a
96 changed files with 36801 additions and 615 deletions
+93 -20
View File
@@ -169,9 +169,18 @@ export function Sidebar({ onToggle, collapsed, userRole, frontendJWT = '' }: Sid
}));
};
const isActive = (path: string) => {
return location.pathname === path || location.pathname.startsWith(`${path}/`);
};
const isActive = (path: string) => {
const target = new URL(path, 'http://sidebar.local');
if (target.search) {
const currentParams = new URLSearchParams(location.search);
return location.pathname === target.pathname && Array.from(target.searchParams.entries()).every(
([key, value]) => currentParams.get(key) === value
);
}
return location.pathname === target.pathname || location.pathname.startsWith(`${target.pathname}/`);
};
// 处理侧边栏切换事件
const handleToggleSidebar = (e: React.MouseEvent) => {
@@ -181,17 +190,81 @@ export function Sidebar({ onToggle, collapsed, userRole, frontendJWT = '' }: Sid
onToggle();
};
// 处理子菜单项点击事件
const handleSubMenuClick = (child: MenuItem, e: React.MouseEvent) => {
// 只需要阻止冒泡,不阻止默认行为
e.stopPropagation();
// console.log('子菜单点击:', child.title, '路径:', child.path);
};
// const isPort51707 = typeof window !== 'undefined' && window.location.port === '51707'
// 处理菜单项:清理子菜单结构
const processedMenuItems: MenuItem[] = menuItems.filter(item =>{
// 处理子菜单项点击事件
const handleSubMenuClick = (child: MenuItem, e: React.MouseEvent) => {
// 只需要阻止冒泡,不阻止默认行为
e.stopPropagation();
// console.log('子菜单点击:', child.title, '路径:', child.path);
};
const isRuleManagementMenu = (item: MenuItem) =>
item.id === 'rule-management' ||
item.path === '/rules' ||
item.title === '评查规则库' ||
!!item.children?.some(child => child.id === 'rules-list' || child.path === '/rules/list');
const isCaseFileModule = selectedModuleName.includes('案卷') || selectedModuleName.includes('卷宗');
const buildRulesTestListPath = (mainType?: string) => {
const params = new URLSearchParams();
if (isCaseFileModule) {
params.set('documentType', '案卷');
if (mainType) params.set('mainType', mainType);
} else if (selectedModuleName.includes('合同')) {
params.set('documentType', '合同');
params.set('mainType', '合同');
} else if (selectedModuleName.includes('公文')) {
params.set('documentType', '内部公文');
params.set('mainType', '内部公文');
} else if (selectedModuleName) {
params.set('documentType', selectedModuleName);
params.set('mainType', selectedModuleName);
}
const query = params.toString();
return query ? `/rulesTest/list?${query}` : '/rulesTest/list';
};
const normalizeRuleManagementMenu = (item: MenuItem): MenuItem => {
if (!isRuleManagementMenu(item)) {
return item;
}
if (isCaseFileModule) {
return {
...item,
children: [
{
id: 'rules-admin-penalty',
title: '行政处罚',
path: buildRulesTestListPath('行政处罚'),
icon: 'ri-list-check-3',
order: 1
},
{
id: 'rules-admin-license',
title: '行政许可',
path: buildRulesTestListPath('行政许可'),
icon: 'ri-list-check-3',
order: 2
}
]
};
}
return {
...item,
children: item.children?.map(child => (
child.id === 'rules-list' || child.path === '/rules' || child.path === '/rules/list'
? { ...child, path: buildRulesTestListPath() }
: child
))
};
};
// const isPort51707 = typeof window !== 'undefined' && window.location.port === '51707'
// 处理菜单项:清理子菜单结构
const processedMenuItems: MenuItem[] = menuItems.filter(item =>{
// console.log('菜单项:', item.title, 'Icon:', item.icon)
// 🔑 优先检查:如果处于系统设置模式,只显示 /settings 及其子路由
@@ -255,11 +328,11 @@ export function Sidebar({ onToggle, collapsed, userRole, frontendJWT = '' }: Sid
if (item.path === '/contract-template' || item.path?.startsWith('/contract-template/')) {
return false;
}
// 保留其他菜单
return true;
}).map((item): MenuItem => {
// 保留其他菜单
return true;
}).map(normalizeRuleManagementMenu).map((item): MenuItem => {
// 处理子菜单:过滤隐藏的子菜单
if (item.children && item.children.length > 0) {
// 过滤掉 hideBreadcrumb=true 的子菜单(这些通常是隐藏菜单)
@@ -449,4 +522,4 @@ export function Sidebar({ onToggle, collapsed, userRole, frontendJWT = '' }: Sid
</div>
</>
);
}
}