fix(projects): 修复动态路由模式下路由不排序的问题

This commit is contained in:
“青菜白玉汤” 2023-01-09 10:39:42 +08:00
parent 25daa23606
commit 58b27c9693
2 changed files with 4 additions and 3 deletions

View File

@ -11,7 +11,8 @@ import {
transformAuthRouteToMenu,
transformAuthRouteToSearchMenus,
transformRouteNameToRoutePath,
transformRoutePathToRouteName
transformRoutePathToRouteName,
sortRoutes
} from '@/utils';
import { useAuthStore } from '../auth';
import { useTabStore } from '../tab';
@ -119,7 +120,7 @@ export const useRouteStore = defineStore('route-store', {
if (!error) {
this.routeHomeName = data.home;
this.handleUpdateRootRedirect(data.home);
this.handleAuthRoute(data.routes);
this.handleAuthRoute(sortRoutes(data.routes));
initHomeTab(data.home, router);

View File

@ -2,7 +2,7 @@
*
* @param routes -
*/
function sortRoutes(routes: AuthRoute.Route[]) {
export function sortRoutes(routes: AuthRoute.Route[]) {
return routes.sort((next, pre) => Number(next.meta?.order) - Number(pre.meta?.order));
}