Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
scrm-base
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 9cd6f747
authored
Oct 08, 2023
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
递归获取无实际路径的菜单下的第一个子菜单的路径
1 parent
7731b911
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
src/store/modules/app.js
src/store/modules/app.js
View file @
9cd6f74
...
@@ -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
}
`
}
`
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment