liwei 1 year ago
parent
commit
74a8b1e692

+ 10 - 10
src/modules/editor/components/CompUI/basicUI/View.tsx

@@ -32,17 +32,17 @@ export const View = defineComponent({
           //   }
           // }}
           onDblclick={() => emit("dblclick")}
-
-          onMousedown={(e) => {
-            e.stopPropagation();
-            if (store.isEditMode) {
-              actions.pickComp(props.compId);
-              controls.transferCtrl.mousedown(e, "move")
-            }
-          }}
         >
-          {slots.default?.()}
-
+          <div onMousedown={(e) => {
+              e.stopPropagation();
+              if (store.isEditMode) {
+                actions.pickComp(props.compId);
+                controls.transferCtrl.mousedown(e, "move")
+              }
+            }}>
+            {slots.default?.()}
+          </div>
+        
           {
             store.isEditMode && isStreamCard && <div class="hudop">
               <IconMove class="draganchor" />

+ 1 - 0
src/modules/editor/controllers/TransferCtrl/index.ts

@@ -58,6 +58,7 @@ export class TransferCtrl extends ModuleControl<EditorModule> {
     document.addEventListener("mouseup", this.mouseup);
     this.currTransfer.mousedown?.call(this, e);
   }
+
   private mousemove = (e: MouseEvent) => {
     const { transEvent } = this;
     transEvent.offsetX = e.clientX - transEvent.startX;

+ 8 - 4
src/modules/editor/module/actions/edit.ts

@@ -17,7 +17,7 @@ export const editActions = EditorModule.action({
       this.actions.pickComp(compId);
       return;
     }
-    
+
     // if (
     //   index === undefined &&
     //   this.store.currComp?.compKey === "Container"
@@ -42,10 +42,12 @@ export const editActions = EditorModule.action({
     //   const comps = this.helper.getCompTrees(compId);
     //   nextCompId = comps[1].id;
     // }
-    // if (compId !== this.store.currCompId) {
-
+      this.store.currCompId = "";
+      this.store.currStreamCardId = "";
       this.store.setCurrComp(compId);
-    // }
+      if (this.store.currCompId == this.store.currStreamCardId) {
+        this.controls.transferCtrl.destroy();
+      }
   },
   // 切换到父组件
   pickParentComp(compId: string) {
@@ -155,6 +157,8 @@ export const editActions = EditorModule.action({
 
   // 设置组件变换
   setCompTransform(comp: DesignComp, transform: Layout["transform"]) {
+    if (!comp) return;
+
     comp.layout.transform = transform;
     console.log(comp);
   },