index.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
  2. import { ERouterName } from '/@/types/index'
  3. import CreatePlan from '/@/components/task/CreatePlan.vue'
  4. import WaylinePanel from '/@/pages/page-web/projects/wayline.vue'
  5. import DockPanel from '/@/pages/page-web/projects/dock.vue'
  6. const routes: Array<RouteRecordRaw> = [
  7. {
  8. path: '/',
  9. redirect: '/' + ERouterName.PROJECT
  10. },
  11. {
  12. path: '/' + ERouterName.PROJECT,
  13. name: ERouterName.PROJECT,
  14. component: () => import('/@/pages/page-web/index.vue')
  15. },
  16. {
  17. path: '/' + ERouterName.HOME,
  18. name: ERouterName.HOME,
  19. component: () => import('/@/pages/page-web/home.vue'),
  20. children: [
  21. {
  22. path: '/' + ERouterName.DEVICES,
  23. name: ERouterName.DEVICES,
  24. component: () => import('/@/pages/page-web/projects/devices.vue')
  25. },
  26. {
  27. path: '/' + ERouterName.WORKSPACE,
  28. name: ERouterName.WORKSPACE,
  29. component: () => import('/@/pages/page-web/projects/workspace.vue'),
  30. },
  31. {
  32. path: '/' + ERouterName.TASK,
  33. name: ERouterName.TASK,
  34. component: () => import('/@/pages/page-web/projects/task.vue'),
  35. children: [
  36. {
  37. path: ERouterName.CREATE_PLAN,
  38. name: ERouterName.CREATE_PLAN,
  39. component: CreatePlan,
  40. children: [
  41. {
  42. path: ERouterName.SELECT_PLAN,
  43. name: ERouterName.SELECT_PLAN,
  44. components: {
  45. WaylinePanel,
  46. DockPanel
  47. }
  48. }
  49. ]
  50. }
  51. ]
  52. },
  53. {
  54. path: '/' + ERouterName.MEDIA,
  55. name: ERouterName.MEDIA,
  56. component: () => import('/@/pages/page-web/projects/media/index/index.vue')
  57. },
  58. {
  59. path: '/' + ERouterName.MEDIA + '/:id',
  60. name: ERouterName.MEDIA + '/:id',
  61. component: () => import('/@/pages/page-web/projects/media/detail/index.vue')
  62. },
  63. {
  64. path: '/' + ERouterName.TRAJECTORY,
  65. name: ERouterName.TRAJECTORY,
  66. component: () => import('/@/pages/page-web/projects/trajectory/index.vue')
  67. },
  68. {
  69. path: '/' + ERouterName.MEMBER,
  70. name: ERouterName.MEMBER,
  71. component: () => import('/@/pages/page-web/projects/member/index.vue')
  72. },
  73. ]
  74. },
  75. {
  76. path: '/' + ERouterName.PILOT,
  77. name: ERouterName.PILOT,
  78. component: () => import('/@/pages/page-pilot/pilot-index.vue'),
  79. },
  80. {
  81. path: '/' + ERouterName.PILOT_HOME,
  82. component: () => import('/@/pages/page-pilot/pilot-home.vue')
  83. },
  84. {
  85. path: '/' + ERouterName.PILOT_MEDIA,
  86. component: () => import('/@/pages/page-pilot/pilot-media.vue')
  87. },
  88. {
  89. path: '/' + ERouterName.PILOT_LIVESHARE,
  90. component: () => import('/@/pages/page-pilot/pilot-liveshare.vue')
  91. },
  92. {
  93. path: '/' + ERouterName.PILOT_BIND,
  94. component: () => import('/@/pages/page-pilot/pilot-bind.vue')
  95. }
  96. ]
  97. const router = createRouter({
  98. history: createWebHistory(import.meta.env.BASE_URL),
  99. routes
  100. })
  101. router.beforeEach((to, from, next) => {
  102. const { sign, key, userCode } = from.query as any
  103. if (sign && key && userCode) {
  104. localStorage.setItem('sign', sign);
  105. localStorage.setItem('key', key);
  106. localStorage.setItem('userCode', userCode);
  107. next();
  108. } else {
  109. next();
  110. }
  111. })
  112. export default router