| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- 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 <keep-alive> (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
|