fix: 修复刷新浏览器后页面跳转到404问题

This commit is contained in:
“huailei000”
2022-03-14 11:47:27 +08:00
committed by 老广
parent fe33798972
commit 2e3dc366e8
2 changed files with 8 additions and 7 deletions

View File

@@ -69,11 +69,6 @@ export const constantRoutes = [
component: () => import('@/views/404'),
hidden: true
},
{
path: '*',
redirect: '/404',
hidden: true
},
...commonRoutes
]

View File

@@ -81,10 +81,16 @@ export async function generatePageRoutes({ to, from, next }) {
try {
// try get user profile
// generate accessible routes map based on roles
const accessRoutes = await store.dispatch('permission/generateRoutes', { to, from })
let accessRoutes = await store.dispatch('permission/generateRoutes', { to, from })
// Incorrect route, jump to 404
accessRoutes = [...accessRoutes, {
path: '*',
redirect: '/404',
hidden: true
}]
// dynamically add accessible routes
Vue.$log.debug('All routes: ', accessRoutes)
Vue.$log.debug('All routes:', accessRoutes)
router.addRoutes(accessRoutes)
await store.dispatch('permission/generateViewRoutes', { to, from })