info.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { modeFlags, ModeFlag } from "@/store/sys";
  2. import { ComputedRef } from "vue";
  3. import { RouteRecordRaw } from "vue-router";
  4. import {
  5. RouteNameRaw,
  6. RouteMetaRaw,
  7. readyRouteMeta,
  8. readyRouteName,
  9. defRouteName,
  10. } from "./constant";
  11. export type RouteAtom<
  12. T extends ModeFlag = any,
  13. key = RouteNameRaw<T>[keyof RouteNameRaw<T>]
  14. > = {
  15. path: string;
  16. name: key;
  17. meta: key extends keyof RouteMetaRaw<T> ? RouteMetaRaw<T>[key] : never;
  18. component: RouteRecordRaw["component"];
  19. redirect?: string;
  20. children?: RoutesRaw<T>;
  21. };
  22. export type RoutesRaw<T extends ModeFlag = any> = RouteAtom<T>[];
  23. export const writeRoutesRaw: RoutesRaw<typeof modeFlags.LOGIN> = [
  24. {
  25. path: "/graphic/:mode/:action/:id",
  26. name: readyRouteName.graphic,
  27. meta: readyRouteMeta.graphic,
  28. component: () => import("@/views/graphic/index.vue"),
  29. },
  30. {
  31. path: "/scene",
  32. name: readyRouteName.scene,
  33. meta: readyRouteMeta.scene,
  34. component: () => import("@/views/scene/index.vue"),
  35. },
  36. {
  37. path: "/photos",
  38. name: readyRouteName.photos,
  39. meta: readyRouteMeta.photos,
  40. component: () => import("@/views/photos/index.vue"),
  41. },
  42. {
  43. path: "/accidents",
  44. name: readyRouteName.accidents,
  45. meta: readyRouteMeta.accidents,
  46. component: () => import("@/views/accidents/index.vue"),
  47. },
  48. {
  49. path: "/gena4/:id1/:id2",
  50. name: readyRouteName.gena4,
  51. meta: readyRouteMeta.gena4,
  52. component: () => import("@/views/accidents/index.vue"),
  53. },
  54. {
  55. path: "/roads",
  56. name: readyRouteName.roads,
  57. meta: readyRouteMeta.roads,
  58. component: () => import("@/views/roads/index.vue"),
  59. },
  60. {
  61. path: "/tabulation/:id",
  62. name: readyRouteName.tabulation,
  63. meta: readyRouteMeta.tabulation,
  64. component: () => import("@/views/roads/tabulation.vue"),
  65. },
  66. ];
  67. export type RoutesRef<T extends ModeFlag = any> = ComputedRef<{
  68. list: RoutesRaw<T>;
  69. default: typeof defRouteName;
  70. }>;