import routes from './routes' ; import { menuItem , routeItem } from '@/store/types' ; const routesArr = routes ( ) ; const parseRoutes = ( routesArr , authMap ) => { const menuArr = [ ] ; routesArr . forEach ( ( item ) => { if ( item . public ) return ; const menuItem = { id : item . id , icon : item . icon } ; if ( item . children ) { menuItem . children = parseRoutes ( item . children , authMap ) ; } else { if ( authMap . includes ( item . id ) ) menuItem . path = item . path ; } if ( menuItem . path || ( menuItem . children && menuItem . children . length > 0 ) ) menuArr [ menuArr . length ] = menuItem ; } ) ; return menuArr ; } ; export default ( authMap ) => parseRoutes ( routesArr [ 1 ] . children as Array < routeItem > , authMap ) ;