perf: 优化发送图片出现空白的情况

This commit is contained in:
kuaifan 2022-07-20 12:21:17 +08:00
parent 9d14123a66
commit d013ab1e3c

View File

@ -875,11 +875,12 @@ export default {
*/ */
sendMsg(text) { sendMsg(text) {
let msgText; let msgText;
let emptied = false;
if (typeof text === "string" && text) { if (typeof text === "string" && text) {
msgText = text; msgText = text;
} else { } else {
msgText = this.msgText; msgText = this.msgText;
this.msgText = ''; emptied = true;
} }
if (msgText == '') { if (msgText == '') {
this.inputFocus(); this.inputFocus();
@ -928,37 +929,38 @@ export default {
text: typeLoad ? '' : msgText, text: typeLoad ? '' : msgText,
}, },
} }
setTimeout(_ => { this.tempMsgs.push(tempMsg)
this.tempMsgs.push(tempMsg) this.msgType = ''
this.msgType = '' this.replyActiveId = 0
this.replyActiveId = 0 this.onActive()
this.onActive() this.$nextTick(this.onToBottom)
this.$nextTick(this.onToBottom) //
// this.$store.dispatch("call", {
this.$store.dispatch("call", { url: 'dialog/msg/sendtext',
url: 'dialog/msg/sendtext', data: {
data: { dialog_id: tempMsg.dialog_id,
dialog_id: tempMsg.dialog_id, reply_id: tempMsg.reply_id,
reply_id: tempMsg.reply_id, text: msgText,
text: msgText, },
}, method: 'post',
method: 'post', complete: _ => this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempId)
complete: _ => this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempId) }).then(({data}) => {
}).then(({data}) => { this.sendSuccess(data)
this.sendSuccess(data) }).catch(({msg}) => {
}).catch(({msg}) => { $A.modalConfirm({
$A.modalConfirm({ icon: 'error',
icon: 'error', title: '发送失败',
title: '发送失败', content: msg,
content: msg, cancelText: '取消',
cancelText: '取消', okText: '再次编辑',
okText: '再次编辑', onOk: () => {
onOk: () => { this.msgText = msgText
this.msgText = msgText }
} })
}) });
}); }
}, 10) if (emptied) {
requestAnimationFrame(_ => this.msgText = '')
} }
}, },