index.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. import { createRouter, createWebHistory } from 'vue-router'
  2. import Home from '../pages/Home.vue'
  3. import CourseDetail from '../pages/CourseDetail.vue'
  4. import MyLearning from '../pages/MyLearning.vue'
  5. import MyLearningHome from '../pages/MyLearningHome.vue'
  6. import Layout from '@/components/Layout.vue'
  7. import { pa } from 'element-plus/es/locales.mjs'
  8. const routes = [
  9. {
  10. path: '/',
  11. name: 'Home',
  12. component: Home,
  13. redirect: '/index',
  14. meta: { title: 'route.home' },
  15. children: [
  16. {
  17. path: 'index',
  18. name: 'Index',
  19. component: Home,
  20. meta: { title: 'route.home' }
  21. }
  22. ]
  23. },
  24. {
  25. path: '/search-platform',
  26. name: 'SearchPlatformHome',
  27. component:() => import('@/pages/SearchPlatform.vue'),
  28. meta: { title: 'SearchPlatformHome' },
  29. children: [
  30. // {
  31. // path: 'search-platform',
  32. // name: 'SearchPlatform',
  33. // component: () => import('@/pages/SearchPlatform.vue'),
  34. // meta: { title: '' }
  35. // },
  36. {
  37. path: 'workflow-detail',
  38. name: 'WorkflowDetail',
  39. component: () => import('@/pages/WorkflowDetail.vue'),
  40. meta: { title: '' }
  41. },
  42. {
  43. path: 'workflow-add',
  44. name: 'WorkflowAdd',
  45. component: () => import('@/pages/WorkflowAdd.vue'),
  46. meta: { title: 'common.chuangjiangongzuoliu' }
  47. }
  48. ]
  49. },
  50. {
  51. path: '/workflow-add',
  52. name: 'WorkflowAddHome',
  53. component: () => import('@/pages/WorkflowAdd.vue'),
  54. meta: { title: 'common.chuangjiangongzuoliu' }
  55. },
  56. {
  57. path: '/workflow-detail',
  58. name: 'WorkflowDetailHome',
  59. component: () => import('@/pages/WorkflowDetail.vue'),
  60. meta: { title: '' }
  61. },
  62. {
  63. path: '/workflow-trade',
  64. name: 'WorkflowTradeHome',
  65. component: () => import('@/pages/workflowTrade/workflowTrade.vue'),
  66. meta: { title: 'common.gongzuoliu_trade' },
  67. children: [
  68. {
  69. path: 'workflow-trade-detail',
  70. name: 'WorkflowTradeDetail',
  71. component: () => import('@/pages/workflowTrade/workflowTradeDetail.vue'),
  72. meta: { title: '' }
  73. },
  74. {
  75. path: 'workflow-trade-add',
  76. name: 'WorkflowTradeAdd',
  77. component: () => import('@/pages/workflowTrade/workflowTradeAdd.vue'),
  78. meta: { title: 'route.gongzuoliu_trade_add' }
  79. }
  80. ]
  81. },
  82. {
  83. path: '/learning-system',
  84. name: 'LearningSystemHome',
  85. component: () => import('@/pages/LearningSystem/LearningSystem.vue'),
  86. meta: { title: 'route.learning_system' },
  87. children: [
  88. {
  89. path: 'detail/:courseId',
  90. name: 'LearningSystemDetail',
  91. component: () => import('@/pages/LearningSystem/LearningSystemDetail.vue'),
  92. meta: { title: '' },
  93. children: [
  94. {
  95. path: 'course/:courseId',
  96. name: 'CourseDetail',
  97. component: () => import('@/pages/LearningSystem/CourseDetail.vue'),
  98. meta: { title: '' }
  99. }
  100. ]
  101. },
  102. ]
  103. },
  104. {
  105. path: '/order-confirm',
  106. name: 'OrderConfirmHome',
  107. component: () => import('@/pages/order/orderConfirm.vue'),
  108. meta: { title: 'route.recharge' }
  109. },
  110. {
  111. path: '/learn-note',
  112. name: 'LearnNoteHome',
  113. component: () => import('@/pages/LearnNote/LearnNote.vue'),
  114. meta: { title: 'common.xuxibiji' }
  115. },
  116. {
  117. path: '/mibi-shop',
  118. name: 'MibiShopHome',
  119. component: () => import('@/pages/mibiShop/mibiShop.vue'),
  120. meta: { title: 'route.mibiShop' }
  121. },
  122. {
  123. path: '/personal-center',
  124. name: 'PersonalCenterHome',
  125. component: () => import('@/pages/PersonalCenter.vue'),
  126. meta: { title: 'personalCenter.personalCenter' },
  127. children:[
  128. {
  129. path: 'wallet',
  130. name: 'Wallet',
  131. component: () => import('@/pages/Personal/Wallet.vue')
  132. },
  133. {
  134. path: 'collection',
  135. name: 'Collection',
  136. component: () => import('@/pages/Personal/Collection.vue')
  137. },
  138. {
  139. path: 'orders',
  140. name: 'Orders',
  141. component: () => import('@/pages/Personal/Orders.vue')
  142. },
  143. {
  144. path: 'member-details',
  145. name: 'MemberDetails',
  146. component: () => import('@/pages/Personal/MemberDetails.vue')
  147. },
  148. {
  149. path: 'demand',
  150. name: 'Demand',
  151. component: () => import('@/pages/Personal/Demand.vue')
  152. },
  153. {
  154. path: 'invoice',
  155. name: 'Invoice',
  156. component: () => import('@/pages/Personal/Invoice.vue')
  157. },
  158. {
  159. path: 'workflow',
  160. name: 'Workflow',
  161. component: () => import('@/pages/Personal/Workflow.vue')
  162. },
  163. {
  164. path: 'business-management',
  165. name: 'BusinessManagement',
  166. component: () => import('@/pages/Personal/BusinessManagement.vue')
  167. }
  168. ]
  169. },
  170. {
  171. path:'/member',
  172. name:'Member',
  173. component: () => import('@/pages/Member.vue')
  174. },
  175. {
  176. path: '/agreement',
  177. name: 'Agreement',
  178. component: () => import('@/pages/Agreement.vue'),
  179. meta: { title: 'common.agreement' }
  180. },
  181. // 一下是demon内容
  182. {
  183. path: '/course/:id',
  184. name: 'CourseDetail2',
  185. component: CourseDetail,
  186. meta: { title: 'route.courseDetail' }
  187. },
  188. {
  189. path: '/my-learning',
  190. name: 'MyLearningHome',
  191. component: Layout,
  192. meta: { title: 'route.myLearning' },
  193. children: [
  194. {
  195. path: '',
  196. name: 'MyLearning',
  197. component: MyLearning,
  198. meta: { title: 'route.myLearning' }
  199. },
  200. {
  201. path: 'course/:id',
  202. name: 'MyLearningCourseDetail',
  203. component: CourseDetail,
  204. meta: { title: 'route.myLearningCourseDetail' }
  205. }
  206. ]
  207. },
  208. // 404 路由
  209. {
  210. path: '/:pathMatch(.*)*',
  211. name: 'NotFound',
  212. component: () => import('@/pages/NotFound.vue')
  213. }
  214. ]
  215. const router = createRouter({
  216. history: createWebHistory(import.meta.env.BASE_URL),
  217. routes,
  218. // 添加scrollBehavior配置项,实现页面切换时滚轴置顶
  219. scrollBehavior() {
  220. return { top: 0 }
  221. }
  222. })
  223. // 全局路由守卫
  224. router.beforeEach((to, from, next) => {
  225. // 设置页面标题
  226. // document.title = to.meta.title || 'Boom Ai'
  227. // 动态设置路由的meta.title
  228. const lastRoute = to.matched?.[to.matched.length - 1]
  229. if (lastRoute && to.query.metaTitle) {
  230. to.meta.title = to.query.metaTitle;
  231. lastRoute.meta.title = to.query.metaTitle;
  232. }
  233. next()
  234. })
  235. export default router