feat(projects): 动态路由根路由重定向只需取决于后端返回的路由首页

ISSUES CLOSED: \
This commit is contained in:
Soybean
2022-06-06 22:44:53 +08:00
parent ae99e57c52
commit 434ab1c560
5 changed files with 36 additions and 10 deletions

View File

@ -31,6 +31,14 @@ export async function createDynamicRouteGuard(
if (to.name === routeName('not-found-page')) {
// 动态路由没有加载导致被not-found-page路由捕获等待权限路由加载好了回到之前的路由
// 若路由是从根路由重定向过来的,重新回到根路由
const ROOT_ROUTE_NAME: AuthRoute.RouteKey = 'root';
if (to.redirectedFrom?.name === ROOT_ROUTE_NAME) {
next({ path: '/', replace: true, query: to.query });
return false;
}
next({ path: to.fullPath, replace: true, query: to.query });
return false;
}

View File

@ -1,15 +1,18 @@
import { getLoginModuleRegExp } from '@/utils';
/** 根路由: / */
export const ROOT_ROUTE: AuthRoute.Route = {
name: 'root',
path: '/',
redirect: import.meta.env.VITE_ROUTE_HOME_PATH,
meta: {
title: 'Root'
}
};
/** 固定的路由 */
export const constantRoutes: AuthRoute.Route[] = [
{
name: 'root',
path: '/',
redirect: import.meta.env.VITE_ROUTE_HOME_PATH,
meta: {
title: 'Root'
}
},
ROOT_ROUTE,
{
name: 'login',
path: '/login',