Skip to content

Commit ac3c2ff

Browse files
committed
[feat]add root router sort
1 parent 3858599 commit ac3c2ff

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/router/index.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,27 @@ const defaultRouterList: Array<RouteRecordRaw> = [
2121
redirect: '/dashboard/base',
2222
},
2323
];
24+
25+
// 根router排序
26+
const rootRouterSort = ['/dashboard', '/system', '/oss', '/result', '/user', '/loginRedirect', '/login', '/'];
27+
2428
// 存放固定路由
2529
export const homepageRouterList: Array<RouteRecordRaw> = mapModuleRouterList(homepageModules);
2630
export const fixedRouterList: Array<RouteRecordRaw> = mapModuleRouterList(fixedModules);
2731

28-
export const allRoutes = [...homepageRouterList, ...fixedRouterList, ...defaultRouterList];
32+
export const beforeSortRoutes = [...homepageRouterList, ...fixedRouterList, ...defaultRouterList];
33+
34+
const afterSortRoutes = [];
35+
for (const v1 of rootRouterSort) {
36+
for (const v2 of beforeSortRoutes) {
37+
if (v2.path === v1) {
38+
afterSortRoutes.push(v2);
39+
}
40+
}
41+
}
42+
export const allRoutes = afterSortRoutes;
2943

44+
console.log(allRoutes);
3045
// 固定路由模块转换为路由
3146
export function mapModuleRouterList(modules: Record<string, unknown>): Array<RouteRecordRaw> {
3247
const routerList: Array<RouteRecordRaw> = [];

0 commit comments

Comments
 (0)