import Vue from 'vue' import Router from 'vue-router' Vue.use(Router) /* Layout */ import Layout from '@/layout' /** * 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 <keep-alive> (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: '/login', component: () => import('@/views/login/index'), hidden: true }, { path: '/404', component: () => import('@/views/404'), hidden: true }, { path: '/', component: Layout, redirect: '/dashboard', children: [{ path: 'dashboard', name: 'Dashboard', component: () => import('@/views/dashboard/index'), meta: { title: '首页', icon: 'homePage' } }] }, { path: '/alarm', component: Layout, redirect: '/dashboard', name: 'alarm', meta: { title: '告警管理', icon: 'alarm' }, children: [ { path: 'cableTime', name: 'cableTime', component: () => import('@/views/alarm/cableTime/index'), meta: { title: '漏缆监测告警' } }, { path: 'device', name: 'device', component: () => import('@/views/alarm/device/index'), meta: { title: '设备连接告警' } } ] }, { path: '/setting', component: Layout, redirect: '/setting/add', name: 'Setting', meta: { title: '配置管理', icon: 'setting' }, children: [ { path: 'add', name: 'settingAdd', component: () => import('@/views/setting/add/index'), meta: { title: '手动添加配置' } }, { path: 'statistics', name: 'settingAtatistics', component: () => import('@/views/setting/statistics/index'), meta: { title: '配置信息统计' }, children: [ ] }, { path: "/detail/", name: "detail", beforeEnter: (to, from, next) => { if (to.query.type==1) { to.meta.title = '铁路线详情' } else if (to.query.type==2) { to.meta.title = '站点详情' } else if (to.query.type==3) { to.meta.title = 'FSU详情' } else if (to.query.type==4) { to.meta.title = '监测设备详情' } else if (to.query.type==5) { to.meta.title = '漏缆详情' } else if (to.query.type==6) { to.meta.title = '天馈线详情' } else{ to.meta.title = '详情' } next() }, component: () => import('@/views/setting/statistics/detail'), hidden: true, }, ] }, { path: '/monitor', component: Layout, redirect: '/dashboard', name: '监测实时状态', meta: { title: '监测实时状态', icon: 'system' }, children: [ { path: 'leakageCable', name: '漏缆实时状态', component: () => import('@/views/monitor/leakageCable'), meta: { title: '漏缆实时状态' } }, { path: 'equipment', name: '设备实时状态', component: () => import('@/views/monitor/equipment'), meta: { title: '设备实时状态' } } ] }, { path: '/maintain', component: Layout, redirect: '/maintain/oneself', name: 'Maintain', meta: { title: '维护管理', icon: 'maintain' }, children: [ { path: 'oneself', name: 'MaintainOneself', component: () => import('@/views/maintain/oneself/index'), meta: { title: '设备本身维护' } }, { path: 'parameter', name: 'MaintainParameter', component: () => import('@/views/maintain/parameter/index'), meta: { title: '设备告警参数设置' } } ] }, { path: '/history', component: Layout, redirect: '/history/leakyCableStatus', name: 'History', meta: { title: '历史数据', icon: 'history' }, children: [ { path: 'leakyCableStatus', name: 'leakyCableStatus', component: () => import('@/views/history/leakyCableStatus/index.vue'), meta: { title: '漏缆监测历史状态' } }, { path: 'leakyCableRepair', name: 'leakyCableRepair', component: () => import('@/views/history/leakyCableRepair/index.vue'), meta: { title: '漏缆监测维护历史' } }, { path: 'deviceLinkStatus', name: 'deviceLinkStatus', component: () => import('@/views/history/deviceLinkStatus/index.vue'), meta: { title: '设备连接历史状态' } }, { path: 'deviceLinkRepair', name: 'deviceLinkRepair', component: () => import('@/views/history/deviceLinkRepair/index.vue'), meta: { title: '设备连接维修历史' } } ] }, { path: '/user', component: Layout, redirect: '/dashboard', name: 'User', meta: { title: '用户管理', icon: 'user' }, children: [{ path: 'updateUser', name: 'UpdateUser', component: () => import('@/views/user/updateUser'), meta: { title: '个人信息管理' } }, { path: 'userList', name: 'UserList', component: () => import('@/views/user/userList'), meta: { title: '用户信息列表' } }, { path: 'userLog', name: 'UserLog', component: () => import('@/views/user/userLog'), meta: { title: '用户操作日志' } }, ] }, // 404 page must be placed at the end !!! { 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 } router.beforeResolve((to, from, next) => { window.document.title = to.meta.title next() }) export default router