Commit 9cd6f747 by liimin

递归获取无实际路径的菜单下的第一个子菜单的路径

1 parent 7731b911
...@@ -175,17 +175,22 @@ function __gen(moduleName, menu) { ...@@ -175,17 +175,22 @@ function __gen(moduleName, menu) {
*/ */
function getDefaultPath(menu) { function getDefaultPath(menu) {
const { name, children, sub = children.noHidden(), child = sub.length ? sub : children } = menu const { name, children, sub = children.noHidden(), child = sub.length ? sub : children } = menu
let { path } = child[0] const path = _loop(child)
if (path.includes('^')) {
// const [, targetPath] = path.split('^')
path = child[0].children.noHidden()[0].path
if (path.includes('^')) {
path = child[0].children.noHidden()[0].children.noHidden()[0].path
}
}
return _get_path_(name, path) return _get_path_(name, path)
} }
/**
* 递归获取无实际路径的菜单下的第一个子菜单的路径
* @param {*} menus
* @returns
*/
function _loop(menus) {
const { path } = menus.noHidden()[0]
if (path.includes('^')) {
return _loop(menus[0].children)
}
return path
}
function _get_path_(moduleName, p) { function _get_path_(moduleName, p) {
return `/${moduleName}${p.startsWith('/') ? p : `/${p}`}` return `/${moduleName}${p.startsWith('/') ? p : `/${p}`}`
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!