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: "/",
    component: () => import("@/pages/home/Home.vue"),
    meta: {
      name: "首页",
    },
  },

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

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

export default router;
