router.js 2.5 KB
Newer Older
!阳仔's avatar
!阳仔 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
//  index.js 文件内容
import Vue from 'vue';
import VueRouter from 'vue-router';
import {isMobile} from "@/common/util"
//  定义路由, 创建路由配置项
const routes = [
    {
      path: '/',
      name: 'pcmap',
      component: () => import('./view/pc/home.vue'),
      beforeEnter (to, from, next) {
        if (!isMobile()) {
          next();
        } else {
          next({
            path:'/m' ,
           
          });
        }
      },
      children: [
        {
          path: '',
          redirect: 'force'
        },
        {
          path: 'force',
          component: () => import('./view/pc/force.vue'),
          meta: {
!阳仔's avatar
!阳仔 已提交
30
            title: '全网博主原力月度排名 - 开源实验室',
!阳仔's avatar
!阳仔 已提交
31
            navTitle:'原力排名',
!阳仔's avatar
!阳仔 已提交
32
            name:'全网博主原力月度排名',
!阳仔's avatar
!阳仔 已提交
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
            pageSpm: '1011.2266'
          }
        },
        {
          path: 'fans',
          component: () => import('./view/pc/fans.vue'),
          meta: {
            title: '全网博主铁粉排名 - 开源实验室',
            name:'全网博主铁粉排名',
            navTitle:'铁粉排名',
            pageSpm: '1011.2266'
          }
        },
      ]
    },
    {
      path: '/m',
      name: 'pcmap',
      component: () => import('./view/wap/home.vue'),
      beforeEnter (to, from, next) {
        if (isMobile()) {
          next();
        } else {
          next({
            path:'/' ,
          });
        }
      },
      children: [
        {
          path: '',
          redirect: 'force'
        },
        {
          path: 'force',
          component: () => import('./view/wap/force.vue'),
          meta: {
!阳仔's avatar
!阳仔 已提交
70
            title: '全网博主原力月度排名 - 开源实验室',
!阳仔's avatar
!阳仔 已提交
71
            navTitle:'原力排名',
!阳仔's avatar
!阳仔 已提交
72
            name:'全网博主原力月度排名',
!阳仔's avatar
!阳仔 已提交
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
            pageSpm: '1011.2266'
          }
        },
        {
          path: 'fans',
          component: () => import('./view/wap/fans.vue'),
          meta: {
            title: '全网博主铁粉排名 - 开源实验室',
            navTitle:'铁粉排名',
            name:'全网博主铁粉排名',
            pageSpm: '1011.2266'
          }
        },
      ]
    },  
]
Vue.use(VueRouter);
//  创建路由对象
const router = new VueRouter({
  base: `/csdn-datav`,
  mode: 'history',
  routes
})
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})
//  把路由对象作为模块导出
export default router;