@@ -2,7 +2,7 @@ import type { AppRouteModule, AppRouteRecordRaw } from '/@/router/types';
22import type { Router , RouteRecordNormalized } from 'vue-router' ;
33
44import { getParentLayout , LAYOUT } from '/@/router/constant' ;
5- import { cloneDeep } from 'lodash-es' ;
5+ import { cloneDeep , omit } from 'lodash-es' ;
66import { warn } from '/@/utils/log' ;
77import { createRouter , createWebHashHistory } from 'vue-router' ;
88
@@ -73,7 +73,7 @@ export function transformObjToRoute<T = AppRouteModule>(routeList: AppRouteModul
7373 }
7474 route . children && asyncImportRoute ( route . children ) ;
7575 } ) ;
76- return ( routeList as unknown ) as T [ ] ;
76+ return routeList as unknown as T [ ] ;
7777}
7878
7979/**
@@ -95,15 +95,15 @@ export function flatMultiLevelRoutes(routeModules: AppRouteModule[]) {
9595function promoteRouteLevel ( routeModule : AppRouteModule ) {
9696 // Use vue-router to splice menus
9797 let router : Router | null = createRouter ( {
98- routes : [ ( routeModule as unknown ) as RouteRecordNormalized ] ,
98+ routes : [ routeModule as unknown as RouteRecordNormalized ] ,
9999 history : createWebHashHistory ( ) ,
100100 } ) ;
101101
102102 const routes = router . getRoutes ( ) ;
103103 addToChildren ( routes , routeModule . children || [ ] , routeModule ) ;
104104 router = null ;
105105
106- routeModule . children = routeModule . children ?. filter ( ( item ) => ! item . children ?. length ) ;
106+ routeModule . children = routeModule . children ?. map ( ( item ) => omit ( item , ' children' ) ) ;
107107}
108108
109109// Add all sub-routes to the secondary route
@@ -120,7 +120,7 @@ function addToChildren(
120120 }
121121 routeModule . children = routeModule . children || [ ] ;
122122 if ( ! routeModule . children . find ( ( item ) => item . name === route . name ) ) {
123- routeModule . children ?. push ( ( route as unknown ) as AppRouteModule ) ;
123+ routeModule . children ?. push ( route as unknown as AppRouteModule ) ;
124124 }
125125 if ( child . children ?. length ) {
126126 addToChildren ( routes , child . children , routeModule ) ;
0 commit comments