书院官网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. import { createRouter, createWebHistory } from "vue-router";
  2. const isMobile = /Android|webOS|iPhone|iPod|BlackBerry|iPad/i.test(navigator.userAgent);
  3. const redirectPath = isMobile ? "/m_home" : "/p_home";
  4. const routes = [{
  5. path: "/",
  6. redirect: redirectPath,
  7. },
  8. {
  9. path: "/m_home",
  10. name: "M_Home",
  11. component: () =>
  12. import ("@/views/mobile/home/Home.vue"),
  13. meta: {
  14. title: "首页",
  15. isNav: true,
  16. type: "mobile",
  17. },
  18. },
  19. {
  20. path: "/m_industry-park",
  21. name: "M_IndustryPark",
  22. component: () =>
  23. import ("@/views/mobile/industry/IndustryPark.vue"),
  24. meta: {
  25. title: "产业园区",
  26. isNav: true,
  27. type: "mobile",
  28. },
  29. },
  30. {
  31. path: "/m_investment-projects",
  32. name: "M_InvestmentProjects",
  33. component: () =>
  34. import ("@/views/mobile/project/InvestmentProjects.vue"),
  35. meta: {
  36. title: "招商项目 ",
  37. isNav: true,
  38. type: "mobile",
  39. },
  40. },
  41. {
  42. path: "/m_preferential-policy",
  43. name: "M_PreferentialPolicy",
  44. component: () =>
  45. import ("@/views/mobile/policy/PreferentialPolicy.vue"),
  46. meta: {
  47. title: "优惠政策",
  48. isNav: true,
  49. type: "mobile",
  50. },
  51. },
  52. {
  53. path: "/m_preferential-policy-detail",
  54. name: "M_PreferentialPolicyDetail",
  55. component: () =>
  56. import ("@/views/mobile/policy/PreferentialPolicyDetail.vue"),
  57. meta: {
  58. title: "优惠政策",
  59. type: "mobile",
  60. },
  61. },
  62. {
  63. path: "/m_about-me",
  64. name: "M_AboutMe",
  65. component: () =>
  66. import ("@/views/mobile/aboutMe/AboutMe.vue"),
  67. meta: {
  68. title: "关于书院",
  69. isNav: true,
  70. type: "mobile",
  71. },
  72. },
  73. {
  74. path: "/m_apply-for-entry",
  75. name: "M_ApplyForEntry",
  76. component: () =>
  77. import ("@/views/mobile/ApplyForEntry.vue"),
  78. meta: {
  79. title: "申请入驻",
  80. isNav: true,
  81. type: "mobile",
  82. },
  83. },
  84. {
  85. path: "/p_home",
  86. name: "P_Home",
  87. component: () =>
  88. import ("@/views/pc/home/Home.vue"),
  89. meta: {
  90. title: "首页",
  91. isNav: true,
  92. type: "pc",
  93. },
  94. },
  95. {
  96. path: "/p_industry-park",
  97. name: "P_IndustryPark",
  98. component: () =>
  99. import ("@/views/pc/industry/IndustryPark.vue"),
  100. meta: {
  101. title: "产业园区",
  102. isNav: true,
  103. type: "pc",
  104. },
  105. },
  106. {
  107. path: "/p_investment-projects",
  108. name: "P_InvestmentProjects",
  109. component: () =>
  110. import ("@/views/pc/project/InvestmentProjects.vue"),
  111. meta: {
  112. title: "招商项目 ",
  113. isNav: true,
  114. type: "pc",
  115. },
  116. },
  117. {
  118. path: "/p_preferential-policy",
  119. name: "P_PreferentialPolicy",
  120. component: () =>
  121. import ("@/views/pc/policy/PreferentialPolicy.vue"),
  122. meta: {
  123. title: "优惠政策",
  124. isNav: true,
  125. type: "pc",
  126. },
  127. },
  128. {
  129. path: "/p_preferential-policy-detail",
  130. name: "P_PreferentialPolicyDetail",
  131. component: () =>
  132. import ("@/views/pc/policy/PreferentialPolicyDetail.vue"),
  133. meta: {
  134. title: "优惠政策",
  135. type: "pc",
  136. },
  137. },
  138. {
  139. path: "/p_about-me",
  140. name: "P_AboutMe",
  141. component: () =>
  142. import ("@/views/pc/aboutMe/AboutMe.vue"),
  143. meta: {
  144. title: "关于书院",
  145. isNav: true,
  146. type: "pc",
  147. },
  148. },
  149. {
  150. path: "/p_apply-for-entry",
  151. name: "P_ApplyForEntry",
  152. component: () =>
  153. import ("@/views/pc/apply/ApplyForEntry.vue"),
  154. meta: {
  155. title: "申请入驻",
  156. isNav: true,
  157. type: "pc",
  158. },
  159. },
  160. ];
  161. const router = createRouter({
  162. history: createWebHistory("/public"),
  163. routes,
  164. scrollBehavior() {
  165. return {
  166. left: 0,
  167. top: 0,
  168. };
  169. },
  170. });
  171. router.beforeEach((to, from, next) => {
  172. // 移动端访问PC
  173. if (isMobile && to.meta.type !== "mobile") {
  174. let routers = router.options.routes.filter(v => v.path != "/" && v.meta.type === "mobile");
  175. let path = null;
  176. routers.forEach(v => {
  177. if (v.name.split("_")[1] == to.name.split("_")[1]) {
  178. path = v.path;
  179. }
  180. });
  181. if (path) next(path);
  182. next("/");
  183. }
  184. // pc 访问 移动
  185. if (!isMobile && to.meta.type !== "pc") {
  186. const routers = router.options.routes.filter(v => v.path != "/" && v.meta.type === "pc");
  187. let path = null;
  188. routers.forEach(v => {
  189. if (v.name.split("_")[1] == to.name.split("_")[1]) {
  190. path = v.path;
  191. }
  192. });
  193. if (path) next(path);
  194. next("/");
  195. }
  196. next();
  197. });
  198. export default router;