123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- 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/error/403.vue'),
- meta: { title: '403' }
- },
- {
- path: '/404',
- component: () => import(/* webpackChunkName: "404" */ '@views/error/404.vue'),
- meta: { title: '404' }
- },
- {
- path: '/instrumentViewDetail',
- component: () => import(/* webpackChunkName: "404" */ '@views/instrumentManagement/setPage/viewDetail.vue'),
- meta: { title: '设备详情' }
- },
- {
- 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.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);
- };
|