保存规则库 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;
}