
import admin from './module/admin.js'
import qiankun from './qiankun'
import store from '@/store'


const routes = [
  ...qiankun,
  ...admin
]

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

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

// 路由守卫
router.beforeEach((to, from, next) => {
  Vue.prototype.$beforeRouter(to, from, next, store.state.env, Vue)
})

export default router
