refactor(sub-nav,redirect-menu): 重构路由路径处理,支持传递query参数

统一在SubNav和redirectMenu组件中处理路由的完整路径,支持解析字符串格式的query参数,将其转换为对象格式存入_fullPath字段,保留原有的路径处理逻辑
This commit is contained in:
2026-06-23 14:35:22 +08:00
parent 1f16c984a8
commit 25b4dfe006
2 changed files with 18 additions and 2 deletions

View File

@@ -146,10 +146,18 @@ export default {
const ownPath = c.path.startsWith('/') ? c.path : path.resolve(parentPath, c.path)
const title = (c.meta && c.meta.title) || c.name || c.path
const hasChildren = c.children && c.children.length > 0 && c.children.some(gc => !gc.hidden)
let routeFullPath = ownPath
if (c.query) {
try {
routeFullPath = { path: ownPath, query: JSON.parse(c.query) }
} catch (e) {
routeFullPath = ownPath
}
}
const item = {
...c,
_ownPath: ownPath,
_fullPath: ownPath,
_fullPath: routeFullPath,
_title: title,
_hasChildren: hasChildren
}

View File

@@ -75,10 +75,18 @@ export default {
const ownPath = c.path.startsWith('/') ? c.path : path.resolve(parentPath, c.path)
const title = (c.meta && c.meta.title) || c.name || c.path || ''
const hasChildren = c.children && c.children.length > 0 && c.children.some(gc => !gc.hidden)
let routeFullPath = ownPath
if (c.query) {
try {
routeFullPath = { path: ownPath, query: JSON.parse(c.query) }
} catch (e) {
routeFullPath = ownPath
}
}
const item = {
...c,
_ownPath: ownPath,
_fullPath: ownPath,
_fullPath: routeFullPath,
_title: title,
_hasChildren: hasChildren
}