mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 19:23:26 +00:00
perf: 网络不好时发送消息顺序问题
This commit is contained in:
parent
081d77da63
commit
20d70c980e
@ -61,7 +61,11 @@ export default {
|
|||||||
handleProgress(event, file) {
|
handleProgress(event, file) {
|
||||||
//上传时
|
//上传时
|
||||||
if (file.tempId === undefined) {
|
if (file.tempId === undefined) {
|
||||||
file.tempId = $A.randNum(1000000000, 9999999999)
|
if (this.$parent.$options.name === 'DialogWrapper') {
|
||||||
|
file.tempId = this.$parent.getTempId()
|
||||||
|
} else {
|
||||||
|
file.tempId = $A.randNum(1000000000, 9999999999)
|
||||||
|
}
|
||||||
this.$emit('on-progress', file)
|
this.$emit('on-progress', file)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -538,6 +538,7 @@ export default {
|
|||||||
|
|
||||||
allMsgs: [],
|
allMsgs: [],
|
||||||
tempMsgs: [],
|
tempMsgs: [],
|
||||||
|
tempId: $A.randNum(1000000000, 9999999999),
|
||||||
msgLoadIng: 0,
|
msgLoadIng: 0,
|
||||||
|
|
||||||
pasteShow: false,
|
pasteShow: false,
|
||||||
@ -1102,10 +1103,9 @@ export default {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// 发送
|
// 发送
|
||||||
const tempId = $A.randNum(1000000000, 9999999999)
|
|
||||||
const typeLoad = $A.stringLength(msgText.replace(/<img[^>]*?>/g, '')) > 5000
|
const typeLoad = $A.stringLength(msgText.replace(/<img[^>]*?>/g, '')) > 5000
|
||||||
const tempMsg = {
|
const tempMsg = {
|
||||||
id: tempId,
|
id: this.getTempId(),
|
||||||
dialog_id: this.dialogData.id,
|
dialog_id: this.dialogData.id,
|
||||||
reply_id: this.replyId,
|
reply_id: this.replyId,
|
||||||
reply_data: this.replyItem,
|
reply_data: this.replyItem,
|
||||||
@ -1130,7 +1130,7 @@ export default {
|
|||||||
},
|
},
|
||||||
method: 'post',
|
method: 'post',
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempId)
|
this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempMsg.id)
|
||||||
this.sendSuccess(data)
|
this.sendSuccess(data)
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.$set(tempMsg, 'error', true)
|
this.$set(tempMsg, 'error', true)
|
||||||
@ -1147,9 +1147,8 @@ export default {
|
|||||||
* @param msg {base64, duration}
|
* @param msg {base64, duration}
|
||||||
*/
|
*/
|
||||||
sendRecord(msg) {
|
sendRecord(msg) {
|
||||||
const tempId = $A.randNum(1000000000, 9999999999);
|
|
||||||
const tempMsg = {
|
const tempMsg = {
|
||||||
id: tempId,
|
id: this.getTempId(),
|
||||||
dialog_id: this.dialogData.id,
|
dialog_id: this.dialogData.id,
|
||||||
reply_id: this.replyId,
|
reply_id: this.replyId,
|
||||||
reply_data: this.replyItem,
|
reply_data: this.replyItem,
|
||||||
@ -1171,7 +1170,7 @@ export default {
|
|||||||
}),
|
}),
|
||||||
method: 'post',
|
method: 'post',
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempId)
|
this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempMsg.id)
|
||||||
this.sendSuccess(data);
|
this.sendSuccess(data);
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.$set(tempMsg, 'error', true)
|
this.$set(tempMsg, 'error', true)
|
||||||
@ -1221,6 +1220,10 @@ export default {
|
|||||||
this.sendMsg(`<p><span data-quick-key="${item.key}">${item.label}</span></p>`)
|
this.sendMsg(`<p><span data-quick-key="${item.key}">${item.label}</span></p>`)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getTempId() {
|
||||||
|
return this.tempId++
|
||||||
|
},
|
||||||
|
|
||||||
getMsgs(data) {
|
getMsgs(data) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
setTimeout(_ => this.msgLoadIng++, 2000)
|
setTimeout(_ => this.msgLoadIng++, 2000)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user