import Vue from 'vue' import Router from 'vue-router' import { ScheduleType, Access } 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' , if it is not a wrapping layer(Layout or Solo), it must be set!!! * include: ['admin'], control the page roles (you can set multiple roles) * access: 'manage-profile', control the page access * meta : { * title: 'title', the name show in sidebar and breadcrumb (recommend set) * icon: 'svg-name'/'el-icon-x', the icon show in the sidebar * cache: 'router-name' if set, the router will be cached (only in Solo) * } */ /** * constantRoutes * a base page that does not have permission requirements * all roles can be accessed */ export const constantRoutes = [ { hidden: true, path: '/error', component: () => import('@/views/platform/error-page/index') } ] /** * 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: 'home' } }, { hidden: true, name: 'profile', path: 'profile', component: () => import('@/views/basic/profile/index'), access: Access.MANAGE_PROFILE, meta: { title: '个人设置' } } ] }, { path: '/cm', component: Layout, meta: { title: '智能信发', icon: 'cm' }, children: [ { name: 'media', path: 'media', component: () => import('@/views/basic/media/index'), access: Access.MANAGE_ASSETS, meta: { title: '媒资管理' } }, { name: 'program-list', path: 'program', component: () => import('@/views/bigscreen/index'), access: Access.MANAGE_CALENDAR, meta: { title: '节目编辑' } }, { path: 'recur', component: Solo, access: Access.MANAGE_CALENDAR, meta: { title: '轮播编排' }, children: [ { name: 'recur-list', path: '', component: () => import('@/views/schedule/index'), meta: { cache: 'ScheduleList' }, props: { type: ScheduleType.RECUR, redirect: 'recur-design' } }, { hidden: true, name: 'recur-design', path: ':id', component: () => import('@/views/schedule/designer/index'), meta: { title: '编辑', cache: 'ScheduleList' }, props: { redirect: 'recur-list' } } ] }, { path: 'schedule', component: Solo, access: Access.MANAGE_CALENDAR, meta: { title: '排期编排' }, children: [ { name: 'schedule-list', path: '', component: () => import('@/views/schedule/index'), meta: { cache: 'ScheduleList' }, props: { type: ScheduleType.COMPLEX, redirect: 'schedule-design' } }, { hidden: true, name: 'schedule-design', path: ':id', component: () => import('@/views/schedule/designer/index'), meta: { title: '编辑', cache: 'ScheduleList' }, props: { redirect: 'schedule-list' } } ] }, { name: 'schedule-deploy', path: 'deploy', component: () => import('@/views/schedule/deploy/index'), access: Access.PUBLISH_CALENDAR, meta: { title: '排期发布' } }, { name: 'review', path: 'review', component: () => import('@/views/review/index'), access: Access.REVIEW, meta: { title: '审核管理' } }, { name: 'schedule-deploy-history', path: 'history', component: () => import('@/views/schedule/history/index'), access: [Access.PUBLISH_CALENDAR, Access.REVIEW], meta: { title: '发布历史' } } ] }, { path: '/dm', component: Layout, meta: { title: '大屏设备', icon: 'dm' }, children: [ { name: 'schedule-timeline', path: 'timeline', component: () => import('@/views/schedule/timeline/index'), meta: { title: '排期预览' } }, { path: 'device', component: Solo, meta: { title: '设备管理' }, children: [ { name: 'device-list', path: '', component: () => import('@/views/device/index'), access: [Access.MANAGE_DEVICES, Access.MANAGE_DEVICE], meta: { cache: 'DeviceList' } }, { hidden: true, name: 'device-detail', path: ':id', component: () => import('@/views/device/detail/index'), meta: { title: '设备详情', cache: 'DeviceList' } } ] }, { name: 'group', path: 'group', component: () => import('@/views/device/group/index'), access: Access.MANAGE_GROUPS, meta: { title: '分组管理' } }, { dev: true, name: 'remote', path: 'remote', component: () => import('@/views/device/remote/index'), meta: { title: '设备操控' } }, { name: 'back', path: 'back', component: () => import('@/views/device/back/index'), meta: { title: '视频回传' } } ] }, { path: '/em', component: Layout, meta: { title: '设备录入', icon: 'em' }, children: [ { path: 'transmitter', name: 'transmitter', access: Access.MANAGE_DEVICES, component: () => import('@/views/external/transmitter/index'), meta: { title: '发送控制设备' } }, { path: 'camera', name: 'camera', access: Access.VIEW_CAMERAS, component: () => import('@/views/external/camera/index'), meta: { title: '摄像头' } } ] }, { path: '/pm', component: Layout, meta: { title: '平台管理', icon: 'pm' }, children: [ { name: 'category', path: 'category', component: () => import('@/views/device/category/index'), access: Access.MANAGE_PRODUCTS, meta: { title: '产品分类' } }, { name: 'product', path: 'product', component: () => import('@/views/device/product/index'), access: Access.MANAGE_PRODUCTS, meta: { title: '产品管理' } }, { name: 'transfer-deploy', path: 'deploy', component: () => import('@/views/platform/transfer/deploy/index'), access: Access.SUPER_ADMIN, meta: { title: '旧排期发布' } }, { name: 'transfer', path: 'transfer', component: () => import('@/views/platform/transfer/index'), access: Access.SUPER_ADMIN, meta: { title: '数据迁移' } } ] }, { path: '/l', component: Layout, access: Access.VIEW_LOGS, meta: { icon: 'logger' }, children: [ { path: '', name: 'logger', component: () => import('@/views/basic/logger/index'), meta: { title: '操作日志' } } ] }, { path: '/d', component: Layout, access: Access.SUPER_ADMIN, meta: { icon: 'bug' }, children: [ { path: '', name: 'debug', component: () => import('@/views/platform/debug/index'), meta: { title: '调试' } } ] }, { path: '/u', component: Layout, access: Access.MANAGE_UPGRADE, meta: { title: '升级管理', icon: 'upgrade' }, children: [ { path: 'apk', name: 'upgrade-apk', component: () => import('@/views/basic/upgrade/index'), meta: { title: '版本管理' } }, { path: 'deploy', name: 'upgrade-deploy', component: () => import('@/views/basic/upgrade/deploy/index'), meta: { title: '发布升级' } } ] }, // { // hidden: true, // name: 'design', // path: '/design/:id', // component: () => import('@/views/bigscreen/designer/index'), // access: Access.MANAGE_CALENDAR // }, // { // hidden: true, // name: 'view', // path: '/view/:id', // component: () => import('@/views/bigscreen/viewer/index') // }, { hidden: true, name: 'program', path: '/cm/program/:id', component: () => import('@/views/bigscreen/ast/index'), props: true }, // 404 page must be placed at the end !!! { hidden: true, path: '*', redirect: '/' } ] 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