style:动态路由
Showing
2 changed files
with
2 additions
and
23 deletions
... | @@ -21,20 +21,14 @@ router.beforeEach(async (to, from, next) => { | ... | @@ -21,20 +21,14 @@ router.beforeEach(async (to, from, next) => { |
21 | } else { | 21 | } else { |
22 | const { result: getMenuData } = await getMenuInfo() | 22 | const { result: getMenuData } = await getMenuInfo() |
23 | const accessRoutes = await store.dispatch('permission/generateRoutes', getMenuData) | 23 | const accessRoutes = await store.dispatch('permission/generateRoutes', getMenuData) |
24 | router.addRoutes(accessRoutes) | 24 | router.addRoutes([...accessRoutes, { path: '*', redirect: '/404', hidden: true }]) |
25 | const routeTo = Cookies.get('routerTo') | ||
26 | if (routeTo) { | ||
27 | next(routeTo) | ||
28 | } else { | ||
29 | next({ ...to, replace: true }) | 25 | next({ ...to, replace: true }) |
30 | } | 26 | } |
31 | } | ||
32 | NProgress.done() | 27 | NProgress.done() |
33 | 28 | ||
34 | }) | 29 | }) |
35 | router.afterEach(to => { | 30 | router.afterEach(to => { |
36 | // 解决刷新页面报404问题 | 31 | // 解决刷新页面报404问题 |
37 | console.log(to.fullPath); | ||
38 | Cookies.set("routerTo", to.fullPath) | 32 | Cookies.set("routerTo", to.fullPath) |
39 | NProgress.done() | 33 | NProgress.done() |
40 | }) | 34 | }) | ... | ... |
... | @@ -23,8 +23,8 @@ export const constantRoutes = [ | ... | @@ -23,8 +23,8 @@ export const constantRoutes = [ |
23 | { | 23 | { |
24 | path: '/', | 24 | path: '/', |
25 | component: Layout, | 25 | component: Layout, |
26 | meta: { title: '404' }, | ||
27 | hidden: true, | 26 | hidden: true, |
27 | redirect: '/404', | ||
28 | children: [ | 28 | children: [ |
29 | { | 29 | { |
30 | path: '404', | 30 | path: '404', |
... | @@ -49,22 +49,7 @@ export const constantRoutes = [ | ... | @@ -49,22 +49,7 @@ export const constantRoutes = [ |
49 | name: 'workFrameView', | 49 | name: 'workFrameView', |
50 | hidden: true, | 50 | hidden: true, |
51 | meta: { title: '发起申请' } | 51 | meta: { title: '发起申请' } |
52 | }, | ||
53 | { | ||
54 | path: '*', | ||
55 | component: Layout, | ||
56 | meta: { title: '404' }, | ||
57 | redirect: '/404', | ||
58 | hidden: true, | ||
59 | children: [ | ||
60 | { | ||
61 | path: '404', | ||
62 | component: () => import('@/views/error-page/404'), | ||
63 | name: '404', | ||
64 | meta: { title: '404' } | ||
65 | } | 52 | } |
66 | ] | ||
67 | }, | ||
68 | ] | 53 | ] |
69 | /** | 54 | /** |
70 | * asyncRoutes | 55 | * asyncRoutes | ... | ... |
-
Please register or sign in to post a comment