瀏覽代碼

feat: 修正bug

bill 3 周之前
父節點
當前提交
fc2e7e4ecf

+ 4 - 1
public/static/kankan.html

@@ -175,10 +175,13 @@
       
       $item && $item.classList.add('active')
 
-      document.querySelector('#floor').innerHTML = $item.innerHTML
+      if ($item) {
+        document.querySelector('#floor').innerHTML = $item.innerHTML
+      }
     }
 
     const renderFloors = (floors) => {
+      console.log('renderFloors', floors)
       const $floors = document.querySelector('#floors')
       if (floors.length <= 1) {
         return;

+ 2 - 2
src/core/components/group/group.vue

@@ -92,11 +92,11 @@ const changePropertyHandler = () => {
       const belong = getShapeBelong(item.id);
       // getShapeBelong(item.id)
       if (belong?.type) {
-        store.setItem(belong.type, { value: belong.item, id: belong.item.id });
+        store.setItem(belong.type, { value: item, id: belong.item.id });
       }
     }
   });
-};
+}; 
 
 const { shape, tData, data } = useComponentStatus<Rect, GroupData>({
   emit,

+ 13 - 2
src/core/components/line-icon/icon.vue

@@ -155,11 +155,20 @@ const { shape, tData, data, operateMenus, describes } = useComponentStatus({
   propertys: ["name", "fill", "stroke", "strokeWidth"],
 });
 
+const lineRaw = computed(() => {
+  const line = store.getTypeItems("line")[0];
+  return line.lines.find((item) => item.id === props.data.lineId);
+});
 const line = computed(() => getSnapLine(store, props.data));
 const history = useHistory();
 watch(
-  () => line.value && (copy(line.value) as Pos[]),
-  (line, oldLine) => {
+  () => ({
+    line: line.value && (copy(line.value) as Pos[]),
+    width: lineRaw.value?.strokeWidth,
+  }),
+  (newv, oldv) => {
+    const line = newv.line;
+    const oldLine = oldv?.line;
     history.preventTrack(() => {
       if (!line) {
         console.error("找不到line", props.data);
@@ -195,6 +204,8 @@ watch(
           emit("delShape");
           return;
         }
+      } else if (newv.width !== oldv.width && newv.width && props.data.type === "full") {
+        emit("updateShape", { ...data.value, height: newv.width });
       }
       nextTick(() => {
         shape.value?.getNode().fire("bound-change");

+ 1 - 1
src/core/components/line-icon/index.ts

@@ -164,7 +164,7 @@ export const matResponse = ({
   return data;
 };
 
-export const genGetLineIconAttach = (lineData: LineData, size: Size, minLen = 200) => {
+export const genGetLineIconAttach = (lineData: LineData, size: Size, minLen = 400) => {
   const lines = lineData.lines.map((line) => [
     lineData.points.find((p) => p.id === line.a)!,
     lineData.points.find((p) => p.id === line.b)!,

+ 2 - 1
src/core/components/line/index.ts

@@ -14,6 +14,7 @@ import mitt from "mitt";
 import { Ref, ref, watch } from "vue";
 import { getInitCtx, NLineDataCtx, normalLineData } from "./attach-server.ts";
 import * as wallRenderer from "./renderer/wall";
+import { Group } from "konva/lib/Group";
 
 export { default as Component } from "./line.vue";
 export { default as TempComponent } from "./temp-line.vue";
@@ -271,7 +272,7 @@ export const useGetSelectionManage: UseGetSelectionManage = () => {
   const canSelect = (shape: EntityShape) => {
     const id = shape.id();
     const line = store.getTypeItems("line")[0];
-    return !!(id && line.lines.some((item) => item.id === id));
+    return !!(id && line.lines.some((item) => item.id === id) && !(shape instanceof Group));
   };
   const listener = (shape: EntityShape) => {
     const bus: SelectionManageBus = mitt();

+ 16 - 2
src/core/components/line/single-line.vue

@@ -31,7 +31,7 @@
     :data="data"
     :line="line"
     :showLabel="
-      status.active ||
+      active ||
       config.showComponentSize ||
       isDrawIng ||
       dragPointIds?.includes(line.a) ||
@@ -93,6 +93,7 @@ import { useConfig } from "@/core/hook/use-config.ts";
 import { PropertyUpdate, Operate } from "../../html-mount/propertys/index.ts";
 import {
   useAnimationMouseStyle,
+  useMouseShapesStatus,
   useMouseShapeStatus,
 } from "@/core/hook/use-mouse-status.ts";
 import { themeColor } from "@/constant";
@@ -104,6 +105,7 @@ import {
 } from "./attach-server.ts";
 import { useStore } from "@/core/store/index.ts";
 import { useHistory } from "@/core/hook/use-history.ts";
+import { useTransformIngShapes } from "@/core/hook/use-global-vars.ts";
 
 const props = defineProps<{
   line: LineDataLine;
@@ -170,7 +172,19 @@ const menus = [
   { label: "删除", handler: delHandler },
 ];
 
-const status = useMouseShapeStatus(shape);
+const mStatus = useMouseShapesStatus();
+const joinIds = computed(() => [
+  ...store
+    .getTypeItems("lineIcon")
+    .filter((item) => item.lineId === props.line.id)
+    .map((item) => item.id),
+  props.line.id,
+]);
+const tfShapes = useTransformIngShapes();
+const active = computed(() => {
+  const operShapes = [...tfShapes.value, ...mStatus.actives];
+  return operShapes.some((item) => joinIds.value.includes(item.id()));
+});
 const [style] = useAnimationMouseStyle({
   shape,
   getMouseStyle,