Commit e80a6f3a authored by yyh's avatar yyh

优化action

parent 5d9f90d2
......@@ -179,23 +179,20 @@ export default class Add extends Vue {
this.showMoreAction = true;
this.currentAction = {index, parentIndex};
}
private addBefore() {
private resolveAction(flag: string = '') {
const { index, parentIndex } = this.currentAction;
const wordType = parentIndex === -1 ? DataType.Unit : DataType.Input;
const word = parentIndex !== -1 ? this.words[parentIndex] : null;
this.preAddWord({ wordType, word}, 'before');
this.preAddWord({ wordType, word}, flag);
}
private updateWord() {
const { index, parentIndex } = this.currentAction;
const wordType = parentIndex === -1 ? DataType.Unit : DataType.Input;
const word = parentIndex !== -1 ? this.words[parentIndex] : null;
this.preAddWord({ wordType, word}, 'update');
private addBefore() {
this.resolveAction('before');
}
private addAfter() {
const { index, parentIndex } = this.currentAction;
const wordType = parentIndex === -1 ? DataType.Unit : DataType.Input;
const word = parentIndex !== -1 ? this.words[parentIndex] : null;
this.preAddWord({ wordType, word }, 'after');
this.resolveAction('after');
}
private updateWord() {
this.resolveAction('update');
}
private async delWord() {
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