perf: 优化关闭任务独立窗口点击取消后没有自动获取焦点

This commit is contained in:
kuaifan 2022-03-07 15:24:19 +08:00
parent e754ceace8
commit 22704b32d6
2 changed files with 14 additions and 8 deletions

View File

@ -15,6 +15,7 @@
<div class="subtask-name"> <div class="subtask-name">
<Input <Input
v-model="taskDetail.name" v-model="taskDetail.name"
ref="name"
type="textarea" type="textarea"
:rows="1" :rows="1"
:autosize="{ minRows: 1, maxRows: 8 }" :autosize="{ minRows: 1, maxRows: 8 }"
@ -137,6 +138,7 @@
<div class="title"> <div class="title">
<Input <Input
v-model="taskDetail.name" v-model="taskDetail.name"
ref="name"
type="textarea" type="textarea"
:rows="1" :rows="1"
:autosize="{ minRows: 1, maxRows: 8 }" :autosize="{ minRows: 1, maxRows: 8 }"
@ -767,34 +769,37 @@ export default {
} }
}, },
checkUpdate(update) { checkUpdate(action) {
let isModify = false; let isModify = false;
if (this.openTask.name != this.taskDetail.name) { if (this.openTask.name != this.taskDetail.name) {
isModify = true; isModify = true;
if (update) { if (action === true) {
this.updateData('name'); this.updateData('name');
} else if (isModify) { } else {
action === false && this.$refs.name.focus();
return true return true
} }
} }
if (this.$refs.desc && this.$refs.desc.getContent() != this.taskContent) { if (this.$refs.desc && this.$refs.desc.getContent() != this.taskContent) {
isModify = true; isModify = true;
if (update) { if (action === true) {
this.updateData('content'); this.updateData('content');
} else if (isModify) { } else {
action === false && this.$refs.desc.focus();
return true return true
} }
} }
if (this.addsubShow && this.addsubName) { if (this.addsubShow && this.addsubName) {
isModify = true; isModify = true;
if (update) { if (action === true) {
this.onAddsub(); this.onAddsub();
} else if (isModify) { } else {
action === false && this.$refs.addsub.focus();
return true return true
} }
} }
this.subList.some(({id}) => { this.subList.some(({id}) => {
if (this.$refs[`subTask_${id}`][0].checkUpdate(update)) { if (this.$refs[`subTask_${id}`][0].checkUpdate(action)) {
isModify = true; isModify = true;
} }
}) })

View File

@ -65,6 +65,7 @@ export default {
this.$Electron.sendMessage('windowDestroy'); this.$Electron.sendMessage('windowDestroy');
}, },
onCancel: () => { onCancel: () => {
this.$refs.taskDetail.checkUpdate(false);
this.canUpdateBlur = true; this.canUpdateBlur = true;
} }
}); });