From 1ee658fda5204382c51b58072cce3588026e4fc2 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 21 Jul 2025 16:44:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20pathResolve=20?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E5=9C=A8=20path=20=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E6=97=B6=E8=BF=94=E5=9B=9E=20parentPath=20=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E9=81=BF=E5=85=8D=E6=8B=BC=E6=8E=A5=E5=87=BA?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/routerHelper.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils/routerHelper.ts b/src/utils/routerHelper.ts index 7a87bd75..cf1b3622 100644 --- a/src/utils/routerHelper.ts +++ b/src/utils/routerHelper.ts @@ -101,7 +101,7 @@ export const generateRoute = (routes: AppCustomRouteRecordRaw[]): AppRouteRecord if (!route.children && route.parentId == 0 && route.component) { data.component = Layout data.meta = { - hidden: meta.hidden, + hidden: meta.hidden } data.name = toCamelCase(route.path, true) + 'Parent' data.redirect = '' @@ -170,8 +170,9 @@ const generateRoutePath = (parentPath: string, path: string) => { } export const pathResolve = (parentPath: string, path: string) => { if (isUrl(path)) return path - const childPath = path.startsWith('/') || !path ? path : `/${path}` - return `${parentPath}${childPath}`.replace(/\/\//g, '/') + if (!path) return parentPath // 修复 path 为空时返回 parentPath,避免拼接出错 https://t.zsxq.com/QVr6b + const childPath = path.startsWith('/') ? path : `/${path}` + return `${parentPath}${childPath}`.replace(/\/+/g, '/') } // 路由降级