yeoolhj 1 year ago
parent
commit
5823a99dcc

+ 12 - 3
src/modules/editor/controllers/HistoryCtrl/HistoryController.ts

@@ -179,11 +179,20 @@ export class Action {
     const parent = get(this.root, paths) || this.root;
     switch (type) {
       case "add":
-        if (actionType === "redo") {
-          parent.push(value);
+        if (parent instanceof Array) {
+          if (actionType === "redo") {
+            parent.push(value);
+          } else {
+            parent.pop();
+          }
         } else {
-          parent.pop();
+          if (actionType === "redo") {
+            parent[attrName] = value
+          } else {
+            delete parent[attrName];
+          }
         }
+       
         break;
       case "set":
         parent[attrName] = value;

+ 6 - 4
src/modules/editor/module/actions/init.ts

@@ -10,10 +10,12 @@ export const initActions = EditorModule.action({
     historyCtrl.proxyActions(Object.keys(editActions));
     this.controls.compUICtrl.init();
 
-    createProxyEffect(this.store, (type, paths, value) => {
-      console.log(type, paths, value);
-      historyCtrl.onChange(this.store, type, paths, value);
-    });
+    // createProxyEffect(this.store, (type, paths, value) => {
+    //   console.log(type, paths, value);
+    //   if(paths[0] === "designData" || paths[0] === "currCompId"){
+    //     historyCtrl.onChange(this.store, type, paths, value);
+    //   }
+    // });
   },
 
   // 初始化数据

+ 1 - 1
src/modules/editor/module/index.ts

@@ -23,7 +23,7 @@ export class EditorModule extends ModuleRoot {
 
   actions = this.createActions([initActions, editActions, ImgCompActions]);
   https = this.createHttps(https);
-  store = this.createStore(store, { useProxy: true });
+  store = this.createStore(store);
   helper = this.createHelper(helpers);
 
   controls = {