mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +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:vote__')
|
||||||
window.localStorage.removeItem('__cache:unfoldWordChain__')
|
window.localStorage.removeItem('__cache:unfoldWordChain__')
|
||||||
|
//
|
||||||
|
this.handlerMsgTransfer()
|
||||||
},
|
},
|
||||||
immediate: true
|
immediate: true
|
||||||
},
|
},
|
||||||
@ -1325,23 +1327,8 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
dialogMsgTransfer: {
|
dialogMsgTransfer: {
|
||||||
handler({time, msgFile, msgRecord, msgText, sendType, dialogId}) {
|
handler() {
|
||||||
if (time < $A.dayjs().unix()) {
|
this.handlerMsgTransfer();
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
immediate: true
|
immediate: true
|
||||||
},
|
},
|
||||||
@ -4467,6 +4454,29 @@ export default {
|
|||||||
}
|
}
|
||||||
this.$store.dispatch("scrollBottom", this.$refs.footer)
|
this.$store.dispatch("scrollBottom", this.$refs.footer)
|
||||||
}, 500)
|
}, 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>
|
</DatePicker>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem v-if="(taskDetail.loop && taskDetail.loop != 'never') || loopForce">
|
<FormItem v-if="(taskDetail.loop && taskDetail.loop != 'never') || loopForce">
|
||||||
<div class="item-label" slot="label">
|
<div class="item-label" slot="label">
|
||||||
@ -1691,7 +1690,7 @@ export default {
|
|||||||
|
|
||||||
openDialogBefore(dialogId, sendType) {
|
openDialogBefore(dialogId, sendType) {
|
||||||
if (sendType !== true) {
|
if (sendType !== true) {
|
||||||
const transferData = {
|
this.$store.state.dialogMsgTransfer = {
|
||||||
time: $A.dayjs().unix() + 10,
|
time: $A.dayjs().unix() + 10,
|
||||||
msgRecord: this.msgRecord,
|
msgRecord: this.msgRecord,
|
||||||
msgFile: this.msgFile,
|
msgFile: this.msgFile,
|
||||||
@ -1702,7 +1701,6 @@ export default {
|
|||||||
this.msgRecord = {};
|
this.msgRecord = {};
|
||||||
this.msgFile = [];
|
this.msgFile = [];
|
||||||
this.msgText = "";
|
this.msgText = "";
|
||||||
this.$store.state.dialogMsgTransfer = transferData
|
|
||||||
this.$store.dispatch("saveDialogDraft", {id: `t_${this.taskId}`, content: ""})
|
this.$store.dispatch("saveDialogDraft", {id: `t_${this.taskId}`, content: ""})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user