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) /** * sub-menu only appear when route children.length >= 1 * 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) * name:'router-name' the name is used by (must set!!!) * meta : { * include: ['admin'], control the page roles (you can set multiple roles) * exclude: ['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 * 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: [ { name: 'dashboard', path: 'dashboard', component: () => import('@/views/dashboard/index'), meta: { title: '首页', icon: 'el-icon-s-home' } }, { name: 'profile', path: 'profile', component: () => import('@/views/profile/index'), meta: { title: '个人设置' }, hidden: true } ] }, { path: '/cm', component: Layout, meta: { title: '智能信发', icon: 'el-icon-s-promotion' }, children: [ { name: 'media', path: 'media', component: () => import('@/views/media/index'), exclude: [Role.VISITOR], 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'), exclude: [Role.VISITOR], meta: { title: '排期编辑', activeMenu: '/cm/schedule', cache: 'ScheduleList' }, hidden: true } ] }, { name: 'schedule-deploy', path: 'deploy', component: () => import('@/views/schedule/deploy/index'), exclude: [Role.VISITOR], meta: { title: '排期发布' } }, { name: 'review', path: 'review', component: () => import('@/views/review/index'), include: [Role.SUPERVISOR], meta: { title: '审核管理' } }, { 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' }, children: [ { name: 'schedule-timeline', path: 'timeline', component: () => import('@/views/schedule/timeline/index'), meta: { title: '排期预览' } }, { dev: true, name: 'remote', path: 'remote', component: () => import('@/views/device/remote/index'), meta: { title: '设备操控' } } ] }, { path: '/m', component: Layout, meta: { title: '大屏管理', icon: 'el-icon-monitor' }, children: [ { name: 'category', path: 'category', component: () => import('@/views/device/category/index'), include: [Role.ADMIN], meta: { title: '产品分类' } }, { name: 'product', path: 'product', component: () => import('@/views/device/product/index'), include: [Role.ADMIN], meta: { title: '产品管理' } }, { 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'), exclude: [Role.VISITOR], meta: { title: '分组管理' } } ] }, { path: '/l', component: Layout, exclude: [Role.STAFF], meta: { icon: 'el-icon-edit-outline' }, children: [ { path: '', name: 'logger', component: () => import('@/views/logger/index'), meta: { title: '操作日志' } } ] }, { path: '/d', component: Layout, include: [Role.ADMIN], meta: { icon: 'bug' }, children: [ { path: '', name: 'debug', component: () => import('@/views/debug/index'), meta: { title: '调试' } } ] }, { path: '/u', component: Layout, include: [Role.ADMIN], meta: { title: '升级管理', icon: 'el-icon-upload' }, 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: '发布升级' } } ] }, { name: 'design', path: '/design/:id', component: () => import('@/views/bigscreen/designer/index'), exclude: [Role.VISITOR], hidden: true }, { name: 'view', path: '/view/:id', component: () => import('@/views/bigscreen/viewer/index'), hidden: true }, // 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