保存规则库 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
@@ -4,6 +4,7 @@
*/
import { getUserRoutesByRole, type MenuItem } from './user-routes';
import { normalizeRoutePathForPermission } from '~/utils/route-alias';
/**
* 从 MenuItem 数组中提取所有路径(包括子路由)
@@ -50,15 +51,17 @@ function isDynamicIdSegment(segment: string): boolean {
* 检查路径是否在允许列表中
*/
function isPathAllowed(pathname: string, allowedPaths: string[]): boolean {
const checkPath = normalizeRoutePathForPermission(pathname);
// 精确匹配
if (allowedPaths.includes(pathname)) {
if (allowedPaths.includes(checkPath)) {
return true;
}
// 动态路由匹配
for (const allowedPath of allowedPaths) {
if (pathname.startsWith(allowedPath + '/')) {
const subPath = pathname.substring(allowedPath.length + 1);
if (checkPath.startsWith(allowedPath + '/')) {
const subPath = checkPath.substring(allowedPath.length + 1);
const segments = subPath.split('/');
const firstSegment = segments[0];
@@ -69,7 +72,7 @@ function isPathAllowed(pathname: string, allowedPaths: string[]): boolean {
}
// 根路径
if (pathname === '/') {
if (checkPath === '/') {
return true;
}
+5 -5
View File
@@ -124,7 +124,7 @@ const FALLBACK_MENU_DATA: Record<string, MenuItem[]> = {
{
id: 'rules-list',
title: '评查点列表',
path: '/rules',
path: '/rules/list',
icon: 'ri-list-check-3',
order: 2
},
@@ -266,7 +266,7 @@ const FALLBACK_MENU_DATA: Record<string, MenuItem[]> = {
{
id: 'rules-list',
title: '评查点列表',
path: '/rules',
path: '/rules/list',
icon: 'ri-list-check-3',
order: 2
},
@@ -381,7 +381,7 @@ const FALLBACK_MENU_DATA: Record<string, MenuItem[]> = {
{
id: 'rules-list',
title: '评查点列表',
path: '/rules',
path: '/rules/list',
icon: 'ri-list-check-3',
order: 2
},
@@ -489,7 +489,7 @@ const FALLBACK_MENU_DATA: Record<string, MenuItem[]> = {
{
id: 'rules-list',
title: '评查点列表',
path: '/rules',
path: '/rules/list',
icon: 'ri-list-check-3',
order: 2
},
@@ -1009,4 +1009,4 @@ export function mapUserRoleToRoleKey(userRole: string): string {
// 如果找不到映射,返回 userRole 本身(假设后端已经返回了正确的 role_key)
return roleMapping[userRole] || userRole || 'common';
}
}