import { createRouter, createWebHashHistory } from "vue-router";
import routersModules from "./modules";

export const constantRoutesBase = [
  {
    path: "/",
    redirect: "/home",
    meta: { title: "首页", tagRoute: "GIP" },
    children: [
      {
        path: "home",
        name: "home",
        meta: { title: "首页", tagRoute: "GIP" },
        component: () => import("@/views/Home/index.vue"),
      },
      {
        path: "articleDetails",
        name: "articleDetails",
        meta: { title: "文章信息", tagRoute: "GIP" },
        component: () => import("@/components/article/public.vue"),
      },
    ],
  },
];
export const constantRoutes = [...constantRoutesBase, ...routersModules];
const router = createRouter({
  // history: createWebHistory(),
  history: createWebHashHistory(),
  routes: constantRoutes,
  scrollBehavior(to, from, savedPosition) {
    if (!savedPosition) {
      savedPosition = Object.assign({ top: 0 });
    }
    return savedPosition;
  },
});

export default router;
