Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
template_vue
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
胡宝山
template_vue
Commits
464dc789
Commit
464dc789
authored
May 22, 2024
by
张伯涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
不管是几级菜单,登录时都会显示第一个目录下的最小一级菜单
parent
525338ab
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
permission.js
src/permission.js
+10
-2
No files found.
src/permission.js
View file @
464dc789
...
@@ -12,6 +12,14 @@ NProgress.configure({ showSpinner: false }) // NProgress Configuration
...
@@ -12,6 +12,14 @@ NProgress.configure({ showSpinner: false }) // NProgress Configuration
const
whiteList
=
[
'/auth-redirect'
,
'/bind'
,
'/register'
,
'/login'
,
'/forgetPwd'
]
const
whiteList
=
[
'/auth-redirect'
,
'/bind'
,
'/register'
,
'/login'
,
'/forgetPwd'
]
/** 获取路由当中第一个目录下的最小一级菜单*/
export
function
getChildPath
(
item
)
{
if
(
item
[
0
].
children
&&
item
[
0
].
children
.
length
>
0
)
{
return
getChildPath
(
item
[
0
].
children
)
}
else
{
return
item
[
0
].
path
}
}
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
NProgress
.
start
()
NProgress
.
start
()
...
@@ -36,9 +44,9 @@ router.beforeEach((to, from, next) => {
...
@@ -36,9 +44,9 @@ router.beforeEach((to, from, next) => {
// store.dispatch('permission/generateRoutes', { roles }).then(accessRoutes => {
// store.dispatch('permission/generateRoutes', { roles }).then(accessRoutes => {
// 根据roles权限生成可访问的路由表
// 根据roles权限生成可访问的路由表
router
.
addRoutes
(
routers
.
accessedRoutes
)
// 动态添加可访问路由表
router
.
addRoutes
(
routers
.
accessedRoutes
)
// 动态添加可访问路由表
if
(
to
.
path
===
'/controlPlatform/control'
)
{
if
(
to
.
path
===
'/controlPlatform/control'
)
{
next
({
path
:
routers
.
accessedRoutes
[
0
].
children
[
0
].
path
,
replace
:
true
})
getChildPath
(
routers
.
accessedRoutes
)
// 获取路由当中第一个目录下的最小一级菜单,登陆后自动跳转到第一个目录下的最小一级菜单
next
({
path
:
getChildPath
(
routers
.
accessedRoutes
),
replace
:
true
})
}
else
{
}
else
{
next
({
...
to
,
replace
:
true
})
// hack方法 确保addRoutes已完成
next
({
...
to
,
replace
:
true
})
// hack方法 确保addRoutes已完成
}
}
...
...
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