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

import { routes } from './modules/index';

Vue.use(VueRouter);

const createRouter = () =>
  new VueRouter({
    // mode: 'history',
    scrollBehavior: () => ({ y: 0 }),
    routes,
  });

const router = createRouter();

// 重置路由
export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher;
}

export default router;
