浏览代码

fix: 修改bug

bill 2 周之前
父节点
当前提交
ec97271811

+ 0 - 1
src/core/components/arrow/temp-arrow.vue

@@ -95,7 +95,6 @@ import { useOperMode } from "@/core/hook/use-status.ts";
 import { useFixedScale } from "@/core/hook/use-viewer.ts";
 
 const props = defineProps<{ data: ArrowData; canEdit?: boolean; addMode?: boolean }>();
-console.log(props.data);
 const emit = defineEmits<{
   (e: "update:position", data: { ndx: number; val: Pos }): void;
   (e: "update"): void;

+ 0 - 1
src/core/components/line-chunk/attrib.ts

@@ -15,7 +15,6 @@ export const getMouseStyle = (data: LineData) => {
   const strokeStatus = getMouseColors(data.stroke || defaultStyle.stroke);
   const strokeWidth = data.strokeWidth || defaultStyle.strokeWidth;
 
-  console.log(strokeStatus.hover)
   return {
     default: { stroke: data.stroke || defaultStyle.stroke, strokeWidth },
     hover: { stroke: strokeStatus.hover },

+ 5 - 3
src/core/hook/use-component.ts

@@ -31,7 +31,7 @@ import {
   PropertyDescribes,
   PropertyKeys,
 } from "../html-mount/propertys";
-import { useStore } from "../store";
+import { itemCopyHandler, useStore } from "../store";
 import { globalWatch, useMountMenusFilter, useStage } from "./use-global-vars";
 import { useAlignmentShape } from "./use-alignment";
 import { useViewerTransform } from "./use-viewer";
@@ -120,10 +120,12 @@ export const useComponentMenus = <T extends DrawItem>(
       label: ui18n.t("sys.copy"),
       async handler() {
         const transform = getCopyTransform();
-        const copyData = copyHandler(
+        
+        const copyData = itemCopyHandler(copyHandler(
           transform,
           JSON.parse(JSON.stringify(data.value)) as T,
-        );
+        ));
+
         copyData.id = onlyId();
         emit("addShape", copyData);
         status.actives = [];

+ 3 - 4
src/core/hook/use-expose.ts

@@ -13,7 +13,7 @@ import {
 import { useCan, useMode, useOperMode } from "./use-status";
 import { Stage } from "konva/lib/Stage";
 import { useInteractiveProps } from "./use-interactive.ts";
-import { useStore } from "../store/index.ts";
+import { itemCopyHandler, useStore } from "../store/index.ts";
 import {
   useFixedScale,
   useGetViewBoxPositionPixel,
@@ -54,7 +54,6 @@ export const useAutoPaste = () => {
   const paste = usePaste();
   const drawAPI = useInteractiveDrawShapeAPI();
   const resourceHandler = useResourceHandler();
-  const viewMat = useViewerTransform();
   const viewInvMat = useViewerInvertTransform();
   const store = useStore();
   const history = useHistory();
@@ -122,12 +121,12 @@ export const useAutoPaste = () => {
         const copy = () => {
           for (const item of items) {
             const base = getBaseItem();
-            const data = {
+            const data = itemCopyHandler({
               ...base,
               ...item.data,
               id: base.id,
               createTime: base.createTime,
-            };
+            });
 
             switch (item.type) {
               case "text":

+ 17 - 11
src/core/hook/use-selection.ts

@@ -163,8 +163,10 @@ type ShapeIconArgs = Partial<
 >;
 export const useShapesIcon = (
   shapes: Ref<EntityShape[] | undefined>,
-  args: ShapeIconArgs = {}
+  args: ShapeIconArgs = {},
+  disableIds?: string[]
 ) => {
+  const store = useStore()
   const mParts = useMountParts();
   const { on } = useOnComponentBoundChange();
   const iconProps = {
@@ -197,6 +199,10 @@ export const useShapesIcon = (
       }
       const { added, deleted } = diffArrayChange(shapes || [], oldShapes || []);
       for (const addShape of added) {
+        if (disableIds?.includes(addShape.attrs.id)) {
+          continue;
+        }
+        // addShape.attrs.id
         const mat = ref(getShapeMat(addShape));
         const data = reactive({ ...iconProps, mat: mat });
         const update = frameEebounce(() => {
@@ -285,6 +291,15 @@ export const useGetShapeSelectionManage = installGlobalVar(() => {
 });
 
 export const useSelectionRevise = installGlobalVar(() => {
+  const groupConfig = {
+    id: onlyId(),
+    createTime: Date.now(),
+    lock: false,
+    opacity: 1,
+    ref: false,
+    listening: false,
+    stroke: themeColor,
+  };
   const getShapeSelectionManage = useGetShapeSelectionManage();
   const mParts = useMountParts();
   const status = useMouseShapesStatus();
@@ -310,7 +325,7 @@ export const useSelectionRevise = installGlobalVar(() => {
       }
     }
   );
-  useShapesIcon(computed(() => status.selects));
+  useShapesIcon(computed(() => status.selects), undefined, [groupConfig.id]);
 
   const filterSelect = debounce(() => {
     const selects = new Set<EntityShape>();
@@ -338,15 +353,6 @@ export const useSelectionRevise = installGlobalVar(() => {
   const ids = computed(() => [
     ...new Set(status.selects.map((item) => item.id())),
   ]);
-  const groupConfig = {
-    id: onlyId(),
-    createTime: Date.now(),
-    lock: false,
-    opacity: 1,
-    ref: false,
-    listening: false,
-    stroke: themeColor,
-  };
   const operMode = useOperMode();
   const layer = useFormalLayer();
   watch(

+ 13 - 0
src/core/store/index.ts

@@ -7,6 +7,19 @@ import { round } from "@/utils/shared";
 import mitt, { Emitter } from "mitt";
 import { FilterKeysWithPrefix, FilterNever } from "@/deconstruction";
 
+export const itemCopyHandler = <T extends DrawItem>(item: T): T => {
+  return {
+    ...item,  
+    key: undefined,
+    userData: undefined,
+    lock: false,
+    disableCopy: false,
+    disableDelete: false,
+    disableEditText: false,
+    disableTransformer: false
+  }
+}
+
 // 放置重复放入历史,我们把小数保留5位小数
 const b = 3;
 const normalStore = (store: any) => {

+ 3 - 3
src/example/fuse/views/overview/index.vue

@@ -67,9 +67,9 @@ const vrHeight = ref(220);
 
 const attach = shallowRef<any>();
 if (import.meta.env.DEV) {
-  import("@/core/renderer-three/renderer.vue").then((res) => {
-    attach.value = res.default;
-  });
+  // import("@/core/renderer-three/renderer.vue").then((res) => {
+  //   attach.value = res.default;
+  // });
 }
 
 const saveAfterHandlers: (() => void)[] = [];

+ 5 - 5
src/example/fuse/views/tabulation/index.vue

@@ -205,7 +205,7 @@ const setMapHandler = async (config: { url: string; size: Size }) => {
     const pack = autoGen
       ? d.history.preventTrack.bind(d.history)
       : (run: () => void) => run();
-    const table = serialTable.value || addTable(d as any);
+    const table: any = serialTable.value || addTable(d as any);
     const syncSerials = serials.map((item) => {
       let desc = "";
       if (item.joinIds) {
@@ -259,16 +259,16 @@ const setMapHandler = async (config: { url: string; size: Size }) => {
       draw.value?.runHook(() => syncTable(table, syncSerials));
     }
 
-    if (serialTable.value) {
+    if (table) {
       if (!syncSerials.length) {
         pack(() => {
-          d.store.delItem("table", serialTable.value!.id);
+          d.store.delItem("table", table.id);
         });
       } else {
         pack(() => {
           d.store.setItem("table", {
-            id: serialTable.value!.id,
-            value: serialTable.value!,
+            id: table.id,
+            value: table,
           });
         });
       }