|
|
@@ -28,7 +28,7 @@ router.beforeEach(async (to, from, next) => {
|
|
|
// 用户已授权的情况
|
|
|
if (isAuthorized) {
|
|
|
if (!hasRouteFlag) {
|
|
|
- const { accessRoutes, accessFlatRoutes } = await initializeRoutes();
|
|
|
+ const { accessRoutes, accessFlatRoutes, firstAccessibleRoute } = await initializeRoutes();
|
|
|
accessRoutes.forEach((route) => {
|
|
|
if (route.path && route.component) {
|
|
|
router.addRoute(route); // 动态添加可访问路由表
|
|
|
@@ -36,7 +36,7 @@ router.beforeEach(async (to, from, next) => {
|
|
|
});
|
|
|
flatRoutes = accessFlatRoutes;
|
|
|
hasRouteFlag = true;
|
|
|
- next({ ...to, replace: true });
|
|
|
+ next({ path: firstAccessibleRoute.path, replace: true });
|
|
|
} else if (isLoginPage) {
|
|
|
next('/');
|
|
|
} else if (!flatRoutes.some((route) => route.path == to.path) && !isInWhiteList) {
|