liwei 1 year ago
parent
commit
7e143cc330

+ 22 - 0
src/modules/editor/components/CompUI/customUI/Cards/CardList/index.tsx

@@ -2,6 +2,8 @@ import { InputNumber } from "ant-design-vue";
 import { createAttrsForm } from "../../../defines/createAttrsForm";
 import { createCompHooks } from "../../../defines/createCompHooks";
 import { createCompId } from "../../../defines/createCompId";
+import { DesignCompObj } from "@/modules/editor/objects/DesignTemp/DesignComp";
+import { RxValue } from "@/modules/editor/controllers/ReactCtrl/rxValue";
 
 export { Component } from "./component";
 
@@ -11,6 +13,26 @@ export const options = {
   thumbnail: thumb,
 };
 
+
+const CardValue = {
+  gap: 10,
+  columns: 3,
+  total: 3,
+  imgHeight: 300,
+  showDesc: true,
+}
+
+export class CompCardListObj extends DesignCompObj<typeof CardValue> {
+  value = RxValue.create({
+     ...CardValue
+  })
+  constructor() {
+    super();
+    this.compKey = "CardList";
+    this.layout.size = [750, 420]
+  }
+}
+
 export const { createComp, useCompData, useCreateChild } = createCompHooks({
   layout: {
     size: [750, 420],

+ 1 - 1
src/modules/editor/controllers/EditorCtrl/index.ts

@@ -280,7 +280,7 @@ export class EditorCtrl extends ModuleControl<EditorModule> {
     } else {
       this.controls.propsCtrl.showProp(compId);
     }
-
+    
     //中间编辑器
     const page = this.controls.pageCtrl;
     page.setCurrComp(compId);

+ 5 - 0
src/modules/editor/controllers/HotKeyCtrl/index.ts

@@ -23,6 +23,11 @@ export class HotKeyCtrl extends ModuleControl<EditorModule> {
       action() {
         this.actions.pickParentComp(this.store.currCompId);
       },
+    },{
+      hotKey: "ctrl+q",
+      action() {
+        this.actions.ctrlq();
+      },
     },
     {
       hotKey: "ctrl+c",

+ 7 - 5
src/modules/editor/controllers/PageCtrl/index.ts

@@ -32,14 +32,14 @@ export class PageCtrl extends ModuleControl<EditorModule> {
     initEvent() {
 
         const updatePid = (pid:string)=>{
-           const comps = this.compMap[pid].children.default;
+           const comps = this.compMap[pid].children.default || [];
            comps.forEach(c=>{
                this.setCompPid(c, pid)
                updatePid(c);
            })
         }
 
-        this.rootPage.children.default.forEach(cid=>{
+        this.rootPage.children.default?.forEach(cid=>{
             const card = this.compMap[cid];
             let first = true;
             this.setCompPid(cid, this.rootPage.id);
@@ -152,10 +152,12 @@ export class PageCtrl extends ModuleControl<EditorModule> {
 
         const comps = this.helper.getCompTrees(compId);
         let cardId = comps[1]?.id || "";
-        if (this.helper.isStreamCard(compId)) {
-          cardId = compId;
+        if (cardId) {
+          if (this.helper.isStreamCard(compId)) {
+            cardId = compId;
+          }
+          this.state.setCurrStreamCardId(cardId);
         }
-        this.state.setCurrStreamCardId(cardId);
     }
 
     findParentComp(compId: string): DesignComp | undefined {

+ 1 - 1
src/modules/editor/controllers/SelectCtrl/index.ts

@@ -125,7 +125,7 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
 
   getUnSelectChilds() {
     const page = this.controls.pageCtrl;
-    const childs = page.currStreamCard.children.default || [];
+    const childs = page.currStreamCard?.children.default || [];
     let n = childs.length;
     let out = [];
     const gizmo = this.controls.selectCtrl.gizmo;

+ 2 - 1
src/modules/editor/controllers/SelectCtrl/matrix.ts

@@ -36,7 +36,8 @@ export class Matrix {
   //matrix(1,0,0,1,0,0)
   static createFromMatrixStr(str: string) {
     const out = new Matrix();
-    out.setMatrixStr(str);
+    if ( str ) out.setMatrixStr(str);
+
     return out;
   }
 

+ 10 - 1
src/modules/editor/module/actions/edit.tsx

@@ -14,7 +14,7 @@ import { cloneObj, createObj, history } from "../../objects/DesignTemp/factory";
 
 const ctrlState = {
   selected: [] as string[],
-  type: 0, // 1 ctrlc 2 ctrlx
+  type: 0, // 1 ctrlc 2 ctrlx 3 ctrlq
   cardId: "", //当前的卡片Id
   screenId: "", //屏幕Id
   selWidth: 0,
@@ -398,6 +398,15 @@ export const editActions = EditorModule.action({
       }
     }
   },
+  ctrlq() {
+    const page = this.controls.pageCtrl;
+    if (!page.currCompId) return;
+    ctrlState.selected = [page.currCompId];
+    ctrlState.screenId = this.controls.screenCtrl.currScreenId;
+    ctrlState.cardId = page.currStreamCardId;
+    ctrlState.type = 3;
+    
+  },
   ctrlx() {
     //console.log("ctrlv ", this.store.selected);
     //console.log("ctrlv ", this.store.selected);

+ 1 - 1
src/modules/editor/module/actions/init.ts

@@ -28,7 +28,7 @@ export const initActions = EditorModule.action({
     const ret = await this.https.getDesignDetail(id, { isSys });
     if (!ret.result.compMap) {
       const cate: any = this.store.tplCategory || [];
-      const item = cate.find((d: any) => ret.result.categories.includes(d.id));
+      const item = cate.find((d: any) => ret.result.categories?.includes(d.id));
       if (item && item.value == "PC") {
         ret.result.platform = "pc";
       } else {

+ 31 - 13
src/modules/editor/objects/DesignTemp/factory.ts

@@ -18,13 +18,14 @@ import { CompWeb3DObj } from "../../components/CompUI/basicUI/Web3D";
 import { HistoryController } from "../../controllers/ReactCtrl/history";
 import { ICompKeys } from "../../typings";
 import { DesignComp, DesignCompObj } from "./DesignComp";
+import { CompCardListObj } from "../../components/CompUI/customUI/Cards/CardList";
 
 
 const history = new HistoryController();
 
-export function createObj( data:any, init = true)  {
+export function createObj( data:any, init = true) :DesignComp {
     const compKey = data.compKey as ICompKeys 
-    let obj = {} as DesignComp;
+    let obj :any = null;
     switch(compKey) {
         case "Container":
             obj = new CompCardObj();
@@ -72,21 +73,38 @@ export function createObj( data:any, init = true)  {
             obj = new CompCurveObj();
             break;
         case "Map":
-            obj = new CompMapObj()
-            
+            obj = new CompMapObj();
+
+            break;
+        case "CardList":
+            obj = new CompCardListObj();
             break;
     }
-    
-    obj.compKey = compKey;
-    obj.value.setHistory( history );
-    obj.layout.setHistory(history);
-    obj.layout.background.setHistory(history);
-    obj.layout.border.setHistory(history);
-    obj.children.setHistory(history);
 
-    if (init) obj.fromJson(data);
+    if (obj) {
+        obj.compKey = compKey;
+        obj.value.setHistory( history );
+        obj.layout.setHistory(history);
+        obj.layout.background.setHistory(history);
+        obj.layout.border.setHistory(history);
+        obj.children.setHistory(history);
 
-    return obj;
+        if (init) obj.fromJson(data);
+
+
+        if (compKey == "CardList") { 
+            obj.children.list = data.children.list;
+        }
+        return obj;
+    }
+
+    //兼容老数据
+    if (compKey == "Cover") {
+      console.log( data );
+      debugger;
+    }
+
+    return data;
 }
 
 export function cloneObj(o: DesignComp ) {