From 20d70c980eef7eafe19d459061355ff555e8fa2b Mon Sep 17 00:00:00 2001 From: kuaifan Date: Thu, 16 Mar 2023 11:58:39 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E7=BD=91=E7=BB=9C=E4=B8=8D=E5=A5=BD?= =?UTF-8?q?=E6=97=B6=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF=E9=A1=BA=E5=BA=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/pages/manage/components/DialogUpload.vue | 6 +++++- .../js/pages/manage/components/DialogWrapper.vue | 15 +++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/resources/assets/js/pages/manage/components/DialogUpload.vue b/resources/assets/js/pages/manage/components/DialogUpload.vue index 5d6d3cc04..27f60235a 100644 --- a/resources/assets/js/pages/manage/components/DialogUpload.vue +++ b/resources/assets/js/pages/manage/components/DialogUpload.vue @@ -61,7 +61,11 @@ export default { handleProgress(event, file) { //上传时 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) } }, diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index 01f1ffe88..11bc58cc4 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -538,6 +538,7 @@ export default { allMsgs: [], tempMsgs: [], + tempId: $A.randNum(1000000000, 9999999999), msgLoadIng: 0, pasteShow: false, @@ -1102,10 +1103,9 @@ export default { }); } else { // 发送 - const tempId = $A.randNum(1000000000, 9999999999) const typeLoad = $A.stringLength(msgText.replace(/]*?>/g, '')) > 5000 const tempMsg = { - id: tempId, + id: this.getTempId(), dialog_id: this.dialogData.id, reply_id: this.replyId, reply_data: this.replyItem, @@ -1130,7 +1130,7 @@ export default { }, method: 'post', }).then(({data}) => { - this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempId) + this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempMsg.id) this.sendSuccess(data) }).catch(error => { this.$set(tempMsg, 'error', true) @@ -1147,9 +1147,8 @@ export default { * @param msg {base64, duration} */ sendRecord(msg) { - const tempId = $A.randNum(1000000000, 9999999999); const tempMsg = { - id: tempId, + id: this.getTempId(), dialog_id: this.dialogData.id, reply_id: this.replyId, reply_data: this.replyItem, @@ -1171,7 +1170,7 @@ export default { }), method: 'post', }).then(({data}) => { - this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempId) + this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempMsg.id) this.sendSuccess(data); }).catch(error => { this.$set(tempMsg, 'error', true) @@ -1221,6 +1220,10 @@ export default { this.sendMsg(`

${item.label}

`) }, + getTempId() { + return this.tempId++ + }, + getMsgs(data) { return new Promise((resolve, reject) => { setTimeout(_ => this.msgLoadIng++, 2000)