|
@@ -1,28 +1,183 @@
|
|
|
-import Vue from "vue";
|
|
|
-import VueRouter from "vue-router";
|
|
|
-import Home from "../views/Home.vue";
|
|
|
-
|
|
|
+import Vue from 'vue';
|
|
|
+import VueRouter from 'vue-router';
|
|
|
+import store from '@/store/index';
|
|
|
+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 routes = [
|
|
|
+const live = [
|
|
|
{
|
|
|
- path: "/",
|
|
|
- name: "Home",
|
|
|
- component: Home
|
|
|
+ path: '/',
|
|
|
+ name: 'index',
|
|
|
+ meta: { title: '网站首页' },
|
|
|
+ component: () => import('../views/index.vue'),
|
|
|
},
|
|
|
{
|
|
|
- path: "/about",
|
|
|
- name: "About",
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- component: () =>
|
|
|
- import( "../views/About.vue")
|
|
|
- }
|
|
|
+ path: '/login',
|
|
|
+ name: 'login',
|
|
|
+ meta: { title: '登录' },
|
|
|
+ component: () => import('../views/login.vue'),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: '/register',
|
|
|
+ name: 'register',
|
|
|
+ meta: { title: '注册账号' },
|
|
|
+ component: () => import('../views/register.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: '/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,
|
|
|
+ ],
|
|
|
+ },
|
|
|
];
|
|
|
-
|
|
|
+const routes = [...live];
|
|
|
const router = new VueRouter({
|
|
|
- routes
|
|
|
+ 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;
|