import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '@/views/HomeView.vue'

Vue.use(VueRouter)

// 获取原型对象push函数
const originalPush = VueRouter.prototype.push

// 获取原型对象replace函数
const originalReplace = VueRouter.prototype.replace

// 修改原型对象中的push函数
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

// 修改原型对象中的replace函数
VueRouter.prototype.replace = function replace(location) {
  return originalReplace.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    name: 'HomeView',
    meta: {
      title: '首页',
      icon: 'home-o',
      isTabBarMenu: true,
      keepAlive: true,
      showNavBar: true
    },
    component: HomeView
  },
  {
    path: '/caricature',
    name: 'CaricatureView',
    meta: {
      title: '漫画',
      icon: 'home-o',
      isTabBarMenu: true,
      keepAlive: true,
      showNavBar: true
    },
    component: () => import('../views/CaricatureView.vue')
  },
  {
    path: '/active',
    name: 'ActiveView',
    meta: {
      title: '活动',
      icon: 'home-o',
      isTabBarMenu: true,
      keepAlive: true,
      showNavBar: true
    },
    component: () => import('../views/ActiveView.vue')
  },
  {
    path: '/live',
    name: 'LiveView',
    meta: {
      title: '直播',
      icon: 'home-o',
      isTabBarMenu: true,
      keepAlive: true,
      showNavBar: true
    },
    component: () => import('../views/LiveView.vue')
  },
  {
    path: '/mine',
    name: 'MineView',
    meta: {
      title: '我的',
      icon: 'home-o',
      isTabBarMenu: true,
      keepAlive: true,
      showNavBar: true
    },
    component: () => import('../views/MineView.vue')
  },
  {
    path: '/detail',
    name: 'DetailView',
    meta: {
      title: '详情',
      isTabBarMenu: false,
      showNavBar: true
    },
    component: () => import('../views/DetailView.vue')
  }
]

const router = new VueRouter({
  // mode: 'history',
  // base: process.env.BASE_URL,
  routes
})

export default router