import Vue from 'vue' import Router from 'vue-router' Vue.use(Router) /* Layout */ import Layout from '@/layout' import FullScreenLayout from '@/layout/components/FullScreen' /** * Note: sub-menu only appear when route children.length >= 1 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html * * hidden: true if set true, item will not show in the sidebar(default is false) * alwaysShow: true if set true, will always show the root menu * if not set alwaysShow, when item has more than one children route, * it will becomes nested mode, otherwise not show the root menu * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb * name:'router-name' the name is used by (must set!!!) * meta : { roles: ['admin','editor'] control the page roles (you can set multiple roles) title: 'title' the name show in sidebar and breadcrumb (recommend set) icon: 'svg-name'/'el-icon-x' the icon show in the sidebar breadcrumb: false if set false, the item will hidden in breadcrumb(default is true) activeMenu: '/example/list' if set path, the sidebar will highlight the path you set } */ /** * constantRoutes * a base page that does not have permission requirements * all roles can be accessed */ export const constantRoutes = [ { path: '/redirect', component: Layout, hidden: true, children: [ { path: '/redirect/:path(.*)', component: () => import('@/views/redirect/index') } ] }, { path: '/login', component: () => import('@/views/login/index'), hidden: true }, { path: '/', component: Layout, redirect: '/index', children: [{ path: 'index', name: 'index', component: () => import('@/views/dashboard/index'), meta: { title: '首页', icon: 'icon-shouye' } }] }, // { // path: 'external-link', // component: Layout, // children: [ // { // path: 'https://baidu.com', // meta: { title: '外链', icon: 'link' } // } // ] // }, // 404 page must be placed at the end !!! { path: '/404', component: () => import('@/views/404'), hidden: true }, { path: '/dashboard-screen', component: FullScreenLayout, // redirect: '/catenary/fault', name: 'dashboard-screen', meta: { title: '', icon: 'icon-jiechuwang', pages: ['pc:catenary'] }, children: [ { path: '', component: () => import('@/views/dashboard-screen/index'), // Parent router-view name: 'fault', meta: { title: '大屏', pages: ['pc:catenary:jlgz'] } } ] }, ] export const asyncRoutes = [ { path: '/catenary', component: Layout, redirect: '/catenary/fault', name: 'catenary', meta: { title: '接触网管理', icon: 'icon-jiechuwang', pages: ['pc:catenary'] }, children: [ { path: 'fault', component: () => import('@/views/catenary/fault/index'), // Parent router-view name: 'fault', meta: { title: '故障数据管理', pages: ['pc:catenary:jlgz'] } }, { path: 'checklist', component: () => import('@/views/catenary/checklist/index'), name: 'checklist', meta: { title: '检查表记录管理', pages: ['pc:catenary:jcab'] } }, { path: 'record', component: () => import('@/views/catenary/record/index'), name: 'record', meta: { title: '检测记录管理', pages: ['pc:catenary:jceb'] } }, { path: 'stand', component: () => import('@/views/catenary/stand/index'), name: 'stand', meta: { title: '九防台账数据管理', pages: ['pc:prevent'] } } ] }, { path: '/security', component: Layout, redirect: '/security/seStand', name: 'security', meta: { title: '安全工具管理', icon: 'icon-anquangongju', pages: ['pc:safetool'] }, children: [ { path: 'seStand', component: () => import('@/views/security/stand/index'), name: 'seStand', meta: { title: '安全工具台账', pages: ['pc:safety:tool'] } }, { path: 'checklist', component: () => import('@/views/security/checkList/index'), name: 'checklist', meta: { title: '安全工具检验记录', pages: ['pc:safety:experiment'] } } ] }, { path: '/basics', component: Layout, redirect: '/basics/pillar', name: 'basics', meta: { title: '基础数据管理', pages: ['pc:baseinfo'], icon: 'icon-jichushuju' }, children: [ { path: 'line', component: () => import('@/views/basics/line/index'), // Parent router-view name: 'line', meta: { title: '线路数据', pages: ['pc:baseinfo:line'] } }, { path: 'section', component: () => import('@/views/basics/section/index'), // Parent router-view name: 'section', meta: { title: '区间站场数据', pages: ['pc:baseinfo:station'] } }, { path: 'pillar', component: () => import('@/views/basics/pillar/index'), // Parent router-view name: 'pillar', meta: { title: '支柱数据', pages: ['pc:baseinfo:pillar'] } }, { path: 'suoting', component: () => import('@/views/basics/suoting/index'), // Parent router-view name: 'suoting', meta: { title: '所亭数据', pages: ['pc:baseinfo:substation'] } }, { path: 'tunnel', component: () => import('@/views/basics/tunnel/index'), // Parent router-view name: 'tunnel', meta: { title: '隧道数据', pages: ['pc:baseinfo:sdtz'] } }, { path: 'add', component: () => import('@/views/basics/add/index'), // Parent router-view name: 'add', meta: { title: '附加悬挂锚段数据', pages: ['pc:baseinfo:fjxgmd'] } }, { path: 'check', component: () => import('@/views/basics/check/index'), // Parent router-view name: 'check', meta: { title: '检查表数据', pages: ['pc:baseinfo:jcab'] } } ] }, { path: '/sys', component: Layout, redirect: '/sys/dept', name: 'sys', meta: { title: '系统管理', pages: ['pc:system'], icon: 'icon-xitong' }, children: [ { path: 'dept', component: () => import('@/views/sys/dept/index'), // Parent router-view name: 'dept', meta: { title: '部门数据', pages: ['pc:system:dept:list'] } }, { path: 'role', component: () => import('@/views/sys/role/index'), // Parent router-view name: 'role', meta: { title: '职务管理', pages: ['pc:system:role:list'] } }, { path: 'user', component: () => import('@/views/sys/user/index'), // Parent router-view name: 'user', meta: { title: '职工管理', pages: ['pc:system:user:list'] } }, { path: 'dict', component: () => import('@/views/sys/dict/index'), // Parent router-view name: 'dict', meta: { title: '字典管理', pages: ['pc:system:dict:list'] } }, { path: 'menu', component: () => import('@/views/sys/menu/index'), // Parent router-view name: 'menu', meta: { title: '菜单管理', pages: ['pc:system:menu:list'] } }, { path: 'app', component: () => import('@/views/sys/app/index'), // Parent router-view name: 'app', meta: { title: 'APP管理', pages: ['pc:system:app:list'] } }, { path: 'log', component: () => import('@/views/sys/log/index'), // Parent router-view name: 'log', meta: { title: '日志管理', pages: ['pc:system:operlog:list'] } } ] }, { path: '*', redirect: '/404', hidden: true } ] const createRouter = () => new Router({ mode: 'history', // require service support scrollBehavior: () => ({ y: 0 }), routes: constantRoutes }) const router = createRouter() // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465 export function resetRouter() { const newRouter = createRouter() router.matcher = newRouter.matcher // reset router } export default router