bill 2 weeks ago
parent
commit
d7d1c4278d

+ 28 - 27
src/core/components/line-icon/icon.vue

@@ -214,31 +214,32 @@ watch(
   },
   { immediate: true, flush: "post" }
 );
-operateMenus.splice(0, 4);
-if (props.data.type === "align-bottom" || props.data.type === "align-bottom-fix") {
-  operateMenus.splice(
-    operateMenus.length - 2,
-    0,
-    // {
-    //   label: "内外翻转",
-    //   handler: () => {
-    //     emit("updateShape", {
-    //       ...data.value,
-    //       openSide: data.value.openSide === "LEFT" ? "RIGHT" : "LEFT",
-    //     });
-    //   },
-    // },
-    {
-      label: "翻转",
-      handler: () => {
-        emit("updateShape", {
-          ...data.value,
-          openSide: data.value.openSide === "LEFT" ? "RIGHT" : "LEFT",
-          startLen: data.value.endLen,
-          endLen: data.value.startLen,
-        });
-      },
-    }
-  );
-}
+operateMenus.splice(0, 2);
+operateMenus.splice(1, 2);
+// if (props.data.type === "align-bottom" || props.data.type === "align-bottom-fix") {
+operateMenus.splice(
+  operateMenus.length - 2,
+  0,
+  // {
+  //   label: "内外翻转",
+  //   handler: () => {
+  //     emit("updateShape", {
+  //       ...data.value,
+  //       openSide: data.value.openSide === "LEFT" ? "RIGHT" : "LEFT",
+  //     });
+  //   },
+  // },
+  {
+    label: "翻转",
+    handler: () => {
+      emit("updateShape", {
+        ...data.value,
+        openSide: data.value.openSide === "LEFT" ? "RIGHT" : "LEFT",
+        startLen: data.value.endLen,
+        endLen: data.value.startLen,
+      });
+    },
+  }
+);
+// }
 </script>

+ 32 - 39
src/core/hook/use-component.ts

@@ -60,6 +60,20 @@ export const useComponentMenus = <T extends DrawItem>(
   // 置顶 置底
   const currentZIndex = useCurrentZIndex();
   operateMenus.push(
+    reactive({
+      label: computed(() => (data.value.lock ? "解锁" : "锁定")) as any,
+      handler() {
+        data.value.lock = !data.value.lock;
+        emit("updateShape", { ...data.value });
+      },
+    }),
+    reactive({
+      label: "隐藏",
+      handler() {
+        data.value.hide = true;
+        emit("updateShape", { ...data.value });
+      },
+    })
     // {
     //   label: `上移`,
     //   icon: Top,
@@ -76,31 +90,6 @@ export const useComponentMenus = <T extends DrawItem>(
     //     emit("updateShape", { ...data.value });
     //   },
     // },
-    {
-      label: `置顶`,
-      handler() {
-        data.value.zIndex = currentZIndex.max + 1;
-        emit("updateShape", { ...data.value });
-      },
-    },
-    {
-      label: `置底`,
-      handler() {
-        data.value.zIndex = currentZIndex.min - 1;
-        emit("updateShape", { ...data.value });
-      },
-    }
-  );
-
-  // 锁定 解锁
-  operateMenus.push(
-    reactive({
-      label: computed(() => (data.value.lock ? "解锁" : "锁定")) as any,
-      handler() {
-        data.value.lock = !data.value.lock;
-        emit("updateShape", { ...data.value });
-      },
-    })
   );
 
   if (alignment) {
@@ -118,17 +107,6 @@ export const useComponentMenus = <T extends DrawItem>(
     });
   }
 
-  // 隐藏
-  operateMenus.push(
-    reactive({
-      label: "隐藏",
-      handler() {
-        data.value.hide = true;
-        emit("updateShape", { ...data.value });
-      },
-    })
-  );
-
   if (copyHandler) {
     const getCopyTransform = useGetShapeCopyTransform(shape);
     const status = useMouseShapesStatus();
@@ -154,7 +132,22 @@ export const useComponentMenus = <T extends DrawItem>(
       },
     });
   }
-
+  operateMenus.push(
+    {
+      label: `置顶`,
+      handler() {
+        data.value.zIndex = currentZIndex.max + 1;
+        emit("updateShape", { ...data.value });
+      },
+    },
+    {
+      label: `置底`,
+      handler() {
+        data.value.zIndex = currentZIndex.min - 1;
+        emit("updateShape", { ...data.value });
+      },
+    }
+  );
   if (!data.value.disableDelete) {
     operateMenus.push({
       label: `删除`,
@@ -219,7 +212,7 @@ export const useComponentDescribes = <T extends { id: string }>(
   watchEffect((onCleanup) => {
     gdescs.set(data.value, descs.value);
     onCleanup(() => {
-      gdescs.del(data.value.id)
+      gdescs.del(data.value.id);
     });
   });
   watch(
@@ -261,7 +254,7 @@ export const useComponentStatus = <S extends EntityShape, T extends DrawItem>(
   );
   const data = useAutomaticData(
     () => args.props.data,
-    (data) => args.selfData ? data : copy(data)
+    (data) => (args.selfData ? data : copy(data))
   );
   const [style, pause, resume] = useAnimationMouseStyle({
     data: data,

+ 1 - 0
src/example/components/slide/actions.ts

@@ -34,6 +34,7 @@ export const draw: MenuItem = {
   icon: "line_d",
   name: "绘制",
   value: uuid(),
+  defSelect: true,
   children: [
     // { icon: "line", ...genDrawItem('sequentLine') },
     { icon: "line", ...genDrawItem("line") },

+ 1 - 0
src/example/components/slide/menu.ts

@@ -8,6 +8,7 @@ export type MenuItem = {
   type?: string
   children?: MenuItem[];
   mount?: any,
+  defSelect?: boolean
   payload?: any;
   single?: boolean
   handler?: (draw: Draw) => void;

+ 1 - 1
src/example/components/slide/slide-item.vue

@@ -53,7 +53,7 @@ const index = computed(() => props.data.value || props.data.name);
 const showAttr = computed(() => props.viewData || props.data);
 const active = computed(() => false);
 const clickHandler = () => {
-  if (props.data.children?.length) {
+  if (props.data.children?.length && props.data.defSelect) {
     const item = props.data.children[0];
     emit("update:activeIndex", item.value || item.name);
   }