index.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. dev: !__PREVIEW__,
  121. path: '/dm',
  122. component: Layout,
  123. meta: { title: '大屏设备', icon: 'el-icon-monitor' },
  124. children: [
  125. {
  126. name: 'schedule-timeline',
  127. path: 'timeline',
  128. component: () => import('@/views/schedule/timeline/index'),
  129. meta: { title: '排期预览' }
  130. },
  131. {
  132. dev: true,
  133. name: 'remote',
  134. path: 'remote',
  135. component: () => import('@/views/device/remote/index'),
  136. meta: { title: '设备操控' }
  137. }
  138. ]
  139. },
  140. {
  141. path: '/m',
  142. component: Layout,
  143. meta: { title: '大屏管理', icon: 'el-icon-monitor' },
  144. children: [
  145. {
  146. name: 'category',
  147. path: 'category',
  148. component: () => import('@/views/device/category/index'),
  149. include: [Role.ADMIN],
  150. meta: { title: '产品分类' }
  151. },
  152. {
  153. name: 'product',
  154. path: 'product',
  155. component: () => import('@/views/device/product/index'),
  156. include: [Role.ADMIN],
  157. meta: { title: '产品管理' }
  158. },
  159. {
  160. path: 'device',
  161. component: Solo,
  162. meta: { title: '设备管理' },
  163. children: [
  164. {
  165. name: 'device-list',
  166. path: '',
  167. component: () => import('@/views/device/index'),
  168. meta: { cache: 'DeviceList' },
  169. hidden: true
  170. },
  171. {
  172. name: 'device-detail',
  173. path: ':id',
  174. component: () => import('@/views/device/detail/index'),
  175. meta: { title: '设备详情', activeMenu: '/m/device', cache: 'DeviceList' },
  176. hidden: true
  177. }
  178. ]
  179. },
  180. {
  181. name: 'group',
  182. path: 'group',
  183. component: () => import('@/views/device/group/index'),
  184. exclude: [Role.VISITOR],
  185. meta: { title: '分组管理' }
  186. }
  187. ]
  188. },
  189. {
  190. path: '/l',
  191. component: Layout,
  192. exclude: [Role.STAFF],
  193. meta: { icon: 'el-icon-edit-outline' },
  194. children: [
  195. {
  196. path: '',
  197. name: 'logger',
  198. component: () => import('@/views/logger/index'),
  199. meta: { title: '操作日志' }
  200. }
  201. ]
  202. },
  203. {
  204. path: '/d',
  205. component: Layout,
  206. include: [Role.ADMIN],
  207. meta: { icon: 'bug' },
  208. children: [
  209. {
  210. path: '',
  211. name: 'debug',
  212. component: () => import('@/views/debug/index'),
  213. meta: { title: '调试' }
  214. }
  215. ]
  216. },
  217. {
  218. path: '/u',
  219. component: Layout,
  220. include: [Role.ADMIN],
  221. meta: { title: '升级管理', icon: 'el-icon-upload' },
  222. children: [
  223. {
  224. path: 'apk',
  225. name: 'upgrade-apk',
  226. component: () => import('@/views/upgrade/index'),
  227. meta: { title: '版本管理' }
  228. },
  229. {
  230. path: 'deploy',
  231. name: 'upgrade-deploy',
  232. component: () => import('@/views/upgrade/deploy/index'),
  233. meta: { title: '发布升级' }
  234. }
  235. ]
  236. },
  237. {
  238. name: 'design',
  239. path: '/design/:id',
  240. component: () => import('@/views/bigscreen/designer/index'),
  241. exclude: [Role.VISITOR],
  242. hidden: true
  243. },
  244. {
  245. name: 'view',
  246. path: '/view/:id',
  247. component: () => import('@/views/bigscreen/viewer/index'),
  248. hidden: true
  249. },
  250. // 404 page must be placed at the end !!!
  251. { path: '*', redirect: '/', hidden: true }
  252. ]
  253. const createRouter = () => new Router({
  254. // mode: 'history', // require service support
  255. scrollBehavior: () => ({ y: 0 }),
  256. routes: constantRoutes
  257. })
  258. const router = createRouter()
  259. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  260. export function resetRouter () {
  261. const newRouter = createRouter()
  262. router.matcher = newRouter.matcher
  263. }
  264. export default router