123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- import Vue from 'vue';
- import VueRouter from 'vue-router';
- import store from '@/store/index';
- const originalPush = VueRouter.prototype.push;
- VueRouter.prototype.push = function push(location) {
- return originalPush.call(this, location).catch(err => err);
- };
- const jwt = require('jsonwebtoken');
- const list = [
- {
- path: '/market/list',
- name: 'market_list',
- meta: { title: '科技超市' },
- component: () => import('../views/market/list.vue'),
- },
- {
- path: '/techolchat/list',
- name: 'techolchat_list',
- meta: { title: '技术交流' },
- component: () => import('../views/techolchat/list.vue'),
- },
- {
- path: '/news/list',
- name: 'news_list',
- meta: { title: '新闻资讯' },
- component: () => import('../views/news/list.vue'),
- },
- ];
- const admin = [
- {
- path: '/admin/live/science',
- name: 'admin_live_science',
- meta: { title: '科技频道管理中心' },
- component: () => import('../views/admin/live/science.vue'),
- },
- {
- path: '/admin/live/train',
- name: 'admin_live_train',
- meta: { title: '培训问诊管理中心' },
- component: () => import('../views/admin/live/train.vue'),
- },
- {
- path: '/admin/live/achieve',
- name: 'admin_live_achieve',
- meta: { title: '科技成果管理中心' },
- component: () => import('../views/admin/live/achieve.vue'),
- },
- ];
- Vue.use(VueRouter);
- const live = [
- {
- path: '/',
- name: 'index',
- meta: { title: '网站首页' },
- component: () => import('../views/index.vue'),
- },
- {
- path: '/login',
- name: 'login',
- meta: { title: '登录' },
- component: () => import('../views/login.vue'),
- },
- {
- path: '/register',
- name: 'register',
- meta: { title: '注册账号' },
- component: () => import('../views/register.vue'),
- },
- {
- path: '/agreement',
- name: 'agreement',
- meta: { title: '用户注册协议' },
- component: () => import('../views/agreement.vue'),
- },
- {
- path: '/channelLive/index',
- name: 'channelLive_index',
- meta: { title: '直播大厅-科技频道', subSite: true },
- component: () => import('../views/channelLive/index.vue'),
- },
- {
- path: '/trainLive/index',
- name: 'trainLive_index',
- meta: { title: '直播大厅-培训问诊', subSite: true },
- component: () => import('../views/trainLive/index.vue'),
- },
- {
- path: '/personalLive/index',
- name: 'personalLive_index',
- meta: { title: '直播大厅-人才对接', subSite: true },
- component: () => import('../views/personalLive/index.vue'),
- },
- {
- path: '/achieveLive/before',
- name: 'personalLive_before',
- meta: { title: '直播大厅-展会活动页', subSite: true },
- component: () => import('../views/achieveLive/before.vue'),
- },
- {
- path: '/achieveLive/detail',
- name: 'personalLive_detail',
- meta: { title: '直播大厅-展会详情', subSite: true },
- component: () => import('../views/achieveLive/detail.vue'),
- },
- // {
- // path: '/achieveLive/expert/index',
- // name: 'achieveLive_expert',
- // meta: { title: '直播大厅-参展专家', subSite: true },
- // component: () => import('../views/achieveLive/expert/index.vue'),
- // },
- // {
- // path: '/achieveLive/expert/detail',
- // name: 'achieveLive_detail',
- // meta: { title: '直播大厅-对接专家', subSite: true },
- // component: () => import('../views/achieveLive/expert/detail.vue'),
- // },
- // {
- // path: '/achieveLive/product/index',
- // name: 'achieveLive_product',
- // meta: { title: '直播大厅-参展项目', subSite: true },
- // component: () => import('../views/achieveLive/product/index.vue'),
- // },
- // {
- // path: '/achieveLive/product/detail',
- // name: 'achieveLive_detail',
- // meta: { title: '直播大厅-对接项目', subSite: true },
- // component: () => import('../views/achieveLive/product/detail.vue'),
- // },
- {
- path: '/achieveLive/news/detail',
- name: 'achieveLive_news_detail',
- meta: { title: '直播大厅-嘉宾访谈,项目路演', subSite: true },
- component: () => import('../views/achieveLive/news/detail.vue'),
- },
- {
- path: '/website',
- name: 'website',
- component: () => import('../views/website.vue'),
- children: [
- // 新闻资讯
- {
- path: '/news/index',
- name: 'news_index',
- meta: { title: '新闻资讯', subSite: true },
- component: () => import('../views/news/index.vue'),
- },
- // 科技超市
- {
- path: '/market/index',
- name: 'market_index',
- meta: { title: '科技超市', subSite: true },
- component: () => import('../views/market/index.vue'),
- },
- ...list,
- // 直播大厅
- {
- path: '/live/index',
- name: 'live_index',
- meta: { title: '直播大厅', subSite: true },
- component: () => import('../views/live/index.vue'),
- },
- {
- path: '/achieveLive/apply',
- name: 'achieveLive_apply',
- meta: { title: '直播大厅-申请参展', subSite: true },
- component: () => import('../views/achieveLive/apply.vue'),
- },
- // 数据动态
- {
- path: '/dynamic/index',
- name: 'dynamic_index',
- meta: { title: '数据动态', subSite: true },
- component: () => import('../views/dynamic/index.vue'),
- },
- // 技术交流
- {
- path: '/techolchat/index',
- name: 'techolchat_index',
- meta: { title: '技术交流', subSite: true },
- component: () => import('../views/techolchat/index.vue'),
- },
- {
- path: '/techolchat/product',
- name: 'techolchat_product',
- meta: { title: '信息发布', subSite: true },
- component: () => import('../views/techolchat/product.vue'),
- },
- {
- path: '/userCenter',
- name: 'userCenter',
- meta: { title: '管理中心' },
- component: () => import('../views/userCenter/index.vue'),
- },
- ...admin,
- // 问卷调查
- {
- path: '/questionnaire/index',
- name: 'questionnaire',
- meta: { title: '问卷调查' },
- component: () => import('../views/questionnaire/index.vue'),
- },
- // 答问卷调查
- {
- path: '/questionnaire/answer',
- name: 'questionnaire',
- meta: { title: '完成问卷调查' },
- component: () => import('../views/questionnaire/detail.vue'),
- },
- // 科技创新能力评价
- {
- path: '/newteck/index',
- name: 'newteck',
- meta: { title: '科技创新能力评价' },
- component: () => import('../views/newTeck/index.vue'),
- },
- ],
- },
- ];
- const routes = [...live];
- const router = new VueRouter({
- mode: 'history',
- base: process.env.VUE_APP_ROUTER,
- routes,
- });
- router.beforeEach((to, from, next) => {
- document.title = `${to.meta.title} `;
- const token = localStorage.getItem('token');
- if (to.path == '/userCenter') {
- if (!token) {
- next('/login');
- } else {
- let user = jwt.decode(token);
- user.type = '4';
- store.commit('setUser', user, { root: true });
- next();
- }
- } else {
- let user = jwt.decode(token);
- store.commit('setUser', user, { root: true });
- next();
- }
- });
- export default router;
|