Ver código fonte

命令修改

haojianlong 4 anos atrás
pai
commit
c045c21097
1 arquivos alterados com 10 adições e 9 exclusões
  1. 10 9
      persagy-web-base/src/undo/SUndoStack.ts

+ 10 - 9
persagy-web-base/src/undo/SUndoStack.ts

@@ -44,7 +44,6 @@ export class SUndoStack extends SObject {
     }
     set index(v: number) {
         this._index = v;
-        this.$emit("cmdListChange");
     }
 
     /** 命令栈是否为空 */
@@ -64,8 +63,9 @@ export class SUndoStack extends SObject {
             return;
         }
 
-        this._index++;
-        this.cmdStack[this._index].redo();
+        this.index++;
+        this.cmdStack[this.index].redo();
+        this.$emit("cmdListChange");
         this.isChange = true;
     }
 
@@ -78,8 +78,9 @@ export class SUndoStack extends SObject {
             return;
         }
 
-        this.cmdStack[this._index].undo();
-        this._index--;
+        this.cmdStack[this.index].undo();
+        this.index--;
+        this.$emit("cmdListChange");
         this.isChange = true;
     }
 
@@ -106,7 +107,7 @@ export class SUndoStack extends SObject {
      */
     clear(): void {
         this.cmdStack.length = 0;
-        this._index = -1;
+        this.index = -1;
         this.isChange = true;
     }
 
@@ -137,15 +138,15 @@ export class SUndoStack extends SObject {
      * @param cmd     被添加的命令
      */
     push(cmd: SUndoCommand): void {
-        this.cmdStack.length = this._index + 1;
+        this.cmdStack.length = this.index + 1;
 
         // 索引有效而且可以合并命令
-        if (this._index >= 0 && cmd.mergeWith(this.cmdStack[this._index])) {
+        if (this.index >= 0 && cmd.mergeWith(this.cmdStack[this.index])) {
             return;
         }
 
         this.cmdStack.push(cmd);
-        this._index = this.cmdStack.length - 1;
+        this.index = this.cmdStack.length - 1;
         this.isChange = true;
     }