liwei 1 year ago
parent
commit
13bd696f16

+ 6 - 5
src/modules/editor/components/CompUI/basicUI/Transfer/streamCard.tsx

@@ -8,17 +8,15 @@ export const StreamCardTransfer = defineComponent({
     const editor = useEditor();
     const { store, controls, helper } = editor;
     const { streamCardTransferCtrl } = controls;
-    const { transferStyle } = streamCardTransferCtrl;
-
+  
     onMounted(() => {
-      setTimeout(() => {
         const pageEl = helper.findRootComp()?.$el;
         if (pageEl) {
-          streamCardTransferCtrl.init(pageEl.firstChild as HTMLElement);
           streamCardTransferCtrl.currComp = store.currStreamCard;
+          streamCardTransferCtrl.pageEl = pageEl.firstChild as any;
           streamCardTransferCtrl.compEl = streamCardTransferCtrl.currComp.$el;
+          streamCardTransferCtrl.observe();
         }
-      });
     });
 
     onUnmounted(() => {
@@ -26,6 +24,9 @@ export const StreamCardTransfer = defineComponent({
     });
 
     return () => {
+       
+        const transferStyle = streamCardTransferCtrl.transferStyle;
+
       return (
         transferStyle.width && (
           <div

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

@@ -47,7 +47,7 @@ export const View = defineComponent({
             store.isEditMode && isStreamCard && <div class="hudop">
               <IconMove class="draganchor" />
               <IconDelete />
-              <IconAdd />
+              <IconAdd onClick={()=>actions.addCompToDesign("Container")} />
 
             </div>
           }

+ 1 - 1
src/modules/editor/controllers/TransferCtrl/transforms/transform.ts

@@ -2,7 +2,7 @@ import { TransCreateFn, TransferCtrl } from "..";
 
 function getTransform(this: TransferCtrl, transType: string) {
   const { transEvent } = this;
-  const { transform = {} } = this.currComp?.layout;
+  const { transform = {} } = this.currComp?.layout || {};
   const offset = {
     x: transform.x || 0,
     y: transform.y || 0,

+ 24 - 12
src/modules/editor/module/actions/edit.ts

@@ -7,22 +7,33 @@ import { ICompKeys, Layout } from "../../typings";
 export const editActions = EditorModule.action({
   // 添加组件到画布
   async addCompToDesign(compKey: ICompKeys, index?: number) {
-    let compId: string;
-    if (
-      index === undefined &&
-      this.store.currComp?.compKey === "Container"
-      // this.store.pageCompIds.includes(this.store.currComp.id)
-    ) {
-      compId = await this.store.insertCompContainer(
+ 
+    if (!this.store.currStreamCardId) {//必须选中一个streamCard
+      return
+    }
+
+    if (compKey == "Container") {
+      const compId = await this.store.insertDesignContent(compKey, index);
+      this.actions.pickComp(compId);
+      return;
+    }
+    
+    // if (
+    //   index === undefined &&
+    //   this.store.currComp?.compKey === "Container"
+    //   // this.store.pageCompIds.includes(this.store.currComp.id)
+    // ) {
+
+      const compId = await this.store.insertCompContainer(
         compKey,
-        this.store.currComp
+        this.store.currStreamCard
       );
       this.actions.pickComp(compId);
       this.actions.setCompPosition(this.store.currComp);
-    } else {
-      compId = await this.store.insertDesignContent(compKey, index);
-      this.actions.pickComp(compId);
-    }
+    // } else {
+    //   compId = await this.store.insertDesignContent(compKey, index);
+    //   this.actions.pickComp(compId);
+    // }
   },
   // 切换当前组件
   pickComp(compId: string) {
@@ -32,6 +43,7 @@ export const editActions = EditorModule.action({
     //   nextCompId = comps[1].id;
     // }
     // if (compId !== this.store.currCompId) {
+
       this.store.setCurrComp(compId);
     // }
   },

+ 2 - 0
src/modules/editor/module/stores/index.ts

@@ -70,6 +70,8 @@ export const store = EditorModule.store({
     setCurrComp(compId: string) {
       
       this.store.currCompId = compId;
+      this.store.currStreamCardId = "";
+      
       const find = (objs:string[], id:string):boolean=>{
         if (!objs || objs.length < 1) return false