index.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. import { Role } from '@/constant'
  4. import Layout from '@/layout'
  5. import Solo from '@/layout/Solo'
  6. Vue.use(Router)
  7. /**
  8. * sub-menu only appear when route children.length >= 1
  9. * dev: true if set true, item will not show in production
  10. * hidden: true if set true, item will not show in the sidebar(default is false)
  11. * name:'router-name' the name is used by <keep-alive> (must set!!!)
  12. * meta : {
  13. * include: ['admin'], control the page roles (you can set multiple roles)
  14. * exclude: ['editor'], control the page roles (you can set multiple roles)
  15. * title: 'title', the name show in sidebar and breadcrumb (recommend set)
  16. * icon: 'svg-name'/'el-icon-x', the icon show in the sidebar
  17. * activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
  18. * }
  19. */
  20. /**
  21. * constantRoutes
  22. * a base page that does not have permission requirements
  23. * all roles can be accessed
  24. */
  25. export const constantRoutes = [
  26. {
  27. path: '/error',
  28. component: () => import('@/views/error-page/index'),
  29. hidden: true
  30. }
  31. ]
  32. /**
  33. * asyncRoutes
  34. * the routes that need to be dynamically loaded based on user roles
  35. */
  36. export const asyncRoutes = [
  37. {
  38. path: '/',
  39. redirect: '/dashboard',
  40. component: Layout,
  41. children: [
  42. {
  43. name: 'dashboard',
  44. path: 'dashboard',
  45. component: () => import('@/views/dashboard/index'),
  46. meta: { title: '首页', icon: 'el-icon-s-home' }
  47. },
  48. {
  49. name: 'profile',
  50. path: 'profile',
  51. component: () => import('@/views/profile/index'),
  52. meta: { title: '个人设置' },
  53. hidden: true
  54. }
  55. ]
  56. },
  57. {
  58. path: '/cm',
  59. component: Layout,
  60. meta: { title: '智能信发', icon: 'el-icon-s-promotion' },
  61. children: [
  62. {
  63. name: 'media',
  64. path: 'media',
  65. component: () => import('@/views/media/index'),
  66. exclude: [Role.VISITOR],
  67. meta: { title: '媒资管理' }
  68. },
  69. {
  70. name: 'program',
  71. path: 'program',
  72. component: () => import('@/views/bigscreen/index'),
  73. meta: { title: '节目编排' }
  74. },
  75. {
  76. path: 'schedule',
  77. component: Solo,
  78. meta: { title: '节目排期' },
  79. children: [
  80. {
  81. name: 'schedule-list',
  82. path: '',
  83. component: () => import('@/views/schedule/index'),
  84. meta: { cache: 'ScheduleList' },
  85. hidden: true
  86. },
  87. {
  88. name: 'schedule-design',
  89. path: ':id',
  90. component: () => import('@/views/schedule/designer/index'),
  91. exclude: [Role.VISITOR],
  92. meta: { title: '排期编辑', activeMenu: '/cm/schedule', cache: 'ScheduleList' },
  93. hidden: true
  94. }
  95. ]
  96. },
  97. {
  98. name: 'schedule-deploy',
  99. path: 'deploy',
  100. component: () => import('@/views/schedule/deploy/index'),
  101. exclude: [Role.VISITOR],
  102. meta: { title: '排期发布' }
  103. },
  104. {
  105. name: 'review',
  106. path: 'review',
  107. component: () => import('@/views/review/index'),
  108. include: [Role.SUPERVISOR],
  109. meta: { title: '审核管理' }
  110. },
  111. {
  112. name: 'schedule-deploy-history',
  113. path: 'history',
  114. component: () => import('@/views/schedule/history/index'),
  115. meta: { title: '发布历史' }
  116. }
  117. ]
  118. },
  119. {
  120. path: '/dm',
  121. component: Layout,
  122. meta: { title: '大屏设备', icon: 'el-icon-monitor' },
  123. children: [
  124. {
  125. name: 'schedule-timeline',
  126. path: 'timeline',
  127. component: () => import('@/views/schedule/timeline/index'),
  128. meta: { title: '排期预览' }
  129. },
  130. {
  131. dev: true,
  132. name: 'remote',
  133. path: 'remote',
  134. component: () => import('@/views/device/remote/index'),
  135. meta: { title: '设备操控' }
  136. },
  137. {
  138. name: 'video',
  139. path: 'video',
  140. component: () => import('@/views/schedule/video/index'),
  141. meta: { title: '视频监控' }
  142. }
  143. ]
  144. },
  145. {
  146. path: '/m',
  147. component: Layout,
  148. meta: { title: '大屏管理', icon: 'el-icon-monitor' },
  149. children: [
  150. {
  151. name: 'category',
  152. path: 'category',
  153. component: () => import('@/views/device/category/index'),
  154. include: [Role.ADMIN],
  155. meta: { title: '产品分类' }
  156. },
  157. {
  158. name: 'product',
  159. path: 'product',
  160. component: () => import('@/views/device/product/index'),
  161. include: [Role.ADMIN],
  162. meta: { title: '产品管理' }
  163. },
  164. {
  165. path: 'device',
  166. component: Solo,
  167. meta: { title: '设备管理' },
  168. children: [
  169. {
  170. name: 'device-list',
  171. path: '',
  172. component: () => import('@/views/device/index'),
  173. meta: { cache: 'DeviceList' },
  174. hidden: true
  175. },
  176. {
  177. name: 'device-detail',
  178. path: ':id',
  179. component: () => import('@/views/device/detail/index'),
  180. meta: { title: '设备详情', activeMenu: '/m/device', cache: 'DeviceList' },
  181. hidden: true
  182. }
  183. ]
  184. },
  185. {
  186. name: 'group',
  187. path: 'group',
  188. component: () => import('@/views/device/group/index'),
  189. exclude: [Role.VISITOR],
  190. meta: { title: '分组管理' }
  191. }
  192. ]
  193. },
  194. {
  195. path: '/l',
  196. component: Layout,
  197. exclude: [Role.STAFF],
  198. meta: { icon: 'el-icon-edit-outline' },
  199. children: [
  200. {
  201. path: '',
  202. name: 'logger',
  203. component: () => import('@/views/logger/index'),
  204. meta: { title: '操作日志' }
  205. }
  206. ]
  207. },
  208. {
  209. path: '/d',
  210. component: Layout,
  211. include: [Role.ADMIN],
  212. meta: { icon: 'bug' },
  213. children: [
  214. {
  215. path: '',
  216. name: 'debug',
  217. component: () => import('@/views/debug/index'),
  218. meta: { title: '调试' }
  219. }
  220. ]
  221. },
  222. {
  223. path: '/u',
  224. component: Layout,
  225. include: [Role.ADMIN],
  226. meta: { title: '升级管理', icon: 'el-icon-upload' },
  227. children: [
  228. {
  229. path: 'apk',
  230. name: 'upgrade-apk',
  231. component: () => import('@/views/upgrade/index'),
  232. meta: { title: '版本管理' }
  233. },
  234. {
  235. path: 'deploy',
  236. name: 'upgrade-deploy',
  237. component: () => import('@/views/upgrade/deploy/index'),
  238. meta: { title: '发布升级' }
  239. }
  240. ]
  241. },
  242. {
  243. name: 'design',
  244. path: '/design/:id',
  245. component: () => import('@/views/bigscreen/designer/index'),
  246. exclude: [Role.VISITOR],
  247. hidden: true
  248. },
  249. {
  250. name: 'view',
  251. path: '/view/:id',
  252. component: () => import('@/views/bigscreen/viewer/index'),
  253. hidden: true
  254. },
  255. // 404 page must be placed at the end !!!
  256. { path: '*', redirect: '/', hidden: true }
  257. ]
  258. const createRouter = () => new Router({
  259. // mode: 'history', // require service support
  260. scrollBehavior: () => ({ y: 0 }),
  261. routes: constantRoutes
  262. })
  263. const router = createRouter()
  264. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  265. export function resetRouter () {
  266. const newRouter = createRouter()
  267. router.matcher = newRouter.matcher
  268. }
  269. export default router