import adminConfig from './admin' ; import pluginsConfig from './plugins' ; import Utils from '@/lin/utils/util' ; import { IRouterItem } from '@/types/project' ; let homeRouter = [ { title : '林间有风' , type : 'view' , name : Symbol ( 'about' ) , route : '/about' , filePath : 'views/about/About' , inNav : true , icon : 'HomeOutlined' , order : 1 } , { title : '日志管理' , type : 'view' , name : Symbol ( 'log' ) , route : '/log' , filePath : 'views/log/Log' , inNav : true , icon : 'SolutionOutlined' , order : 2 , permission : [ '查询所有日志' ] } , { title : '个人中心' , type : 'view' , name : Symbol ( 'center' ) , route : '/center' , filePath : 'views/center/Center' , inNav : false , icon : 'SolutionOutlined' } , { title : '404' , type : 'view' , name : Symbol ( '404' ) , route : '/404' , filePath : 'views/error-page/ErrorPage' , inNav : false , icon : 'StopOutlined' } , adminConfig , ] ; const plugins = [ ... pluginsConfig ] ; function filterPlugin ( data ) { if ( plugins . length === 0 ) { return ; } if ( Array . isArray ( data ) ) { data . forEach ( item => { filterPlugin ( item ) ; } ) ; } else { const findResult = plugins . findIndex ( item => data === item ) ; if ( findResult >= 0 ) { plugins . splice ( findResult , 1 ) ; } if ( data . children ) { filterPlugin ( data . children ) ; } } } filterPlugin ( homeRouter ) ; homeRouter = homeRouter . concat ( plugins ) ; homeRouter = Utils . sortByOrder ( homeRouter ) ; const deepReduceName = ( target ) => { if ( Array . isArray ( target ) ) { target . forEach ( item => { if ( typeof item !== 'object' ) { return ; } deepReduceName ( item ) ; } ) ; return ; } if ( typeof target === 'object' ) { if ( typeof target . name !== 'symbol' ) { target . name = target . name || Utils . getRandomStr ( ) ; target . name = Symbol ( target . name ) ; } if ( Array . isArray ( target . children ) ) { target . children . forEach ( item => { if ( typeof item !== 'object' ) { return ; } deepReduceName ( item ) ; } ) ; } } } ; deepReduceName ( homeRouter ) ; export default homeRouter ;