b35b85f1 by 任超

style:动态路由

1 parent 96db9287
......@@ -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()
})
......
......@@ -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
......