fix: 修复 pathResolve 函数在 path 为空时返回 parentPath 的逻辑,避免拼接出错

This commit is contained in:
YunaiV 2025-07-21 16:44:34 +08:00
parent 9ac6017ccc
commit 1ee658fda5

View File

@ -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, '/')
}
// 路由降级