From e5c622cb8952af23095eb61b99351e00e04f6e04 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Thu, 14 Dec 2023 22:29:52 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E9=87=8D=E8=BF=9E?= =?UTF-8?q?=E6=97=B6=E6=B6=88=E6=81=AF=E5=88=97=E8=A1=A8=E8=B7=B3=E5=9B=9E?= =?UTF-8?q?=E7=AC=AC=E4=B8=80=E9=A1=B5=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/manage/components/DialogWrapper.vue | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index 6fac88c31..ffe7c3cd8 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -570,7 +570,6 @@ export default { msgNew: 0, msgType: '', loadIng: 0, - unreadMsgId: 0, allMsgs: [], tempMsgs: [], @@ -654,11 +653,13 @@ export default { scrollTmp: 0, scrollIng: 0, - positionLoad: 0, - - approveDetails:{id: 0}, + approveDetails: {id: 0}, approveDetailsShow: false, - approvaUserStatus: '' + approvaUserStatus: '', + + positionLoad: 0, // 定位跳转加载中 + unreadMsgId: 0, // 最早未读消息id + toBottomReGetMsg: false, // 滚动到底部重新获取消息 } }, @@ -997,6 +998,7 @@ export default { this.msgType = '' this.searchShow = false this.unreadMsgId = 0 + this.toBottomReGetMsg = false // if (this.allMsgList.length > 0) { this.allMsgs = this.allMsgList @@ -1114,11 +1116,15 @@ export default { if (num <= 1) { return } - this.getMsgs({ - dialog_id: this.dialogId, - msg_id: this.msgId, - msg_type: this.msgType, - }).catch(_ => {}); + // 判断是否最后一条消息可见才重新获取消息 + const lastMsg = this.allMsgs[this.allMsgs.length - 1] + const lastEl = $A(this.$refs.scroller.$el).find(`[data-id="${lastMsg.id}"]`) + if (lastEl.length === 0) { + this.toBottomReGetMsg = true + return; + } + // 开始请求重新获取消息 + this.onReGetMsg() }, allMsgList(newList, oldList) { @@ -1936,6 +1942,15 @@ export default { this.$store.dispatch("openOkr", this.dialogData.link_id); }, + onReGetMsg() { + this.toBottomReGetMsg = false + this.getMsgs({ + dialog_id: this.dialogId, + msg_id: this.msgId, + msg_type: this.msgType, + }).catch(_ => {}); + }, + onPrevPage() { if (this.prevId === 0) { return @@ -2228,6 +2243,7 @@ export default { this.scrollTail = tail; if (this.scrollTail <= 55) { this.msgNew = 0; + this.toBottomReGetMsg && this.onReGetMsg() } // this.scrollAction = event.target.scrollTop;