Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pro-blocks
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
pro-blocks
Commits
212bc889
Commit
212bc889
authored
6 years ago
by
Amumu
Committed by
偏右
6 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
menu key对switch的子页面没有配置menu时取父菜单配置
menu key对switch的子页面没有配置menu时取父菜单配置
parent
89245734
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
src/common/router.js
src/common/router.js
+17
-2
No files found.
src/common/router.js
View file @
212bc889
...
...
@@ -70,6 +70,22 @@ function getFlatMenuData(menus) {
return
keys
;
}
function
findMenuKey
(
menuData
,
path
)
{
const
menuKey
=
Object
.
keys
(
menuData
).
find
(
key
=>
pathToRegexp
(
path
).
test
(
key
));
if
(
menuKey
==
null
)
{
if
(
path
===
'
/
'
)
{
return
null
;
}
const
lastIdx
=
path
.
lastIndexOf
(
'
/
'
);
if
(
lastIdx
<
0
)
{
return
null
;
}
// 如果没有,使用上一层的配置
return
findMenuKey
(
menuData
,
path
.
substr
(
0
,
lastIdx
));
}
return
menuKey
;
}
export
const
getRouterData
=
app
=>
{
const
routerConfig
=
{
'
/
'
:
{
...
...
@@ -185,8 +201,7 @@ export const getRouterData = app => {
Object
.
keys
(
routerConfig
).
forEach
(
path
=>
{
// Regular match item name
// eg. router /user/:id === /user/chen
const
pathRegexp
=
pathToRegexp
(
path
);
const
menuKey
=
Object
.
keys
(
menuData
).
find
(
key
=>
pathRegexp
.
test
(
`
${
key
}
`
));
const
menuKey
=
findMenuKey
(
menuData
,
path
);
let
menuItem
=
{};
// If menuKey is not empty
if
(
menuKey
)
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
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 comment