Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
front-backend
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
framework
front-backend
Commits
f1299856
Commit
f1299856
authored
Jun 11, 2021
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复四级菜单无法显示问题
parent
226ca495
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
src/router/index.js
+1
-1
src/store/modules/permission.js
+11
-5
No files found.
src/router/index.js
View file @
f1299856
...
...
@@ -56,7 +56,7 @@ export const loadMenus = (next, to) => {
const
sdata
=
JSON
.
parse
(
JSON
.
stringify
(
res
))
const
rdata
=
JSON
.
parse
(
JSON
.
stringify
(
res
))
const
sidebarRoutes
=
filterAsyncRouter
(
sdata
)
const
rewriteRoutes
=
filterAsyncRouter
(
rdata
,
true
)
const
rewriteRoutes
=
filterAsyncRouter
(
rdata
,
false
,
true
)
rewriteRoutes
.
push
({
path
:
'*'
,
redirect
:
'/404'
,
hidden
:
true
})
store
.
dispatch
(
'GenerateRoutes'
,
rewriteRoutes
).
then
(()
=>
{
// 存储路由
...
...
src/store/modules/permission.js
View file @
f1299856
...
...
@@ -27,9 +27,9 @@ const permission = {
}
}
export
const
filterAsyncRouter
=
(
routers
,
isRewrit
e
=
false
)
=>
{
// 遍历后台传来的路由字符串,转换为组件对象
export
const
filterAsyncRouter
=
(
routers
,
lastRouter
=
false
,
typ
e
=
false
)
=>
{
// 遍历后台传来的路由字符串,转换为组件对象
return
routers
.
filter
(
router
=>
{
if
(
isRewrit
e
&&
router
.
children
)
{
if
(
typ
e
&&
router
.
children
)
{
router
.
children
=
filterChildren
(
router
.
children
)
}
if
(
router
.
component
)
{
...
...
@@ -42,14 +42,17 @@ export const filterAsyncRouter = (routers, isRewrite = false) => { // 遍历后
router
.
component
=
loadView
(
component
)
}
}
if
(
router
.
children
&&
router
.
children
.
length
)
{
router
.
children
=
filterAsyncRouter
(
router
.
children
,
router
,
isRewrite
)
if
(
router
.
children
!=
null
&&
router
.
children
&&
router
.
children
.
length
)
{
router
.
children
=
filterAsyncRouter
(
router
.
children
,
router
,
type
)
}
else
{
delete
router
[
'children'
]
delete
router
[
'redirect'
]
}
return
true
})
}
function
filterChildren
(
childrenMap
)
{
function
filterChildren
(
childrenMap
,
lastRouter
=
false
)
{
var
children
=
[]
childrenMap
.
forEach
((
el
,
index
)
=>
{
if
(
el
.
children
&&
el
.
children
.
length
)
{
...
...
@@ -65,6 +68,9 @@ function filterChildren(childrenMap) {
return
}
}
if
(
lastRouter
)
{
el
.
path
=
lastRouter
.
path
+
'/'
+
el
.
path
}
children
=
children
.
concat
(
el
)
})
return
children
...
...
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