refactor(sub-nav,redirect-menu): 重构路由路径处理,支持传递query参数
统一在SubNav和redirectMenu组件中处理路由的完整路径,支持解析字符串格式的query参数,将其转换为对象格式存入_fullPath字段,保留原有的路径处理逻辑
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user