Explorar o código

Merge branch 'dev' of http://124.70.149.18:10880/lianghj/queenshow into dev

bianjiang hai 1 ano
pai
achega
89595c9999

+ 1 - 1
src/modules/editor/components/CompUI/basicUI/Container/index.ts

@@ -4,7 +4,7 @@ import { createCompHooks } from "../../defines/createCompHooks";
 export { Component } from "./component";
 
 export const options = {
-  name: "图层",
+  name: "容器",
   thumbnail: require("@/modules/editor/assets/icons/group.svg"),
 };
 

+ 18 - 12
src/modules/editor/module/stores/index.ts

@@ -50,22 +50,28 @@ export const store = EditorModule.store({
     previewImageList(state) {
       const res: string[] = [];
 
-      function findImg(comp: DesignComp) {
-        (comp?.children?.default
-          ? comp?.children?.default
-          : Object.values(comp?.children)
-        ).forEach((k: string) => {
-          const comp = state.designData.compMap[k];
-          if (comp.compKey == "Image") {
-            res.push(comp.value?.url);
+      function deepChild(item: any) {
+        if (typeof item == "string") {
+          const comp = state.designData.compMap[item];
+          if (comp.compKey === "Image") {
+            res.push(comp.value.url);
+          } else if (comp.children) {
+            deepChild(comp.children);
+          }
+        } else if (item instanceof Object) {
+          if (item instanceof Array) {
+            item.forEach((d) => {
+              deepChild(d);
+            });
           } else {
-            findImg(comp);
+            Object.values(item).forEach((d) => {
+              deepChild(d);
+            });
           }
-        });
+        }
       }
+      deepChild(state.designData.compMap["root"].children);
 
-      const root = state.designData.compMap["root"];
-      findImg(root);
       return res;
     },
   },