import { RouteRecordRaw, createRouter, createWebHistory } from "vue-router"; import { useStore } from "@/store/index"; import { createRouterGuards } from "./routerGuards"; export const routes: RouteRecordRaw[] = [ { path: "/", redirect: "/login", }, { name: "login", path: "/login", component: () => import("../pages/login.vue"), }, { name: "register", path: "/register", component: () => import("../pages/register.vue"), }, { name: "home", path: "/home", component: () => import("../pages/home.vue"), children: [ // { // name: 'thread', // path: '/thread', // component: () => import("../pages/thread/thread.vue") // }, { name: 'analysis', path: '/analysis', component: () => import("../pages/analysis/index.vue") }, ], }, { name: "test", path: "/test", component: () => import("../pages/test/index.vue"), }, { name: "testEcharts", path: "/testEcharts", component: () => import("../pages/test/echarts.vue"), }, ]; const router = createRouter({ scrollBehavior: () => ({ left: 0, top: 0 }), history: createWebHistory(), routes, }); const { beforeEach } = createRouterGuards(router); console.log('添加好后的路由', beforeEach) router.beforeEach(beforeEach); export default router;