Browse Source

模板替换

qinyan 1 year ago
parent
commit
02477a4a78

+ 1 - 1
src/modules/editor/components/Viewport/Slider/SliderLeft/Templates/index.tsx

@@ -70,7 +70,7 @@ export default defineUI({
                     class="draggable-item relative"
                     key={item._id}
                     title={item.title}
-                    style={{ aspectRatio: 1 }}
+                    // style={{ aspectRatio: 1 }}
                     onClick={() => editor.actions.clickTplToDesign(item)}
                   >
                     <Image

+ 8 - 7
src/modules/editor/module/actions/edit.tsx

@@ -11,6 +11,7 @@ import { ICompKeys, Layout } from "../../typings";
 import CompSave from "../../components/CompSave";
 import { getKeyThenIncreaseKey } from "ant-design-vue/lib/message";
 import { cloneObj, createObj, history } from "../../objects/DesignTemp/factory";
+import { DesignTemp } from "../../objects/DesignTemp";
 
 const ctrlState = {
   selected: [] as string[],
@@ -1110,20 +1111,20 @@ export const editActions = EditorModule.action({
     const frameData = await this.https.getDesignDetail(record._id, {
       isSys: true,
     });
-    const { compMap, content, desc, thumbnail, title, _id } = frameData.result;
+    const result = new DesignTemp(frameData.result);
+    const { _id, ...rest } = result;
 
     const designData = {
-      _id: ctrl.designData._id,
+      ...ctrl.designData,
       version: ctrl.designData.version,
-      compMap,
-      content,
-      desc,
-      thumbnail,
-      title,
+      ...rest,
     };
 
     this.controls.editorCtrl.clickPickComp("root");
     ctrl.setDesignData(designData);
+    setTimeout(() => {
+      this.controls.editorCtrl.autoInScreen();
+    }, 0);
 
     ctrl.state.setDesignId(_id as string);
   },