123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- import Vue from 'vue';
- import VueRouter from 'vue-router';
- import store from '@/store/index';
- Vue.use(VueRouter);
- const routes = [
- // 首页
- {
- path: '/',
- name: 'index',
- meta: { title: '首页', isleftarrow: false },
- component: () => import('../views/index.vue'),
- },
- // 直播大厅
- {
- path: '/live/index',
- name: 'live_index',
- meta: { title: '直播大厅', isleftarrow: false },
- component: () => import('../views/live/index.vue'),
- },
- {
- path: '/live/detail',
- name: 'live_detail',
- meta: { title: '直播详情', isleftarrow: true },
- component: () => import('../views/live/detail.vue'),
- },
- // 科技超市
- {
- path: '/market/index',
- name: 'market_index',
- meta: { title: '科技超市', isleftarrow: false },
- component: () => import('../views/market/index.vue'),
- },
- {
- path: '/market/productDetail',
- name: 'market_productDetail',
- meta: { title: '科技超市详情', isleftarrow: true },
- component: () => import('../views/market/productDetail.vue'),
- },
- {
- path: '/market/exportDetail',
- name: 'market_exportDetail',
- meta: { title: '专家详情', isleftarrow: true },
- component: () => import('../views/market/exportDetail.vue'),
- },
- // 创新服务
- {
- path: '/service/index',
- name: 'service_index',
- meta: { title: '创新服务', isleftarrow: false },
- component: () => import('../views/service/index.vue'),
- },
- {
- path: '/service/detail',
- name: 'service_detail',
- meta: { title: '创新服务', isleftarrow: true },
- component: () => import('../views/service/detail.vue'),
- },
- // 个人中心
- {
- path: '/user/index',
- name: 'user_index',
- meta: { title: '个人中心', isleftarrow: false },
- component: () => import('../views/user/index.vue'),
- },
- // 用户-我的发布
- {
- path: '/userCenter/myProduct/index',
- name: 'myProduct_index',
- meta: { title: '我的发布', isleftarrow: true },
- component: () => import('../views/userCenter/myProduct/index.vue'),
- },
- // 用户-事项管理
- {
- path: '/userCenter/matter/index',
- name: 'matter_index',
- meta: { title: '事项管理', isleftarrow: true },
- component: () => import('../views/userCenter/matter/index.vue'),
- },
- // 用户-展会管理
- {
- path: '/userCenter/dock/index',
- name: 'dock_index',
- meta: { title: '展会管理', isleftarrow: true },
- component: () => import('../views/userCenter/dock/index.vue'),
- },
- // 用户-基本信息
- {
- path: '/userCenter/user/index',
- name: 'user_index',
- meta: { title: '基本信息', isleftarrow: true },
- component: () => import('../views/userCenter/user/index.vue'),
- },
- // 用户-退出登录
- {
- path: '/userCenter/out/index',
- name: 'user_index',
- meta: { title: '个人中心', isleftarrow: true },
- component: () => import('../views/userCenter/out/index.vue'),
- },
- // 管理用户菜单
- {
- path: '/adminCenter/user/index',
- name: 'adminCenter_user_index',
- meta: { title: '用户管理', isleftarrow: true },
- component: () => import('../views/adminCenter/user/index.vue'),
- },
- {
- path: '/adminCenter/user/detail',
- name: 'adminCenter_user_detail',
- meta: { title: '审核/查看用户', isleftarrow: true },
- component: () => import('../views/adminCenter/user/detail.vue'),
- },
- {
- path: '/adminCenter/duijiehui/index',
- name: 'adminCenter_duijiehui_index',
- meta: { title: '展会管理', isleftarrow: true },
- component: () => import('../views/adminCenter/duijiehui/index.vue'),
- },
- {
- path: '/adminCenter/duijiehui/add',
- name: 'adminCenter_duijiehui_add',
- meta: { title: '展会信息管理', isleftarrow: true },
- component: () => import('../views/adminCenter/duijiehui/add.vue'),
- },
- {
- path: '/adminCenter/enterpriseProduct/index',
- name: 'adminCenter_enterpriseProduct',
- meta: { title: '审核管理', isleftarrow: true },
- component: () => import('../views/adminCenter/enterpriseProduct/index.vue'),
- },
- {
- path: '/adminCenter/enterpriseProduct/detail',
- name: 'adminCenter_enterpriseProduct',
- meta: { title: '产品信息管理', isleftarrow: true },
- component: () => import('../views/adminCenter/enterpriseProduct/detail.vue'),
- },
- {
- path: '/adminCenter/transaction/index',
- name: 'adminCenter_transaction',
- meta: { title: '交易审核管理', isleftarrow: true },
- component: () => import('../views/adminCenter/transaction/index.vue'),
- },
- {
- path: '/adminCenter/transaction/detail',
- name: 'adminCenter_transaction',
- meta: { title: '交易信息管理', isleftarrow: true },
- component: () => import('../views/adminCenter/transaction/detail.vue'),
- },
- // 登录
- {
- path: '/login',
- name: 'login',
- meta: { title: '登录', isleftarrow: true },
- component: () => import('../views/login.vue'),
- },
- ];
- const router = new VueRouter({
- mode: 'history',
- base: process.env.NODE_ENV === 'development' ? '' : process.env.VUE_APP_ROUTER,
- routes,
- });
- router.beforeEach(async (to, form, next) => {
- if (to.name == 'user_index') {
- let res = await store.dispatch('login/toGetUser');
- if (res) {
- next();
- } else {
- next({ name: 'login' });
- }
- } else {
- let res = await store.dispatch('login/toGetUser');
- next();
- }
- });
- const originalPush = VueRouter.prototype.push;
- VueRouter.prototype.push = function push(location, onResolve, onReject) {
- if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject);
- return originalPush.call(this, location).catch(err => err);
- };
- export default router;
|