index.js 7.5 KB

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