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

Vue.use(VueRouter)

const routes = []

export function initRoute(routes, base = "/", mode = "hash") {
  return new VueRouter({
    mode: mode,
    base: base,
    routes
  });
}

// 解决 `element ui` 导航栏重复点菜单报错问题
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};

export default initRoute(routes)
