mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-11 18:42:54 +00:00
feat: 优化消息传递处理逻辑
- 在 DialogWrapper 组件中添加 handlerMsgTransfer 方法以简化消息传递逻辑 - 更新 TaskDetail 组件以直接使用状态管理中的 dialogMsgTransfer 数据
This commit is contained in:
parent
18758a1614
commit
39781c9cd7
@ -1227,6 +1227,8 @@ export default {
|
||||
//
|
||||
window.localStorage.removeItem('__cache:vote__')
|
||||
window.localStorage.removeItem('__cache:unfoldWordChain__')
|
||||
//
|
||||
this.handlerMsgTransfer()
|
||||
},
|
||||
immediate: true
|
||||
},
|
||||
@ -1325,23 +1327,8 @@ export default {
|
||||
},
|
||||
|
||||
dialogMsgTransfer: {
|
||||
handler({time, msgFile, msgRecord, msgText, sendType, dialogId}) {
|
||||
if (time < $A.dayjs().unix()) {
|
||||
return
|
||||
}
|
||||
if (dialogId != this.dialogId) {
|
||||
return;
|
||||
}
|
||||
this.$store.state.dialogMsgTransfer.time = 0;
|
||||
this.$nextTick(() => {
|
||||
if ($A.isArray(msgFile) && msgFile.length > 0) {
|
||||
this.sendFileMsg(msgFile);
|
||||
} else if ($A.isJson(msgRecord) && msgRecord.duration > 0) {
|
||||
this.sendRecord(msgRecord);
|
||||
} else if (msgText) {
|
||||
this.sendMsg(msgText, sendType);
|
||||
}
|
||||
});
|
||||
handler() {
|
||||
this.handlerMsgTransfer();
|
||||
},
|
||||
immediate: true
|
||||
},
|
||||
@ -4467,6 +4454,29 @@ export default {
|
||||
}
|
||||
this.$store.dispatch("scrollBottom", this.$refs.footer)
|
||||
}, 500)
|
||||
},
|
||||
|
||||
handlerMsgTransfer() {
|
||||
const {time, msgFile, msgRecord, msgText, sendType, dialogId} = this.dialogMsgTransfer || {}
|
||||
if (!/^\d+$/.test(time) || !/^\d+$/.test(dialogId)) {
|
||||
return
|
||||
}
|
||||
if (time < $A.dayjs().unix()) {
|
||||
return
|
||||
}
|
||||
if (dialogId != this.dialogId) {
|
||||
return
|
||||
}
|
||||
this.$store.state.dialogMsgTransfer.time = 0;
|
||||
this.$nextTick(() => {
|
||||
if ($A.isArray(msgFile) && msgFile.length > 0) {
|
||||
this.sendFileMsg(msgFile);
|
||||
} else if ($A.isJson(msgRecord) && msgRecord.duration > 0) {
|
||||
this.sendRecord(msgRecord);
|
||||
} else if (msgText) {
|
||||
this.sendMsg(msgText, sendType);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -265,7 +265,6 @@
|
||||
</DatePicker>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</FormItem>
|
||||
<FormItem v-if="(taskDetail.loop && taskDetail.loop != 'never') || loopForce">
|
||||
<div class="item-label" slot="label">
|
||||
@ -1691,7 +1690,7 @@ export default {
|
||||
|
||||
openDialogBefore(dialogId, sendType) {
|
||||
if (sendType !== true) {
|
||||
const transferData = {
|
||||
this.$store.state.dialogMsgTransfer = {
|
||||
time: $A.dayjs().unix() + 10,
|
||||
msgRecord: this.msgRecord,
|
||||
msgFile: this.msgFile,
|
||||
@ -1702,7 +1701,6 @@ export default {
|
||||
this.msgRecord = {};
|
||||
this.msgFile = [];
|
||||
this.msgText = "";
|
||||
this.$store.state.dialogMsgTransfer = transferData
|
||||
this.$store.dispatch("saveDialogDraft", {id: `t_${this.taskId}`, content: ""})
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user