import Vue from 'vue' import Router from 'vue-router' import { Role } from '@/constant' import Layout from '@/layout' import Solo from '@/layout/Solo' Vue.use(Router) /** * 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 * * dev: true if set true, item will not show in production * 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 * 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: '/error', component: () => import('@/views/error-page/index'), hidden: true } ] /** * asyncRoutes * the routes that need to be dynamically loaded based on user roles */ export const asyncRoutes = [ { path: '/', redirect: '/dashboard', component: Layout, children: [ { path: 'dashboard', name: 'home', component: () => import('@/views/dashboard/index'), meta: { title: '首页', icon: 'el-icon-s-home' } } ] }, { hidden: true, path: '/abnormal', redirect: '/dashboard', component: Layout, meta: { title: '首页' }, children: [ { path: ':type', name: 'abnormal', component: () => import('@/views/abnormal/index'), meta: { title: '异常', activeMenu: '/dashboard' } } ] }, { name: 'design', path: '/design/:id', component: () => import('@/views/bigscreen/designer/index'), hidden: true }, { name: 'view', path: '/view/:id', component: () => import('@/views/bigscreen/viewer/index'), hidden: true }, { path: '/cm', component: Layout, meta: { title: '智能信发', icon: 'el-icon-s-promotion', placeholder: true }, children: [ { name: 'media', path: 'media', component: () => import('@/views/media/index'), meta: { title: '媒资管理' } }, { name: 'program', path: 'program', component: () => import('@/views/bigscreen/index'), meta: { title: '节目编排' } }, { path: 'schedule', component: Solo, meta: { title: '节目排期' }, children: [ { name: 'schedule-list', path: '', component: () => import('@/views/schedule/index'), meta: { cache: 'ScheduleList' }, hidden: true }, { name: 'schedule-design', path: ':id', component: () => import('@/views/schedule/designer/index'), meta: { title: '排期编辑', activeMenu: '/cm/schedule', cache: 'ScheduleList' }, hidden: true } ] }, { name: 'schedule-deploy', path: 'deploy', component: () => import('@/views/schedule/deploy/index'), meta: { title: '排期发布' } }, { name: 'review', path: 'review', component: () => import('@/views/review/index'), meta: { title: '审核管理', roles: [Role.SUPERVISOR] } }, { name: 'schedule-deploy-history', path: 'history', component: () => import('@/views/schedule/history/index'), meta: { title: '发布历史' } } ] }, { dev: !__PREVIEW__, path: '/dm', component: Layout, meta: { title: '大屏设备', icon: 'el-icon-monitor', placeholder: true }, children: [ { name: 'schedule-timeline', path: 'timeline', component: () => import('@/views/schedule/timeline/index'), meta: { title: '排期预览' } }, { dev: true, name: 'remote', path: 'remote', component: () => import('@/views/remote/index'), meta: { title: '设备操控' } } ] }, { path: '/m', component: Layout, meta: { title: '大屏管理', icon: 'el-icon-monitor', placeholder: true }, children: [ { name: 'category', path: 'category', component: () => import('@/views/device/category/index'), meta: { title: '产品分类', roles: [Role.ADMIN] } }, { name: 'product', path: 'product', component: () => import('@/views/device/product/index'), meta: { title: '产品管理', roles: [Role.ADMIN] } }, { path: 'device', component: Solo, meta: { title: '设备管理' }, children: [ { name: 'device-list', path: '', component: () => import('@/views/device/index'), meta: { cache: 'DeviceList' }, hidden: true }, { name: 'device-detail', path: ':id', component: () => import('@/views/device/detail/index'), meta: { title: '设备详情', activeMenu: '/m/device', cache: 'DeviceList' }, hidden: true } ] }, { name: 'group', path: 'group', component: () => import('@/views/device/group/index'), meta: { title: '分组管理' } } ] }, { path: '/l', component: Layout, meta: { roles: [Role.ADMIN] }, children: [ { path: '', name: 'logger', component: () => import('@/views/logger/index'), meta: { title: '操作日志', icon: 'el-icon-edit-outline' } } ] }, { path: '/d', component: Layout, meta: { roles: [Role.ADMIN] }, children: [ { path: '', name: 'debug', component: () => import('@/views/debug/index'), meta: { title: '调试', icon: 'bug' } } ] }, { path: '/u', component: Layout, meta: { title: '升级管理', icon: 'el-icon-upload', placeholder: true, roles: [Role.ADMIN] }, children: [ { path: 'apk', name: 'upgrade-apk', component: () => import('@/views/upgrade/index'), meta: { title: '版本管理' } }, { path: 'deploy', name: 'upgrade-deploy', component: () => import('@/views/upgrade/deploy/index'), meta: { title: '发布升级' } } ] }, // 404 page must be placed at the end !!! { path: '*', redirect: '/', 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 } export default router