bill 7 місяців тому
батько
коміт
1f84423da1

+ 5 - 1
src/app/liantong/example/index.vue

@@ -16,7 +16,7 @@
 
     <template v-if="activeEntity">
       <ElButton @click="activeEntity.copy({ count: 5 })"> 向右复制5个 </ElButton>
-      <ElButton @click="activeEntity.split('x')"> 上下拆分 </ElButton>
+      <ElButton @click="splitHandler"> 上下拆分 </ElButton>
       <ElButton @click="activeEntity.split('y')"> 左右拆分 </ElButton>
       <ElButton @click="activeEntity.setSize({ w: 1, h: 1 })"> 设置大小 </ElButton>
       <ElButton @click="activeEntity.del()"> 删除 </ElButton>
@@ -65,6 +65,10 @@ type Board = ReturnType<typeof createBoard>;
 const board = createBoard();
 board.bound.setRetainScale(true);
 
+const splitHandler = () => {
+  activeEntity.value.split("x");
+  board.blurPoi();
+};
 setTimeout(() => {
   // board.setData({ rooms: rooms });
   console.log(storeData);

+ 2 - 3
src/board/packages/poi/edit-poi.ts

@@ -10,13 +10,11 @@ import { Group } from "konva/lib/Group";
 import { Rect } from "konva/lib/shapes/Rect";
 import { Transform } from "konva/lib/Util";
 import { MathUtils } from "three";
-import { nextTick } from "vue";
 import { Attrib } from "../../type";
 
 export class EditPoi<T extends PoiAttrib = PoiAttrib> extends Poi<T> {
   initShape() {
     const group = super.initShape() as Group;
-    const rect = group.findOne<Rect>(".rect");
     const tf = new Transformer({
       visible: false,
       name: "tf" + this.attrib.id,
@@ -174,7 +172,7 @@ export class EditPoi<T extends PoiAttrib = PoiAttrib> extends Poi<T> {
     const items = this.container.getSameLevelData(this) as Attrib[];
     const newAttrib = {
       ...this.attrib,
-      id: generateId(items),
+      id: Date.now().toString(),
     };
 
     const rect = (this.shape as Group).findOne<Rect>(".rect");
@@ -237,6 +235,7 @@ export class EditPoi<T extends PoiAttrib = PoiAttrib> extends Poi<T> {
       newAttrib.x = cd.x;
       newAttrib.y = cd.y;
     }
+    console.log("add", newAttrib);
     items.push(newAttrib as any);
   }
 }

+ 34 - 0
tsconfig.prod.json

@@ -0,0 +1,34 @@
+{
+  "compilerOptions": {
+    "target": "es2015",
+    "useDefineForClassFields": true,
+    "module": "ESNext",
+    "lib": [
+      "es2015",
+      "DOM",
+      "DOM.Iterable"
+    ],
+    "skipLibCheck": true,
+    "moduleResolution": "Node",
+    "resolveJsonModule": true,
+    "isolatedModules": true,
+    "jsx": "preserve",
+    "noUnusedLocals": true,
+    "noUnusedParameters": true,
+    "noFallthroughCasesInSwitch": true,
+    "allowImportingTsExtensions": true,
+    "emitDeclarationOnly": true,
+    "declaration": true,
+    "declarationDir": "/Users/bill/word/drawing-board/dist/tempts",
+    "incremental": false
+  },
+  "include": [
+    "/Users/bill/word/drawing-board/src/app/liantong/index.ts",
+    "src/vite-env.d.ts"
+  ],
+  "references": [
+    {
+      "path": "./tsconfig.node.json"
+    }
+  ]
+}