bill пре 2 година
родитељ
комит
4d174287f1
4 измењених фајлова са 14 додато и 5 уклоњено
  1. 1 0
      src/graphic/Layer.js
  2. 5 3
      src/hook/useGraphic.ts
  3. 4 2
      src/views/drawGraphic/index.vue
  4. 4 0
      vite.config.ts

+ 1 - 0
src/graphic/Layer.js

@@ -22,6 +22,7 @@ import VectorType from "./enum/VectorType";
 import { mathUtil } from "./Util/MathUtil";
 import History from "./History/History";
 import { keyService } from "./Service/KeyService";
+import mitt from "mitt";
 
 export default class Layer extends mitt {
   constructor(canvas) {

+ 5 - 3
src/hook/useGraphic.ts

@@ -1,8 +1,10 @@
 import { ref } from "vue";
-import { structureDraw } from "../graphic/index.js";
+import type { structureDraw } from "../graphic/index.js";
 
 export const drawRef = ref<ReturnType<typeof structureDraw>>();
 
-export const setCanvas = (canvas: HTMLCanvasElement) => {
-  drawRef.value = structureDraw(canvas);
+export const setCanvas = async (canvas: HTMLCanvasElement) => {
+  await import("../graphic/index.js").then((model) => {
+    drawRef.value = model.structureDraw(canvas);
+  });
 };

+ 4 - 2
src/views/drawGraphic/index.vue

@@ -39,8 +39,10 @@ onMounted(() => {
   setCanvas(drawCanvasRef.value);
 
   watchEffect(() => {
-    drawRef.value.control.currentUI = activeMenu.value as any;
-    drawRef.value.control.updateEventNameForSelectUI();
+    if (drawRef.value) {
+      drawRef.value.control.currentUI = activeMenu.value as any;
+      drawRef.value.control.updateEventNameForSelectUI();
+    }
   });
 });
 

+ 4 - 0
vite.config.ts

@@ -28,6 +28,10 @@ export default async ({ mode }) => {
   }
 
   return defineConfig({
+    mode,
+    build: {
+      sourcemap: true,
+    },
     resolve: {
       alias: {
         "@": path.resolve(__dirname, "src"),