index.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { RouteRecordRaw, createRouter, createWebHistory } from "vue-router";
  2. import { useStore } from "@/store/index";
  3. import { createRouterGuards } from "./routerGuards";
  4. export const routes: RouteRecordRaw[] = [
  5. {
  6. path: "/",
  7. redirect: "/login",
  8. },
  9. {
  10. name: "login",
  11. path: "/login",
  12. component: () => import("../pages/login.vue"),
  13. },
  14. {
  15. name: "register",
  16. path: "/register",
  17. component: () => import("../pages/register.vue"),
  18. },
  19. {
  20. name: "home",
  21. path: "/home",
  22. component: () => import("../pages/home.vue"),
  23. children: [
  24. // {
  25. // name: 'thread',
  26. // path: '/thread',
  27. // component: () => import("../pages/thread/thread.vue")
  28. // },
  29. {
  30. name: 'analysis',
  31. path: '/analysis',
  32. component: () => import("../pages/analysis/index.vue")
  33. },
  34. ],
  35. },
  36. {
  37. name: "test",
  38. path: "/test",
  39. component: () => import("../pages/test/index.vue"),
  40. },
  41. {
  42. name: "testEcharts",
  43. path: "/testEcharts",
  44. component: () => import("../pages/test/echarts.vue"),
  45. },
  46. ];
  47. const router = createRouter({
  48. scrollBehavior: () => ({ left: 0, top: 0 }),
  49. history: createWebHistory(),
  50. routes,
  51. });
  52. const { beforeEach } = createRouterGuards(router);
  53. console.log('添加好后的路由', beforeEach)
  54. router.beforeEach(beforeEach);
  55. export default router;