Skip to content

Commit

Permalink
fix(projects): 修复动态路由模式下路由不排序的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Azir-11 committed Jan 9, 2023
1 parent 25daa23 commit 58b27c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/store/modules/route/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
transformAuthRouteToMenu,
transformAuthRouteToSearchMenus,
transformRouteNameToRoutePath,
transformRoutePathToRouteName
transformRoutePathToRouteName,
sortRoutes
} from '@/utils';
import { useAuthStore } from '../auth';
import { useTabStore } from '../tab';
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/utils/router/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down

0 comments on commit 58b27c9

Please sign in to comment.