Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NLT-e-cigarette
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
张伯涛
NLT-e-cigarette
Commits
fef1e967
Commit
fef1e967
authored
Jun 14, 2022
by
张伯涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
31f4e7e1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
15 deletions
+26
-15
permission.js
src/permission.js
+2
-2
permission.js
src/store/modules/permission.js
+23
-13
user.js
src/store/modules/user.js
+1
-0
No files found.
src/permission.js
View file @
fef1e967
...
@@ -38,7 +38,7 @@ router.beforeEach((to, from, next) => {
...
@@ -38,7 +38,7 @@ router.beforeEach((to, from, next) => {
router
.
addRoutes
(
routers
.
accessedRoutes
)
// 动态添加可访问路由表
router
.
addRoutes
(
routers
.
accessedRoutes
)
// 动态添加可访问路由表
next
({
...
to
,
replace
:
true
})
// hack方法 确保addRoutes已完成
next
({
...
to
,
replace
:
true
})
// hack方法 确保addRoutes已完成
}
else
{
}
else
{
alert
(
'用户无权限
1
'
)
alert
(
'用户无权限'
)
store
.
dispatch
(
'FedLogOut'
).
then
(()
=>
{
store
.
dispatch
(
'FedLogOut'
).
then
(()
=>
{
next
({
path
:
'/'
})
next
({
path
:
'/'
})
// window.location.href = `${process.env.VUE_APP_LOGIN}?redirect=${to.fullPath}&reLocation=${process.env.VUE_APP_NQ}`
// window.location.href = `${process.env.VUE_APP_LOGIN}?redirect=${to.fullPath}&reLocation=${process.env.VUE_APP_NQ}`
...
@@ -46,7 +46,7 @@ router.beforeEach((to, from, next) => {
...
@@ -46,7 +46,7 @@ router.beforeEach((to, from, next) => {
}
}
})
})
}
else
{
}
else
{
alert
(
'用户无权限
2
'
)
alert
(
'用户无权限'
)
store
.
dispatch
(
'FedLogOut'
).
then
(()
=>
{
store
.
dispatch
(
'FedLogOut'
).
then
(()
=>
{
next
({
path
:
'/'
})
next
({
path
:
'/'
})
// window.location.href = `${process.env.VUE_APP_LOGIN}?redirect=${to.fullPath}&reLocation=${process.env.VUE_APP_NQ}`
// window.location.href = `${process.env.VUE_APP_LOGIN}?redirect=${to.fullPath}&reLocation=${process.env.VUE_APP_NQ}`
...
...
src/store/modules/permission.js
View file @
fef1e967
...
@@ -20,21 +20,31 @@ const permission = {
...
@@ -20,21 +20,31 @@ const permission = {
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
resolve
=>
{
// 向后端请求路由数据
// 向后端请求路由数据
// getInfo().then(res => {
// getInfo().then(res => {
const
accessedRoutes
=
filterAsyncRouter
(
res
.
data
.
menus
[
0
].
children
)
const
pathList
=
res
.
data
.
menus
.
map
(
item
=>
item
.
path
).
join
(
','
).
split
(
','
)
console
.
log
(
'进来了'
,
accessedRoutes
)
console
.
log
(
'pathList'
,
pathList
)
for
(
let
i
=
0
,
l
=
res
.
data
.
menus
[
0
].
children
.
length
;
i
<
l
;
i
++
)
{
if
(
pathList
.
includes
(
'nlt_pc'
))
{
if
(
res
.
data
.
menus
[
0
].
children
[
i
].
path
===
'/entry'
)
{
for
(
let
i
=
0
,
l
=
res
.
data
.
menus
.
length
;
i
<
l
;
i
++
)
{
res
.
data
.
menus
[
0
].
children
[
i
].
showFather
=
'false'
if
(
res
.
data
.
menus
[
i
].
path
===
'nlt_pc'
)
{
const
accessedRoutes
=
filterAsyncRouter
(
res
.
data
.
menus
[
i
].
children
)
const
newRouters
=
res
.
data
.
menus
[
i
].
path
// 当前用户pc端的菜单权限
console
.
log
(
'进来了'
,
accessedRoutes
)
for
(
let
j
=
0
,
l
=
res
.
data
.
menus
[
i
].
children
.
length
;
j
<
l
;
j
++
)
{
res
.
data
.
menus
[
i
].
children
[
j
].
showFather
=
'false'
}
if
(
accessedRoutes
[
0
])
{
const
firstChild
=
getFirstChild
(
accessedRoutes
[
0
])
accessedRoutes
.
push
({
path
:
'*'
,
redirect
:
'/404'
,
hidden
:
true
})
accessedRoutes
.
push
({
path
:
'/'
,
redirect
:
firstChild
,
hidden
:
true
})
commit
(
'SET_ROUTES'
,
accessedRoutes
)
}
const
routers
=
{
accessedRoutes
:
accessedRoutes
,
getRouters
:
newRouters
}
resolve
(
routers
)
}
}
}
}
else
{
const
routers
=
{
accessedRoutes
:
[],
getRouters
:
[]
}
resolve
(
routers
)
}
}
if
(
accessedRoutes
[
0
])
{
const
firstChild
=
getFirstChild
(
accessedRoutes
[
0
])
accessedRoutes
.
push
({
path
:
'*'
,
redirect
:
'/404'
,
hidden
:
true
})
accessedRoutes
.
push
({
path
:
'/'
,
redirect
:
firstChild
,
hidden
:
true
})
commit
(
'SET_ROUTES'
,
accessedRoutes
)
}
const
routers
=
{
accessedRoutes
:
accessedRoutes
,
getRouters
:
res
.
data
.
menus
[
1
].
children
}
resolve
(
routers
)
// })
// })
})
})
}
}
...
...
src/store/modules/user.js
View file @
fef1e967
...
@@ -95,6 +95,7 @@ const user = {
...
@@ -95,6 +95,7 @@ const user = {
FedLogOut
({
commit
})
{
FedLogOut
({
commit
})
{
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
resolve
=>
{
commit
(
'SET_TOKEN'
,
''
)
commit
(
'SET_TOKEN'
,
''
)
commit
(
'SET_ROLES'
,
[])
removeToken
()
removeToken
()
resolve
()
resolve
()
})
})
...
...
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