index.js 7.6 KB

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