import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const routes = [
  {
    path: "/",
    component: () => import('@/views/index'),
  },

  {
    path:'/admin/login',
    name:'Login',
    meta: {
      title: '系统登录'
    },
    component: () => import("../views/login/index.vue")
  },
  {
    path: "/admin",
    component: () => import('@/views/layout/index.vue'),
    children: [
     
    ]
  },
 
]

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

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title;
  }
  next();
})

router.afterEach((to, from) => {

});

export default router
