Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
client
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
dad5847d
authored
Apr 26, 2024
by
赵月辉
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改系统路由不需要登录的白名单
parent
11ede501
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
src/permission.js
+7
-5
No files found.
src/permission.js
View file @
dad5847d
...
...
@@ -9,9 +9,9 @@ import useUserStore from '@/store/modules/user'
import
useSettingsStore
from
'@/store/modules/settings'
import
usePermissionStore
from
'@/store/modules/permission'
NProgress
.
configure
({
showSpinner
:
false
});
NProgress
.
configure
({
showSpinner
:
false
})
const
whiteList
=
[
'/login'
,
'/register'
,
'/index'
,
'/computingResource/resourceList'
];
const
whiteList
=
[
'/login'
,
'/register'
,
'/index'
,
'/computingResource/resourceList'
]
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
NProgress
.
start
()
...
...
@@ -19,9 +19,11 @@ router.beforeEach((to, from, next) => {
to
.
meta
.
title
&&
useSettingsStore
().
setTitle
(
to
.
meta
.
title
)
/* has token*/
if
(
to
.
path
===
'/login'
)
{
next
({
path
:
'/'
})
next
({
path
:
'/'
})
NProgress
.
done
()
}
else
if
(
whiteList
.
indexOf
(
to
.
path
)
!==
-
1
)
{
useUserStore
().
getInfo
().
then
(
res
=>
{
})
next
()
}
else
{
if
(
useUserStore
().
roles
.
length
===
0
)
{
...
...
@@ -36,12 +38,12 @@ router.beforeEach((to, from, next) => {
router
.
addRoute
(
route
)
// 动态添加可访问路由表
}
})
next
({
...
to
,
replace
:
true
})
// hack方法 确保addRoutes已完成
next
({
...
to
,
replace
:
true
})
// hack方法 确保addRoutes已完成
})
}).
catch
(
err
=>
{
useUserStore
().
logOut
().
then
(()
=>
{
ElMessage
.
error
(
err
)
next
({
path
:
'/'
})
next
({
path
:
'/'
})
})
})
}
else
{
...
...
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