import { createRouter, createWebHistory } from "vue-router"; const routes = [ { path: "/login", name: "login", component: () => import("@/pages/login/index.vue"), meta: { title: "登录", }, }, { path: "/", component: () => import("@/layouts/MainLayout.vue"), redirect: "/overview", children: [ { path: "overview", name: "overview", component: () => import("@/pages/home/overview.vue"), meta: { title: "项目概览", }, }, { path: "project-detail", name: "projectDetail", component: () => import("@/pages/empty/index.vue"), meta: { title: "项目明细", }, }, { path: "one-map", name: "oneMap", component: () => import("@/pages/empty/index.vue"), meta: { title: "一张图", }, }, { path: "overall-plan", name: "overallPlan", component: () => import("@/pages/empty/index.vue"), meta: { title: "总体计划", }, }, { path: "permission", name: "permission", component: () => import("@/pages/empty/index.vue"), meta: { title: "权限管理", }, }, ], }, { path: "/:pathMatch(.*)*", redirect: "/overview", }, ]; const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), routes, scrollBehavior() { return { left: 0, top: 0 }; }, }); router.afterEach((to) => { const defaultTitle = "前期研究前置报告计划管理系统"; const title = to.meta && to.meta.title ? to.meta.title : defaultTitle; document.title = title; }); export default router;