
import { module, blank } from './module/index.js'
import vue from 'vue'

// vue跳转相同路径报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    meta: { title: '布局'},
    name: 'layout',
    component: () => import('@/layout/Index'),
    children: [
      {
        path: '/userInfo',
        meta: { title: '个人信息', isMenu: false},
        component: SANHUI.UserInfo
      },
      {
        path: '/405',
        meta: { title: '405', isLogin: false},
        component: SANHUI.Error405
      },
      ...module,
    ]
  },
  ...blank,
  {
    path: '/login',
    meta: { title: '登录', isLogin: false},
    component: SANHUI.Login
  },
  {
    path: '*',
    meta: { title: '404', isLogin: false},
    component: SANHUI.Error404
  }
]
const router = new VueRouter({
  // mode: 'history',
  // base: process.env.BASE_URL,
  routes
})
// 路由守卫
router.beforeEach((to, from, next) => {
  vue.prototype.$beforeRouter(to, from, next, process.env, Vue)
})


export default router
