fix: 动态刷新之后404

This commit is contained in:
JaguarJack
2023-02-23 09:38:48 +08:00
parent c73c68dee5
commit 8fd87ad46b
2 changed files with 8 additions and 8 deletions

View File

@@ -41,10 +41,14 @@ const guard = (router: Router) => {
asyncRoutes.forEach((route: Menu) => {
router.addRoute(route as unknown as RouteRecordRaw)
})
// 在动态路由之后挂载匹配 404 路由
router.addRoute({
path: '/:pathMatch(.*)*',
redirect: '/404',
})
}
next({ ...to, replace: true })
next({ ...to, replace: true });
} catch (e) {
console.log(e)
removeAuthToken()
next({ path: `${WhiteListPage.LOGIN_PATH}?redirect=/${to.path}` })
}
@@ -54,6 +58,7 @@ const guard = (router: Router) => {
} else {
// 如果不在白名单
if (whiteList.indexOf(to.path) !== -1) {
console.log(123)
next()
} else {
next({ path: WhiteListPage.LOGIN_PATH })