index.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. import {
  4. ScheduleType,
  5. Access
  6. } from '@/constant'
  7. import Layout from '@/layout'
  8. import Solo from '@/layout/Solo'
  9. Vue.use(Router)
  10. /**
  11. * sub-menu only appear when route children.length >= 1
  12. * dev: true, if set true, item will not show in production
  13. * hidden: true, if set true, item will not show in the sidebar(default is false)
  14. * name:'router-name' , if it is not a wrapping layer(Layout or Solo), it must be set!!!
  15. * include: ['admin'], control the page roles (you can set multiple roles)
  16. * access: 'manage-profile', control the page access
  17. * meta : {
  18. * title: 'title', the name show in sidebar and breadcrumb (recommend set)
  19. * icon: 'svg-name'/'el-icon-x', the icon show in the sidebar
  20. * cache: 'router-name' if set, the router will be cached (only in Solo)
  21. * }
  22. */
  23. /**
  24. * constantRoutes
  25. * a base page that does not have permission requirements
  26. * all roles can be accessed
  27. */
  28. export const constantRoutes = [
  29. {
  30. hidden: true,
  31. path: '/error',
  32. component: () => import('@/views/platform/error-page/index')
  33. }
  34. ]
  35. /**
  36. * asyncRoutes
  37. * the routes that need to be dynamically loaded based on user roles
  38. */
  39. export const asyncRoutes = [
  40. {
  41. path: '/',
  42. redirect: '/dashboard',
  43. component: Layout,
  44. children: [
  45. {
  46. name: 'dashboard',
  47. path: 'dashboard',
  48. component: () => import('@/views/dashboard/index'),
  49. meta: { title: '首页', icon: 'home' }
  50. },
  51. {
  52. hidden: true,
  53. name: 'profile',
  54. path: 'profile',
  55. component: () => import('@/views/basic/profile/index'),
  56. access: Access.MANAGE_PROFILE,
  57. meta: { title: '个人设置' }
  58. }
  59. ]
  60. },
  61. {
  62. path: '/cm',
  63. component: Layout,
  64. meta: { title: '智能信发', icon: 'cm' },
  65. children: [
  66. {
  67. name: 'media',
  68. path: 'media',
  69. component: () => import('@/views/basic/media/index'),
  70. access: Access.MANAGE_ASSETS,
  71. meta: { title: '媒资管理' }
  72. },
  73. {
  74. name: 'program-list',
  75. path: 'program',
  76. component: () => import('@/views/bigscreen/index'),
  77. access: Access.MANAGE_CALENDAR,
  78. meta: { title: '节目编辑' }
  79. },
  80. {
  81. path: 'recur',
  82. component: Solo,
  83. access: Access.MANAGE_CALENDAR,
  84. meta: { title: '轮播编排' },
  85. children: [
  86. {
  87. name: 'recur-list',
  88. path: '',
  89. component: () => import('@/views/schedule/index'),
  90. meta: { cache: 'ScheduleList' },
  91. props: { type: ScheduleType.RECUR, redirect: 'recur-design' }
  92. },
  93. {
  94. hidden: true,
  95. name: 'recur-design',
  96. path: ':id',
  97. component: () => import('@/views/schedule/designer/index'),
  98. meta: { title: '编辑', cache: 'ScheduleList' },
  99. props: { redirect: 'recur-list' }
  100. }
  101. ]
  102. },
  103. {
  104. path: 'schedule',
  105. component: Solo,
  106. access: Access.MANAGE_CALENDAR,
  107. meta: { title: '排期编排' },
  108. children: [
  109. {
  110. name: 'schedule-list',
  111. path: '',
  112. component: () => import('@/views/schedule/index'),
  113. meta: { cache: 'ScheduleList' },
  114. props: {
  115. type: ScheduleType.COMPLEX,
  116. redirect: 'schedule-design'
  117. }
  118. },
  119. {
  120. hidden: true,
  121. name: 'schedule-design',
  122. path: ':id',
  123. component: () => import('@/views/schedule/designer/index'),
  124. meta: {
  125. title: '编辑',
  126. cache: 'ScheduleList'
  127. },
  128. props: {
  129. redirect: 'schedule-list'
  130. }
  131. }
  132. ]
  133. },
  134. {
  135. name: 'schedule-deploy',
  136. path: 'deploy',
  137. component: () => import('@/views/schedule/deploy/index'),
  138. access: Access.PUBLISH_CALENDAR,
  139. meta: { title: '排期发布' }
  140. },
  141. {
  142. name: 'review',
  143. path: 'review',
  144. component: () => import('@/views/review/index'),
  145. access: Access.REVIEW,
  146. meta: { title: '审核管理' }
  147. },
  148. {
  149. name: 'schedule-deploy-history',
  150. path: 'history',
  151. component: () => import('@/views/schedule/history/index'),
  152. access: [Access.PUBLISH_CALENDAR, Access.REVIEW],
  153. meta: { title: '发布历史' }
  154. }
  155. ]
  156. },
  157. {
  158. path: '/dm',
  159. component: Layout,
  160. meta: { title: '大屏设备', icon: 'dm' },
  161. children: [
  162. {
  163. name: 'schedule-timeline',
  164. path: 'timeline',
  165. component: () => import('@/views/schedule/timeline/index'),
  166. meta: { title: '排期预览' }
  167. },
  168. {
  169. path: 'device',
  170. component: Solo,
  171. meta: { title: '设备管理' },
  172. children: [
  173. {
  174. name: 'device-list',
  175. path: '',
  176. component: () => import('@/views/device/index'),
  177. access: [Access.MANAGE_DEVICES, Access.MANAGE_DEVICE],
  178. meta: { cache: 'DeviceList' }
  179. },
  180. {
  181. hidden: true,
  182. name: 'device-detail',
  183. path: ':id',
  184. component: () => import('@/views/device/detail/index'),
  185. meta: { title: '设备详情', cache: 'DeviceList' }
  186. }
  187. ]
  188. },
  189. {
  190. name: 'group',
  191. path: 'group',
  192. component: () => import('@/views/device/group/index'),
  193. access: Access.MANAGE_GROUPS,
  194. meta: { title: '分组管理' }
  195. },
  196. {
  197. dev: true,
  198. name: 'remote',
  199. path: 'remote',
  200. component: () => import('@/views/device/remote/index'),
  201. meta: { title: '设备操控' }
  202. },
  203. {
  204. name: 'back',
  205. path: 'back',
  206. component: () => import('@/views/device/back/index'),
  207. meta: { title: '视频回传' }
  208. }
  209. ]
  210. },
  211. {
  212. path: '/em',
  213. component: Layout,
  214. meta: { title: '设备录入', icon: 'em' },
  215. children: [
  216. {
  217. path: 'transmitter',
  218. name: 'transmitter',
  219. access: Access.MANAGE_DEVICES,
  220. component: () => import('@/views/external/transmitter/index'),
  221. meta: { title: '发送控制设备' }
  222. },
  223. {
  224. path: 'camera',
  225. name: 'camera',
  226. access: Access.VIEW_CAMERAS,
  227. component: () => import('@/views/external/camera/index'),
  228. meta: { title: '摄像头' }
  229. }
  230. ]
  231. },
  232. {
  233. path: '/pm',
  234. component: Layout,
  235. meta: { title: '平台管理', icon: 'pm' },
  236. children: [
  237. {
  238. name: 'category',
  239. path: 'category',
  240. component: () => import('@/views/device/category/index'),
  241. access: Access.MANAGE_PRODUCTS,
  242. meta: { title: '产品分类' }
  243. },
  244. {
  245. name: 'product',
  246. path: 'product',
  247. component: () => import('@/views/device/product/index'),
  248. access: Access.MANAGE_PRODUCTS,
  249. meta: { title: '产品管理' }
  250. },
  251. {
  252. name: 'transfer-deploy',
  253. path: 'deploy',
  254. component: () => import('@/views/platform/transfer/deploy/index'),
  255. access: Access.SUPER_ADMIN,
  256. meta: { title: '旧排期发布' }
  257. },
  258. {
  259. name: 'transfer',
  260. path: 'transfer',
  261. component: () => import('@/views/platform/transfer/index'),
  262. access: Access.SUPER_ADMIN,
  263. meta: { title: '数据迁移' }
  264. }
  265. ]
  266. },
  267. {
  268. path: '/l',
  269. component: Layout,
  270. access: Access.VIEW_LOGS,
  271. meta: { icon: 'logger' },
  272. children: [
  273. {
  274. path: '',
  275. name: 'logger',
  276. component: () => import('@/views/basic/logger/index'),
  277. meta: { title: '操作日志' }
  278. }
  279. ]
  280. },
  281. {
  282. path: '/d',
  283. component: Layout,
  284. access: Access.SUPER_ADMIN,
  285. meta: { icon: 'bug' },
  286. children: [
  287. {
  288. path: '',
  289. name: 'debug',
  290. component: () => import('@/views/platform/debug/index'),
  291. meta: { title: '调试' }
  292. }
  293. ]
  294. },
  295. {
  296. path: '/u',
  297. component: Layout,
  298. access: Access.MANAGE_UPGRADE,
  299. meta: { title: '升级管理', icon: 'upgrade' },
  300. children: [
  301. {
  302. path: 'apk',
  303. name: 'upgrade-apk',
  304. component: () => import('@/views/basic/upgrade/index'),
  305. meta: { title: '版本管理' }
  306. },
  307. {
  308. path: 'deploy',
  309. name: 'upgrade-deploy',
  310. component: () => import('@/views/basic/upgrade/deploy/index'),
  311. meta: { title: '发布升级' }
  312. }
  313. ]
  314. },
  315. // {
  316. // hidden: true,
  317. // name: 'design',
  318. // path: '/design/:id',
  319. // component: () => import('@/views/bigscreen/designer/index'),
  320. // access: Access.MANAGE_CALENDAR
  321. // },
  322. // {
  323. // hidden: true,
  324. // name: 'view',
  325. // path: '/view/:id',
  326. // component: () => import('@/views/bigscreen/viewer/index')
  327. // },
  328. {
  329. hidden: true,
  330. name: 'program',
  331. path: '/cm/program/:id',
  332. component: () => import('@/views/bigscreen/ast/index'),
  333. props: true
  334. },
  335. // 404 page must be placed at the end !!!
  336. { hidden: true, path: '*', redirect: '/' }
  337. ]
  338. const createRouter = () => new Router({
  339. // mode: 'history', // require service support
  340. scrollBehavior: () => ({ y: 0 }),
  341. routes: constantRoutes
  342. })
  343. const router = createRouter()
  344. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  345. export function resetRouter () {
  346. const newRouter = createRouter()
  347. router.matcher = newRouter.matcher
  348. }
  349. export default router