Commit e80a6f3a authored by yyh's avatar yyh

优化action

parent 5d9f90d2
...@@ -179,23 +179,20 @@ export default class Add extends Vue { ...@@ -179,23 +179,20 @@ export default class Add extends Vue {
this.showMoreAction = true; this.showMoreAction = true;
this.currentAction = {index, parentIndex}; this.currentAction = {index, parentIndex};
} }
private addBefore() { private resolveAction(flag: string = '') {
const { index, parentIndex } = this.currentAction; const { index, parentIndex } = this.currentAction;
const wordType = parentIndex === -1 ? DataType.Unit : DataType.Input; const wordType = parentIndex === -1 ? DataType.Unit : DataType.Input;
const word = parentIndex !== -1 ? this.words[parentIndex] : null; const word = parentIndex !== -1 ? this.words[parentIndex] : null;
this.preAddWord({ wordType, word}, 'before'); this.preAddWord({ wordType, word}, flag);
} }
private updateWord() { private addBefore() {
const { index, parentIndex } = this.currentAction; this.resolveAction('before');
const wordType = parentIndex === -1 ? DataType.Unit : DataType.Input;
const word = parentIndex !== -1 ? this.words[parentIndex] : null;
this.preAddWord({ wordType, word}, 'update');
} }
private addAfter() { private addAfter() {
const { index, parentIndex } = this.currentAction; this.resolveAction('after');
const wordType = parentIndex === -1 ? DataType.Unit : DataType.Input; }
const word = parentIndex !== -1 ? this.words[parentIndex] : null; private updateWord() {
this.preAddWord({ wordType, word }, 'after'); this.resolveAction('update');
} }
private async delWord() { private async delWord() {
const { index, parentIndex } = this.currentAction; const { index, parentIndex } = this.currentAction;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment