Переглянути джерело

Merge branch 'master' of http://192.168.0.115:3000/bill/drawing-board

bill 1 рік тому
батько
коміт
8ca62091d9

+ 1 - 1
src/board/env.ts

@@ -1 +1 @@
-export const DEV = true;
+export const DEV = false;

+ 3 - 4
src/board/packages/container.ts

@@ -1,4 +1,4 @@
-import { watch, watchEffect } from "vue";
+import { watch } from "vue";
 import { Attrib, ShapeType } from "../type";
 import { Layer } from "konva/lib/Layer";
 import { Entity, EntityProps, EntityType } from "./entity";
@@ -92,8 +92,7 @@ export class Container<
       this.incFactorys[key] = incEntitysFactoryGenerate(
         types[key],
         this,
-        () => {},
-        true
+        () => {}
       );
     }
   }
@@ -125,7 +124,7 @@ export class Container<
         return result;
       },
       this.diffRedraw.bind(this),
-      { immediate: true, flush: "pre" }
+      { immediate: true, flush: "sync" }
     );
   }
 

+ 0 - 1
src/board/packages/whole-line/editable/pen-whole-line.ts

@@ -197,7 +197,6 @@ export class PenEditWholeLine<
         autoClose: this.autoClose,
         config: this.attrib,
         changePolygon: (pid: string) => {
-          console.error("changePolygon", pid);
           this.editPolygonId.value = pid;
         },
         quitHandler: () => {

+ 0 - 1
src/board/packages/whole-line/service/index.ts

@@ -1,7 +1,6 @@
 export * from "./constant";
 export * from "./whole-line-base";
 export * from "./whole-line-tear-merge";
-export * from "./whole-line-normal";
 export * from "./whole-line-mouse";
 export * from "./whole-line-edit";
 export * from "./whole-line-helper";

+ 17 - 15
src/board/packages/whole-line/service/whole-line-edit.ts

@@ -162,23 +162,25 @@ export const penWholeLinePoygonsEdit = <
       }
     }
     const polygonPoints = getWholeLinePolygonPoints(config, polyginAttrib.id);
-    let position: number[];
-    if (adsorbRadius) {
-      const points = polygonPoints.map(({ x, y }) => [x, y]);
-      if (prevId) {
-        const prev = getWholeLinePoint(config, prevId);
-        points.push([prev.x, prev.y]);
+    if (!pointAttrib) {
+      let position: number[];
+      if (adsorbRadius) {
+        const points = polygonPoints.map(({ x, y }) => [x, y]);
+        if (prevId) {
+          const prev = getWholeLinePoint(config, prevId);
+          points.push([prev.x, prev.y]);
+        }
+        position = getAdsorbPosition({
+          tree,
+          pixel,
+          radius: adsorbRadius,
+          points,
+        });
+      } else {
+        position = tree.getRealFromStage(pixel);
       }
-      position = getAdsorbPosition({
-        tree,
-        pixel,
-        radius: adsorbRadius,
-        points,
-      });
-    } else {
-      position = tree.getRealFromStage(pixel);
+      pointAttrib = pointAttribFactory(position) as P & Attrib;
     }
-    pointAttrib = pointAttribFactory(position) as P & Attrib;
 
     const curNdx = polygonPoints.findIndex(({ id }) => id === pointAttrib.id);
     const isClose = curNdx === 0 && (!autoClose || polygonPoints.length >= 3);

+ 1 - 1
src/board/packages/whole-line/service/whole-line-helper.ts

@@ -13,7 +13,7 @@ import {
 } from "./whole-line-edit";
 import addMouseIco from "../../../shared/cursor/pic_pen_a.ico";
 import delMouseIco from "../../../shared/cursor/pic_pen_r.ico";
-import { getAbsoluteTransform, getRealAbsoluteSize } from "../../../shared";
+import { getRealAbsoluteSize } from "../../../shared";
 import { lineShapeFactory, pointShapeFactory } from "../style";
 import { Layer } from "konva/lib/Layer";
 import { Group } from "konva/lib/Group";

+ 0 - 20
src/board/packages/whole-line/service/whole-line-normal.ts

@@ -1,20 +0,0 @@
-import { polygonCounterclockwise } from "../../../shared/math";
-import { WholeLineAttrib } from "../view/whole-line";
-
-export const normalWholeLinePolygon = (
-  config: WholeLineAttrib,
-  polygonId: string
-) => {
-  // const polygon = config.polygons.find(({ id }) => id === polygonId);
-  // if (!polygon) return null;
-  // const points = polygon.points
-  //   .map((id) => config.points.find((point) => point.id === id))
-  //   .filter((point) => !!point);
-  // const flatPoints = points.map(({ x, y }) => [x, y]);
-  // if (!polygonCounterclockwise(flatPoints)) {
-  //   polygon.points.reverse();
-  // }
-  // // 形成闭合,需要确保整体逆时针方向,如果不是则修正
-  // if (points[0] === points[points.length - 1]) {
-  // }
-};

+ 1 - 1
src/board/plugins/history-plugin.ts

@@ -1,4 +1,4 @@
-import { reactive, watchEffect } from "vue";
+import { reactive } from "vue";
 import { Container } from "../packages";
 import { History } from "stateshot";
 import { inRevise } from "../shared";

+ 0 - 1
src/board/shared/adsorb.ts

@@ -10,7 +10,6 @@ import {
   getVerticaLineDire,
 } from "./math";
 import { MathUtils } from "three";
-import { getRealAbsoluteSize } from "./shape-helper";
 
 type AdsorbBaseProps = { tree: Container; position: number[] };
 

+ 1 - 2
src/board/shared/entity-utils.ts

@@ -57,8 +57,7 @@ export const incEntitysFactoryGenerate = <
 >(
   Type: C,
   parent?: Entity<any, any>,
-  extra?: (self: InstanceType<C>) => void,
-  dev = false
+  extra?: (self: InstanceType<C>) => void
 ) => {
   let oldAttribs: T[] = [];
 

+ 3 - 1
src/board/shared/shape-mose.ts

@@ -5,7 +5,7 @@ import { Group } from "konva/lib/Group";
 import { getAbsoluteTransform } from "./shape-helper";
 import { KonvaEventObject } from "konva/lib/Node";
 
-export const openShapeMouseStyles = <T extends Shape | Group, R>(
+export const openShapeMouseStyles = <T extends Shape | Group>(
   shape: T,
   styles: ShapeStyles,
   namespace = "mouse-style"
@@ -56,12 +56,14 @@ export const openShapeMouseStyles = <T extends Shape | Group, R>(
 
       setTimeout(() => {
         const stage = shape.getStage();
+        if (!stage) return;
         stage.on(`click.${namespace}${shape.id()}`, (evt) => {
           if (evt.target !== shape) {
             active = false;
             mouseHandler(evt);
           }
           setTimeout(() => {
+            if (!stage) return;
             stage.off(`click.${namespace}${shape.id()}`);
           });
         });