index.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. import Vue from 'vue';
  2. import VueRouter from 'vue-router';
  3. import store from '@/store/index';
  4. const jwt = require('jsonwebtoken');
  5. const originalPush = VueRouter.prototype.push;
  6. VueRouter.prototype.push = function push(location, onResolve, onReject) {
  7. if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject);
  8. return originalPush.call(this, location).catch(err => err);
  9. };
  10. Vue.use(VueRouter);
  11. const onLive = [
  12. {
  13. path: '/live/onAchieve/index',
  14. meta: { title: '直播大厅-在线展会' },
  15. component: () => import('../views/live/onAchieve/index.vue'),
  16. },
  17. {
  18. path: '/live/onAchieve/detail',
  19. meta: { title: '在线展会-详细信息' },
  20. component: () => import('../views/live/onAchieve/detail.vue'),
  21. },
  22. {
  23. path: '/live/channel/index',
  24. meta: { title: '直播大厅-科技频道' },
  25. component: () => import('../views/live/channel/index.vue'),
  26. },
  27. {
  28. path: '/live/channel/detail',
  29. meta: { title: '科技频道-详细信息' },
  30. component: () => import('../views/live/channel/detail.vue'),
  31. },
  32. {
  33. path: '/live/trainInter/index',
  34. meta: { title: '直播大厅-培训访谈' },
  35. component: () => import('../views/live/trainInter/index.vue'),
  36. },
  37. {
  38. path: '/live/trainInter/oneDetail',
  39. meta: { title: '嘉宾访谈-详细信息' },
  40. component: () => import('../views/live/trainInter/oneDetail.vue'),
  41. },
  42. {
  43. path: '/live/trainInter/twoDetail',
  44. meta: { title: '技能培训-详细信息' },
  45. component: () => import('../views/live/trainInter/twoDetail.vue'),
  46. },
  47. {
  48. path: '/live/roadshow/index',
  49. meta: { title: '直播大厅-项目路演' },
  50. component: () => import('../views/live/roadshow/index.vue'),
  51. },
  52. {
  53. path: '/live/roadshow/detail',
  54. meta: { title: '项目路演-详细信息' },
  55. component: () => import('../views/live/roadshow/detail.vue'),
  56. },
  57. ];
  58. const market = [
  59. {
  60. path: '/market/achieve/index',
  61. meta: { title: '科技超市-技术成果' },
  62. component: () => import('../views/market/achieve/index.vue'),
  63. },
  64. {
  65. path: '/market/achieve/detail',
  66. meta: { title: '技术成果-详细信息' },
  67. component: () => import('../views/market/achieve/detail.vue'),
  68. },
  69. {
  70. path: '/market/patent/index',
  71. meta: { title: '科技超市-E-专利' },
  72. component: () => import('../views/market/patent/index.vue'),
  73. },
  74. {
  75. path: '/market/patent/detail',
  76. meta: { title: 'E-专利-详细信息' },
  77. component: () => import('../views/market/patent/detail.vue'),
  78. },
  79. {
  80. path: '/market/techol/index',
  81. meta: { title: '科技超市-科技需求' },
  82. component: () => import('../views/market/techol/index.vue'),
  83. },
  84. {
  85. path: '/market/techol/detail',
  86. meta: { title: '科技需求-详细信息' },
  87. component: () => import('../views/market/techol/detail.vue'),
  88. },
  89. {
  90. path: '/market/expert/index',
  91. meta: { title: '科技超市-专家智库' },
  92. component: () => import('../views/market/expert/index.vue'),
  93. },
  94. {
  95. path: '/market/expert/detail',
  96. meta: { title: '专家智库-详细信息' },
  97. component: () => import('../views/market/expert/detail.vue'),
  98. },
  99. {
  100. path: '/market/service/index',
  101. meta: { title: '科技超市-在线服务' },
  102. component: () => import('../views/market/service/index.vue'),
  103. },
  104. {
  105. path: '/market/service/detail',
  106. meta: { title: '在线服务-详细信息' },
  107. component: () => import('../views/market/service/detail.vue'),
  108. },
  109. ];
  110. const user = [
  111. {
  112. path: '/user/question/index',
  113. meta: { title: '个人中心-调查问卷' },
  114. component: () => import('../views/user/question/index.vue'),
  115. },
  116. {
  117. path: '/user/notice/index',
  118. meta: { title: '个人中心-通知通告' },
  119. component: () => import('../views/user/notice/index.vue'),
  120. },
  121. {
  122. path: '/user/notice/detail',
  123. meta: { title: '通知通告-详细信息' },
  124. component: () => import('../views/user/notice/detail.vue'),
  125. },
  126. {
  127. path: '/user/news/index',
  128. meta: { title: '个人中心-新闻资讯' },
  129. component: () => import('../views/user/news/index.vue'),
  130. },
  131. {
  132. path: '/user/news/detail',
  133. meta: { title: '新闻资讯-详细信息' },
  134. component: () => import('../views/user/news/detail.vue'),
  135. },
  136. {
  137. path: '/user/account/index',
  138. meta: { title: '个人中心-账号管理' },
  139. component: () => import('../views/user/account/index.vue'),
  140. },
  141. ];
  142. const routes = [
  143. {
  144. path: '/',
  145. meta: { title: '首页' },
  146. component: () => import('../views/index.vue'),
  147. },
  148. ...onLive,
  149. ...market,
  150. ...user,
  151. ];
  152. const router = new VueRouter({
  153. mode: 'history',
  154. base: process.env.NODE_ENV === 'development' ? '' : process.env.VUE_APP_ROUTER,
  155. routes,
  156. });
  157. // router.beforeEach((to, from, next) => {
  158. // document.title = `${to.meta.title} `;
  159. // let token = localStorage.getItem('token');
  160. // console.log(token);
  161. // if (to.path == '/account/index') {
  162. // if (token == null) {
  163. // next('/login');
  164. // } else {
  165. // let user = jwt.decode(token);
  166. // store.commit('setUser', user, { root: true });
  167. // next();
  168. // }
  169. // } else {
  170. // let user = jwt.decode(token);
  171. // store.commit('setUser', user, { root: true });
  172. // next();
  173. // }
  174. // });
  175. export default router;