import store from '../store/store.js'; const staticMuen = [ { path: '/msg', component: () => import(/* webpackChunkName: "messages" */ '@views/messages'), meta: { title: '消息中心' } }, { path: '/403', component: () => import(/* webpackChunkName: "404" */ '@views/403'), meta: { title: '403' } }, { path: '/404', component: () => import(/* webpackChunkName: "404" */ '@views/404'), meta: { title: '404' } }, { path: '/parkingLotAdministration/pageJump/partitionManagement', component: () => import(/* webpackChunkName: "404" */ '@views/parkingLotAdministration/pageJump/partitionManagement.vue'), meta: { title: '车库分区管理' } }, { path: '/ownerManagement/details', component: () => import(/* webpackChunkName: "404" */ '@views/ownerManagement/details.vue'), meta: { title: '住户详情' } }, { path: '/housingManagement/details', component: () => import(/* webpackChunkName: "404" */ '@views/assetManagement/housingManagement/details.vue'), meta: { title: '房屋详情' }, name: 'housingManagementDetails' }, { path: '/shopManagement/details', component: () => import(/* webpackChunkName: "404" */ '@views/assetManagement/shopManagement/details.vue'), meta: { title: '商铺详情' }, name: 'shopManagementDetails' }, { path: '/invoiceManagement/index', component: () => import(/* webpackChunkName: "404" */ '@views/payService/invoiceManagement/index.vue'), meta: { title: '发票管理' } }, { path: '/expenseReport/index', component: () => import(/* webpackChunkName: "404" */ '@views/payService/expenseReport/index.vue'), meta: { title: '费用报表' }, name: 'expenseReport' }, { path: '/shannon-transfer', component: () => import(/* webpackChunkName: "404" */ '@views/patrolManagement/components/shannon-transfer.vue'), meta: { title: '测试' }, name: 'shannon-transfer' }, { path: '*', redirect: '/404' } ]; //路由格式 // 自定义路由文件 const setListMunt = (arrList, item) => { let newOb = {}; newOb = { path: `/${item.linkPath}`, component: () => import(`@/views/${item.linkPath}.vue`), meta: { title: item.name } }; arrList.push(newOb); }; const dimension = (arrList, arr) => { arr.forEach((item, index) => { //默认去掉第一个添加路由 // if (item.linkPath !== 'workbench/index') { // if (!!item.children) { // dimension(arrList, item.children); // } else { // setListMunt(arrList, item); // } // } if (!!item.children) { dimension(arrList, item.children); } else { setListMunt(arrList, item); } }); }; //添加路由 const AddRt = (router, dynamicMuenList) => { let NEWdynamicMuenList = [...dynamicMuenList, ...staticMuen]; if (NEWdynamicMuenList.length !== 0) { NEWdynamicMuenList.forEach((item) => { router.options.routes[0].children.push(item); }); router.addRoutes(router.options.routes); } }; export const funcRouter = (arr, data, router) => { dimension(arr, data); store.commit('setMenuList', data); AddRt(router, arr); };