store.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { Ref, ref } from "vue";
  2. import { StoreData } from "@/core/store/store";
  3. import { PaperKey } from "../components/slide/actions";
  4. import { overviewId, params, tabulationId } from "../env";
  5. import { DrawItem } from "@/core/components";
  6. import { IRect } from "konva/lib/types";
  7. import { ShapeType } from "@/index";
  8. export {
  9. tableCoverKey,
  10. tableCoverScaleKey,
  11. tableTableKey,
  12. tableTitleKey,
  13. tableCompassKey,
  14. mapImageKey,
  15. tableCoverWidth,
  16. tableCoverHeight,
  17. } from "../constant";
  18. export type TabCover = {
  19. url: string;
  20. width: number;
  21. height: number;
  22. proportion: {
  23. scale: number;
  24. unit: string;
  25. };
  26. syncItems?: (DrawItem<ShapeType> & { rect: IRect; desc: string })[];
  27. };
  28. export const overviewData = ref() as Ref<{
  29. title?: string;
  30. cover?: string;
  31. store: StoreData;
  32. viewport: number[] | null;
  33. }>;
  34. export const refreshOverviewData = () => {
  35. return window.platform.getOverviewData(overviewId.value).then((data: any) => {
  36. overviewData.value = data;
  37. });
  38. };
  39. export const tabulationData = ref() as Ref<{
  40. store: StoreData;
  41. cover: TabCover | null;
  42. title?: string;
  43. paperKey: PaperKey;
  44. isAutoGen: boolean;
  45. viewport: number[] | null;
  46. mapUrl: string | null;
  47. high?: number;
  48. width?: number;
  49. }>;
  50. export const refreshTabulationData = () => {
  51. return window.platform
  52. .getTabulationData(tabulationId.value)
  53. .then((data: any) => {
  54. tabulationData.value = data
  55. });
  56. };
  57. export const sysError = ref<{ code: number }>();
  58. window.platform.bus.on("requestError", (val: any) => {
  59. sysError.value = val;
  60. });