import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
import Home from "./view-detail";
import Notfind from "../view/notfind";

const routes: RouteRecordRaw[] = [
  {
    path: "/",
    component: Home,
  },
  {
    path: "/product-img",
    component: () => import("/src/view/transfer-to-img/index"),
  },
  {
    path: "/evaluat-report",
    component: () => import("./view-evaluat-report/index"),
  },
  {
    path: "/preview",
    component: () => import("./view-preview/index"),
  },
  {
    path: "/view-figner",
    component: () => import("./view-figner/index"),
  },
  {
    path: "/simple-detail", // 简单的一行谱页面
    component: () => import("./simple-detail/index"),
  },
  {
    path: "/:pathMatch(.*)*",
    component: Notfind,
    meta: {
      title: "404 Not Fund",
    },
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title as string;
  }
  next();
});

export default router;
