info.ts 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. import.meta.env.VITE_APP_SDK === "true"
  25. ? [
  26. {
  27. path: "/scene",
  28. name: readyRouteName.scene,
  29. meta: readyRouteMeta.scene,
  30. component: () => import("@/views/scene/scene.vue"),
  31. },
  32. ]
  33. : [
  34. {
  35. path: "/graphic/:mode/:action/:id",
  36. name: readyRouteName.graphic,
  37. meta: readyRouteMeta.graphic,
  38. component: () => import("@/views/graphic/index.vue"),
  39. },
  40. {
  41. path: "/scene",
  42. name: readyRouteName.scene,
  43. meta: readyRouteMeta.scene,
  44. component: () => import("@/views/scene/index.vue"),
  45. },
  46. {
  47. path: "/photos",
  48. name: readyRouteName.photos,
  49. meta: readyRouteMeta.photos,
  50. component: () => import("@/views/photos/index.vue"),
  51. },
  52. {
  53. path: "/accidents",
  54. name: readyRouteName.accidents,
  55. meta: readyRouteMeta.accidents,
  56. component: () => import("@/views/accidents/index.vue"),
  57. },
  58. {
  59. path: "/gena4/:id1/:id2",
  60. name: readyRouteName.gena4,
  61. meta: readyRouteMeta.gena4,
  62. component: () => import("@/views/accidents/print.vue"),
  63. },
  64. {
  65. path: "/roads",
  66. name: readyRouteName.roads,
  67. meta: readyRouteMeta.roads,
  68. component: () => import("@/views/roads/index.vue"),
  69. },
  70. {
  71. path: "/tabulation/:id",
  72. name: readyRouteName.tabulation,
  73. meta: readyRouteMeta.tabulation,
  74. component: () => import("@/views/roads/tabulation.vue"),
  75. },
  76. {
  77. path: "/tables/:name",
  78. name: readyRouteName.tables,
  79. meta: readyRouteMeta.tables,
  80. component: () => import("@/views/tables/index.vue"),
  81. },
  82. {
  83. path: "/demo/:id",
  84. name: readyRouteName.demo,
  85. meta: readyRouteMeta.demo,
  86. component: () => import("@/views/tables/demo.vue"),
  87. },
  88. ];
  89. export type RoutesRef<T extends ModeFlag = any> = ComputedRef<{
  90. list: RoutesRaw<T>;
  91. default: typeof defRouteName;
  92. }>;