Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
bdc
/
bdcdj-web
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
b35b85f1
authored
2022-11-03 17:36:11 +0800
by
任超
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
style:动态路由
1 parent
96db9287
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
25 deletions
src/permission.js
src/router/index.js
src/permission.js
View file @
b35b85f
...
...
@@ -21,20 +21,14 @@ router.beforeEach(async (to, from, next) => {
}
else
{
const
{
result
:
getMenuData
}
=
await
getMenuInfo
()
const
accessRoutes
=
await
store
.
dispatch
(
'permission/generateRoutes'
,
getMenuData
)
router
.
addRoutes
(
accessRoutes
)
const
routeTo
=
Cookies
.
get
(
'routerTo'
)
if
(
routeTo
)
{
next
(
routeTo
)
}
else
{
next
({
...
to
,
replace
:
true
})
}
router
.
addRoutes
([...
accessRoutes
,
{
path
:
'*'
,
redirect
:
'/404'
,
hidden
:
true
}])
next
({
...
to
,
replace
:
true
})
}
NProgress
.
done
()
})
router
.
afterEach
(
to
=>
{
// 解决刷新页面报404问题
console
.
log
(
to
.
fullPath
);
Cookies
.
set
(
"routerTo"
,
to
.
fullPath
)
NProgress
.
done
()
})
...
...
src/router/index.js
View file @
b35b85f
...
...
@@ -23,8 +23,8 @@ export const constantRoutes = [
{
path
:
'/'
,
component
:
Layout
,
meta
:
{
title
:
'404'
},
hidden
:
true
,
redirect
:
'/404'
,
children
:
[
{
path
:
'404'
,
...
...
@@ -49,22 +49,7 @@ export const constantRoutes = [
name
:
'workFrameView'
,
hidden
:
true
,
meta
:
{
title
:
'发起申请'
}
},
{
path
:
'*'
,
component
:
Layout
,
meta
:
{
title
:
'404'
},
redirect
:
'/404'
,
hidden
:
true
,
children
:
[
{
path
:
'404'
,
component
:
()
=>
import
(
'@/views/error-page/404'
),
name
:
'404'
,
meta
:
{
title
:
'404'
}
}
]
},
}
]
/**
* asyncRoutes
...
...
Please
register
or
sign in
to post a comment