import Vue from "vue";
import VueRouter from "vue-router";
import Layouts from "@/pages/layouts/Layouts.vue";
// 解决重复点击同一个路由报错
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function (location) {
  return originalPush.call(this, location).catch((err) => err);
};
Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/home",
  },
  // 首页
  {
    path: "/home",
    component: () => import("@/pages/home/Home.vue"),
  },

  // 快速查看
  {
    path: "/matterList",
    component: Layouts,
    children: [
      {
        path: "",
        component: () => import("@/pages/showpage/MatterList.vue"),
      },
    ],
  },
  // 快速搜索
  {
    path: "/searchpage",
    component: Layouts,
    children: [
      {
        path: "",
        component: () => import("@/pages/searchpage/SearchPage.vue"),
      },
    ],
  },
  // 事项分类
  {
    path: "/matterify",
    component: Layouts,
    children: [
      {
        path: "",
        component: () => import("@/pages/showpage/MatterIfy.vue"),
      },
    ],
  },
  // 材料展示
  {
    path: "/showmaterials",
    component: Layouts,
    children: [
      {
        path: "",
        component: () => import("@/pages/showpage/ShowMaterials.vue"),
      },
    ],
  },
];

const router = new VueRouter({
  routes,
});

export default router;
