Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
9
91isoft_sys_web
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
张伯涛
91isoft_sys_web
Commits
72e455f0
Commit
72e455f0
authored
Jun 08, 2022
by
张伯涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口getinfo重复调用问题
parent
d29df8b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
+14
-14
permission.js
src/permission.js
+2
-2
permission.js
src/store/modules/permission.js
+12
-12
No files found.
src/permission.js
View file @
72e455f0
...
...
@@ -26,8 +26,8 @@ router.beforeEach((to, from, next) => {
// 判断用户是否有权限 有角色
if
(
res
.
data
.
roles
&&
res
.
data
.
roles
.
length
>
0
&&
res
.
data
.
permissions
&&
res
.
data
.
permissions
.
length
>
0
)
{
// 拉取user_info
const
roles
=
res
.
data
.
roles
store
.
dispatch
(
'GenerateRoutes'
,
{
roles
}
).
then
((
routers
)
=>
{
//
const roles = res.data.roles
store
.
dispatch
(
'GenerateRoutes'
,
res
).
then
((
routers
)
=>
{
// 判断用户是否有路由
if
(
routers
.
accessedRoutes
&&
routers
.
accessedRoutes
.
length
>
0
&&
routers
.
getRouters
&&
routers
.
getRouters
.
length
>
0
)
{
// 测试 默认静态页面
...
...
src/store/modules/permission.js
View file @
72e455f0
...
...
@@ -16,20 +16,20 @@ const permission = {
},
actions
:
{
// 生成路由
GenerateRoutes
({
commit
})
{
GenerateRoutes
({
commit
}
,
res
)
{
return
new
Promise
(
resolve
=>
{
// 向后端请求路由数据
getInfo
().
then
(
res
=>
{
const
accessedRoutes
=
filterAsyncRouter
(
res
.
data
.
menus
)
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
}
resolve
(
routers
)
})
//
getInfo().then(res => {
const
accessedRoutes
=
filterAsyncRouter
(
res
.
data
.
menus
)
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
}
resolve
(
routers
)
//
})
})
}
}
...
...
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