index.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  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: '/home',
  43. component: Layout,
  44. children: [
  45. {
  46. name: 'home',
  47. path: 'home',
  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/platform/profile/index'),
  56. meta: { title: '个人设置' }
  57. }
  58. ]
  59. },
  60. {
  61. path: '/cm',
  62. component: Layout,
  63. meta: { title: '智能信发', icon: 'cm' },
  64. children: [
  65. {
  66. name: 'media',
  67. path: 'media',
  68. component: () => import('@/views/platform/media/index'),
  69. access: [Access.MANAGE_CALENDAR, Access.MANAGE_GROUP],
  70. meta: { title: '媒资管理' }
  71. },
  72. {
  73. name: 'program-list',
  74. path: 'program',
  75. component: () => import('@/views/bigscreen/index'),
  76. access: [Access.MANAGE_CALENDAR, Access.MANAGE_GROUP],
  77. meta: { title: '节目管理' }
  78. },
  79. {
  80. path: 'recur',
  81. component: Solo,
  82. meta: { title: '轮播管理' },
  83. children: [
  84. {
  85. name: 'recur-list',
  86. path: '',
  87. component: () => import('@/views/schedule/index'),
  88. access: [Access.MANAGE_CALENDAR, Access.MANAGE_GROUP],
  89. meta: { cache: 'ScheduleList' },
  90. props: { type: ScheduleType.RECUR, redirect: 'recur-design' }
  91. },
  92. {
  93. hidden: true,
  94. name: 'recur-design',
  95. path: ':id',
  96. component: () => import('@/views/schedule/designer/index'),
  97. access: Access.MANAGE_CALENDAR,
  98. meta: { title: '编辑', cache: 'ScheduleList' },
  99. props: { redirect: 'recur-list' }
  100. }
  101. ]
  102. },
  103. {
  104. path: 'schedule',
  105. component: Solo,
  106. meta: { title: '排期管理' },
  107. children: [
  108. {
  109. name: 'schedule-list',
  110. path: '',
  111. component: () => import('@/views/schedule/index'),
  112. access: [Access.MANAGE_CALENDAR, Access.MANAGE_GROUP],
  113. meta: { cache: 'ScheduleList' },
  114. props: { type: ScheduleType.COMPLEX, redirect: 'schedule-design' }
  115. },
  116. {
  117. hidden: true,
  118. name: 'schedule-design',
  119. path: ':id',
  120. component: () => import('@/views/schedule/designer/index'),
  121. access: Access.MANAGE_CALENDAR,
  122. meta: { title: '编辑', cache: 'ScheduleList' },
  123. props: { redirect: 'schedule-list' }
  124. }
  125. ]
  126. },
  127. {
  128. name: 'schedule-deploy',
  129. path: 'deploy',
  130. component: () => import('@/views/schedule/deploy/index'),
  131. access: Access.MANAGE_CALENDAR,
  132. meta: { title: '排期发布' }
  133. },
  134. // {
  135. // path: 'review',
  136. // component: () => import('@/views/review/index'),
  137. // access: Access.MANAGE_GROUP,
  138. // meta: { title: '审核管理' }
  139. // },
  140. {
  141. path: 'workflow',
  142. component: Solo,
  143. access: Access.MANAGE_GROUP,
  144. meta: { title: '流程审核' },
  145. children: [
  146. {
  147. name: 'workflow-list',
  148. path: '',
  149. component: () => import('@/views/review/workflow/index'),
  150. meta: { cache: 'WorkflowList' }
  151. },
  152. {
  153. hidden: true,
  154. name: 'workflow-detail',
  155. path: ':id',
  156. component: () => import('@/views/review/workflow/detail/index'),
  157. meta: { title: '审核', cache: 'WorkflowList' }
  158. }
  159. ]
  160. },
  161. {
  162. path: 'mine',
  163. component: () => import('@/views/review/workflow/mine/index'),
  164. access: Access.MANAGE_CALENDAR,
  165. meta: { title: '我的流程' }
  166. },
  167. {
  168. name: 'deploy-history',
  169. path: 'history',
  170. component: () => import('@/views/review/history/index'),
  171. access: [Access.MANAGE_CALENDAR, Access.MANAGE_GROUP],
  172. meta: { title: '发布历史' }
  173. }
  174. ]
  175. },
  176. {
  177. path: '/dm',
  178. component: Layout,
  179. meta: { title: '大屏设备', icon: 'dm' },
  180. children: [
  181. {
  182. name: 'device-timeline',
  183. path: 'timeline',
  184. component: () => import('@/views/device/timeline/index'),
  185. meta: { title: '排期预览' }
  186. },
  187. {
  188. path: 'device',
  189. component: Solo,
  190. meta: { title: '我的设备' },
  191. children: [
  192. {
  193. name: 'device-list',
  194. path: '',
  195. component: () => import('@/views/device/index'),
  196. meta: { cache: 'DeviceList' }
  197. },
  198. {
  199. hidden: true,
  200. name: 'device-detail',
  201. path: ':id',
  202. component: () => import('@/views/device/detail/index'),
  203. meta: { title: '设备详情', cache: 'DeviceList' }
  204. }
  205. ]
  206. },
  207. {
  208. name: 'group',
  209. path: 'group',
  210. component: () => import('@/views/device/group/index'),
  211. meta: { title: '分组管理' }
  212. },
  213. {
  214. name: 'record',
  215. path: 'record',
  216. component: () => import('@/views/device/record/index'),
  217. meta: { title: '视频回采' }
  218. }
  219. ]
  220. },
  221. {
  222. path: '/dashboard',
  223. component: Solo,
  224. meta: { title: '大数据', icon: 'dm' },
  225. access: [Access.MANAGE_TENANTS, Access.MANAGE_TENANT],
  226. children: [
  227. {
  228. name: 'dashboard-v0',
  229. path: 'v0',
  230. component: () => import('@/views/dashboard/v0/index'),
  231. meta: { title: 'V0' }
  232. },
  233. {
  234. name: 'dashboard-v1',
  235. path: 'v1',
  236. component: () => import('@/views/dashboard/v1/index'),
  237. meta: { title: 'V1' }
  238. }
  239. ]
  240. },
  241. {
  242. path: '/em',
  243. component: Layout,
  244. access: Access.MANAGE_TENANTS,
  245. meta: { title: '设备录入', icon: 'em' },
  246. children: [
  247. {
  248. path: 'transmitter',
  249. name: 'transmitter',
  250. component: () => import('@/views/external/transmitter/index'),
  251. meta: { title: '发送控制设备' }
  252. },
  253. {
  254. path: 'gateway',
  255. name: 'gateway',
  256. component: () => import('@/views/external/gateway/index'),
  257. meta: { title: '网关' }
  258. },
  259. {
  260. path: 'camera',
  261. name: 'camera',
  262. component: () => import('@/views/external/camera/index'),
  263. meta: { title: '摄像头' }
  264. }
  265. ]
  266. },
  267. {
  268. path: '/pm',
  269. component: Layout,
  270. access: [Access.MANAGE_TENANTS, Access.MANAGE_TENANT],
  271. meta: { title: '平台管理', icon: 'pm' },
  272. children: [
  273. {
  274. name: 'settings',
  275. path: 'settings',
  276. component: () => import('@/views/realm/settings/index'),
  277. meta: { title: '功能管理' }
  278. },
  279. {
  280. name: 'org',
  281. path: 'org',
  282. component: () => import('@/views/realm/tenant/index'),
  283. meta: { title: '组织管理' }
  284. },
  285. {
  286. name: 'account',
  287. path: 'account',
  288. component: () => import('@/views/realm/user/index'),
  289. meta: { title: '账号管理' }
  290. },
  291. {
  292. path: 'device/manage',
  293. component: Solo,
  294. meta: { title: '设备管理' },
  295. children: [
  296. {
  297. name: 'device-management',
  298. path: '',
  299. component: () => import('@/views/realm/device/index'),
  300. meta: { cache: 'DeviceManagement' }
  301. },
  302. {
  303. hidden: true,
  304. name: 'device-management-detail',
  305. path: 'detail/:id',
  306. component: () => import('@/views/device/detail/index'),
  307. meta: { title: '详情', cache: 'DeviceManagement' }
  308. },
  309. {
  310. hidden: true,
  311. name: 'device-management-settings',
  312. path: 'settings/:id',
  313. component: () => import('@/views/realm/device/settings/index'),
  314. access: Access.MANAGE_TENANTS,
  315. meta: { title: '配置', cache: 'DeviceManagement' }
  316. }
  317. ]
  318. },
  319. {
  320. name: 'device-assign',
  321. path: 'device/assign',
  322. component: () => import('@/views/realm/assign/index'),
  323. meta: { title: '设备分配' }
  324. },
  325. {
  326. name: 'ai-stock',
  327. path: 'ai/stock',
  328. component: () => import('@/views/realm/ai-stock/index'),
  329. meta: { title: 'AI审核库存' }
  330. },
  331. {
  332. name: 'ai-timing',
  333. path: 'ai/timing',
  334. component: () => import('@/views/realm/ai-timing/index'),
  335. meta: { title: 'AI抽帧检测' }
  336. }
  337. ]
  338. },
  339. {
  340. path: '/ad',
  341. component: Layout,
  342. meta: { title: '广告', icon: 'ad' },
  343. access: [Access.MANAGE_TENANTS],
  344. children: [
  345. {
  346. name: 'ad-asset-review',
  347. path: 'asset/review',
  348. component: () => import('@/views/ad/review-asset/index'),
  349. meta: { title: '素材审核' }
  350. },
  351. {
  352. name: 'ad-order-review',
  353. path: 'order/review',
  354. component: () => import('@/views/ad/review-order/index'),
  355. meta: { title: '订单审核' }
  356. }
  357. ]
  358. },
  359. {
  360. path: '/bm',
  361. component: Layout,
  362. meta: { title: '应急广播', icon: 'bm' },
  363. children: [
  364. {
  365. name: 'broadcast-template',
  366. path: 'template',
  367. component: () => import('@/views/broadcast/template/index'),
  368. access: Access.MANAGE_TENANTS,
  369. meta: { title: '模板管理' }
  370. },
  371. {
  372. name: 'broadcast-deploy',
  373. path: 'deploy',
  374. component: () => import('@/views/broadcast/deploy/index'),
  375. access: [Access.MANAGE_TENANTS, Access.MANAGE_TENANT],
  376. meta: { title: '广播发布' }
  377. },
  378. {
  379. name: 'broadcast-deploy-history',
  380. path: 'history',
  381. component: () => import('@/views/broadcast/history/index'),
  382. access: [Access.MANAGE_TENANTS, Access.MANAGE_TENANT],
  383. meta: { title: '发布历史' }
  384. }
  385. ]
  386. },
  387. {
  388. path: '/l',
  389. component: Layout,
  390. access: Access.VIEW_LOGS,
  391. meta: { icon: 'logger' },
  392. children: [
  393. {
  394. path: '',
  395. name: 'logger',
  396. component: () => import('@/views/platform/logger/index'),
  397. meta: { title: '操作日志' }
  398. }
  399. ]
  400. },
  401. {
  402. path: '/d',
  403. component: Layout,
  404. access: Access.MANAGE_TENANTS,
  405. meta: { icon: 'bug', title: '调试' },
  406. children: [
  407. {
  408. path: 'logger',
  409. name: 'debug',
  410. component: () => import('@/views/realm/debug/index'),
  411. meta: { title: '日志' }
  412. },
  413. {
  414. path: 'simulator',
  415. name: 'simulator',
  416. component: () => import('@/views/realm/debug/simulator/index'),
  417. meta: { title: '模拟器' }
  418. }
  419. ]
  420. },
  421. {
  422. path: '/u',
  423. component: Layout,
  424. access: Access.MANAGE_TENANTS,
  425. meta: { title: '升级管理', icon: 'upgrade' },
  426. children: [
  427. {
  428. path: 'apk',
  429. name: 'upgrade-apk',
  430. component: () => import('@/views/realm/upgrade/index'),
  431. meta: { title: '版本管理' }
  432. },
  433. {
  434. path: 'deploy',
  435. name: 'upgrade-deploy',
  436. component: () => import('@/views/realm/upgrade/deploy/index'),
  437. meta: { title: '发布升级' }
  438. }
  439. ]
  440. },
  441. {
  442. hidden: true,
  443. name: 'program',
  444. path: '/cm/program/:id',
  445. component: () => import('@/views/bigscreen/ast/index'),
  446. props: true
  447. },
  448. {
  449. dev: !__DEVICE_DASHBARD__,
  450. hidden: true,
  451. name: 'device-dashboard',
  452. path: '/dm/dashboard/:id',
  453. component: () => import('@/views/device/detail/dashboard/index'),
  454. props: true
  455. },
  456. // 404 page must be placed at the end !!!
  457. { hidden: true, path: '*', redirect: '/' }
  458. ]
  459. const createRouter = () => new Router({
  460. // mode: 'history', // require service support
  461. scrollBehavior: () => { return { y: 0 } },
  462. routes: constantRoutes
  463. })
  464. const router = createRouter()
  465. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  466. export function resetRouter () {
  467. const newRouter = createRouter()
  468. router.matcher = newRouter.matcher
  469. }
  470. export default router