index.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. import Vue from 'vue';
  2. import VueRouter from 'vue-router';
  3. import store from '@/store/index';
  4. const originalPush = VueRouter.prototype.push;
  5. VueRouter.prototype.push = function push(location) {
  6. return originalPush.call(this, location).catch(err => err);
  7. };
  8. const jwt = require('jsonwebtoken');
  9. const list = [
  10. {
  11. path: '/market/list',
  12. name: 'market_list',
  13. meta: { title: '科技超市' },
  14. component: () => import('../views/market/list.vue'),
  15. },
  16. {
  17. path: '/techolchat/list',
  18. name: 'techolchat_list',
  19. meta: { title: '技术交流' },
  20. component: () => import('../views/techolchat/list.vue'),
  21. },
  22. {
  23. path: '/news/list',
  24. name: 'news_list',
  25. meta: { title: '新闻资讯' },
  26. component: () => import('../views/news/list.vue'),
  27. },
  28. ];
  29. const admin = [
  30. {
  31. path: '/admin/live/science',
  32. name: 'admin_live_science',
  33. meta: { title: '科技频道管理中心' },
  34. component: () => import('../views/admin/live/science.vue'),
  35. },
  36. {
  37. path: '/admin/live/train',
  38. name: 'admin_live_train',
  39. meta: { title: '培训问诊管理中心' },
  40. component: () => import('../views/admin/live/train.vue'),
  41. },
  42. {
  43. path: '/admin/live/achieve',
  44. name: 'admin_live_achieve',
  45. meta: { title: '科技成果管理中心' },
  46. component: () => import('../views/admin/live/achieve.vue'),
  47. },
  48. ];
  49. Vue.use(VueRouter);
  50. const live = [
  51. {
  52. path: '/',
  53. name: 'index',
  54. meta: { title: '网站首页' },
  55. component: () => import('../views/index.vue'),
  56. },
  57. {
  58. path: '/login',
  59. name: 'login',
  60. meta: { title: '登录' },
  61. component: () => import('../views/login.vue'),
  62. },
  63. {
  64. path: '/register',
  65. name: 'register',
  66. meta: { title: '注册账号' },
  67. component: () => import('../views/register.vue'),
  68. },
  69. {
  70. path: '/agreement',
  71. name: 'agreement',
  72. meta: { title: '用户注册协议' },
  73. component: () => import('../views/agreement.vue'),
  74. },
  75. {
  76. path: '/channelLive/index',
  77. name: 'channelLive_index',
  78. meta: { title: '直播大厅-科技频道', subSite: true },
  79. component: () => import('../views/channelLive/index.vue'),
  80. },
  81. {
  82. path: '/trainLive/index',
  83. name: 'trainLive_index',
  84. meta: { title: '直播大厅-培训问诊', subSite: true },
  85. component: () => import('../views/trainLive/index.vue'),
  86. },
  87. {
  88. path: '/personalLive/index',
  89. name: 'personalLive_index',
  90. meta: { title: '直播大厅-人才对接', subSite: true },
  91. component: () => import('../views/personalLive/index.vue'),
  92. },
  93. {
  94. path: '/achieveLive/before',
  95. name: 'personalLive_before',
  96. meta: { title: '直播大厅-展会活动页', subSite: true },
  97. component: () => import('../views/achieveLive/before.vue'),
  98. },
  99. {
  100. path: '/achieveLive/detail',
  101. name: 'personalLive_detail',
  102. meta: { title: '直播大厅-展会详情', subSite: true },
  103. component: () => import('../views/achieveLive/detail.vue'),
  104. },
  105. // {
  106. // path: '/achieveLive/expert/index',
  107. // name: 'achieveLive_expert',
  108. // meta: { title: '直播大厅-参展专家', subSite: true },
  109. // component: () => import('../views/achieveLive/expert/index.vue'),
  110. // },
  111. // {
  112. // path: '/achieveLive/expert/detail',
  113. // name: 'achieveLive_detail',
  114. // meta: { title: '直播大厅-对接专家', subSite: true },
  115. // component: () => import('../views/achieveLive/expert/detail.vue'),
  116. // },
  117. // {
  118. // path: '/achieveLive/product/index',
  119. // name: 'achieveLive_product',
  120. // meta: { title: '直播大厅-参展项目', subSite: true },
  121. // component: () => import('../views/achieveLive/product/index.vue'),
  122. // },
  123. // {
  124. // path: '/achieveLive/product/detail',
  125. // name: 'achieveLive_detail',
  126. // meta: { title: '直播大厅-对接项目', subSite: true },
  127. // component: () => import('../views/achieveLive/product/detail.vue'),
  128. // },
  129. {
  130. path: '/achieveLive/news/detail',
  131. name: 'achieveLive_news_detail',
  132. meta: { title: '直播大厅-嘉宾访谈,项目路演', subSite: true },
  133. component: () => import('../views/achieveLive/news/detail.vue'),
  134. },
  135. {
  136. path: '/website',
  137. name: 'website',
  138. component: () => import('../views/website.vue'),
  139. children: [
  140. // 新闻资讯
  141. {
  142. path: '/news/index',
  143. name: 'news_index',
  144. meta: { title: '新闻资讯', subSite: true },
  145. component: () => import('../views/news/index.vue'),
  146. },
  147. // 科技超市
  148. {
  149. path: '/market/index',
  150. name: 'market_index',
  151. meta: { title: '科技超市', subSite: true },
  152. component: () => import('../views/market/index.vue'),
  153. },
  154. ...list,
  155. // 直播大厅
  156. {
  157. path: '/live/index',
  158. name: 'live_index',
  159. meta: { title: '直播大厅', subSite: true },
  160. component: () => import('../views/live/index.vue'),
  161. },
  162. {
  163. path: '/achieveLive/apply',
  164. name: 'achieveLive_apply',
  165. meta: { title: '直播大厅-申请参展', subSite: true },
  166. component: () => import('../views/achieveLive/apply.vue'),
  167. },
  168. // 数据动态
  169. {
  170. path: '/dynamic/index',
  171. name: 'dynamic_index',
  172. meta: { title: '数据动态', subSite: true },
  173. component: () => import('../views/dynamic/index.vue'),
  174. },
  175. // 技术交流
  176. {
  177. path: '/techolchat/index',
  178. name: 'techolchat_index',
  179. meta: { title: '技术交流', subSite: true },
  180. component: () => import('../views/techolchat/index.vue'),
  181. },
  182. {
  183. path: '/techolchat/product',
  184. name: 'techolchat_product',
  185. meta: { title: '信息发布', subSite: true },
  186. component: () => import('../views/techolchat/product.vue'),
  187. },
  188. {
  189. path: '/userCenter',
  190. name: 'userCenter',
  191. meta: { title: '管理中心' },
  192. component: () => import('../views/userCenter/index.vue'),
  193. },
  194. ...admin,
  195. // 问卷调查
  196. {
  197. path: '/questionnaire/index',
  198. name: 'questionnaire',
  199. meta: { title: '问卷调查' },
  200. component: () => import('../views/questionnaire/index.vue'),
  201. },
  202. // 答问卷调查
  203. {
  204. path: '/questionnaire/answer',
  205. name: 'questionnaire',
  206. meta: { title: '完成问卷调查' },
  207. component: () => import('../views/questionnaire/detail.vue'),
  208. },
  209. // 科技创新能力评价
  210. {
  211. path: '/newteck/index',
  212. name: 'newteck',
  213. meta: { title: '科技创新能力评价' },
  214. component: () => import('../views/newTeck/index.vue'),
  215. },
  216. ],
  217. },
  218. ];
  219. const routes = [...live];
  220. const router = new VueRouter({
  221. mode: 'history',
  222. base: process.env.VUE_APP_ROUTER,
  223. routes,
  224. });
  225. router.beforeEach((to, from, next) => {
  226. document.title = `${to.meta.title} `;
  227. const token = localStorage.getItem('token');
  228. if (to.path == '/userCenter') {
  229. if (!token) {
  230. next('/login');
  231. } else {
  232. let user = jwt.decode(token);
  233. user.type = '4';
  234. store.commit('setUser', user, { root: true });
  235. next();
  236. }
  237. } else {
  238. let user = jwt.decode(token);
  239. store.commit('setUser', user, { root: true });
  240. next();
  241. }
  242. });
  243. export default router;