From 3ba1e3e0e7ca4d0f3e7d10d7ec84c3df5d194ebd Mon Sep 17 00:00:00 2001 From: yangzhe Date: Mon, 14 Jul 2025 09:45:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E6=A0=87=E5=BF=97=E4=BD=8D=EF=BC=8C=E9=98=B2?= =?UTF-8?q?=E6=AD=A2=E4=B8=8A=E6=8B=89=E5=88=B7=E6=96=B0=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=87=BA=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/home/index/index.vue | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/pages/home/index/index.vue b/pages/home/index/index.vue index 261073f..f4c3d2e 100644 --- a/pages/home/index/index.vue +++ b/pages/home/index/index.vue @@ -275,6 +275,7 @@ export default { isLoading: false, // loadingMore isLoadingMore: false, // 是否正在加载更多的标志位 noMoreData: false, // 是否已加载全部历史消息 + isSwitchingConversation: false, // 是否正在切换对话的标志位 pageQuery: { PageIndex: 1, @@ -544,6 +545,9 @@ export default { this.isChat = true; + // 设置切换对话标志位,防止触发上拉刷新 + this.isSwitchingConversation = true; + // 重置消息列表和分页相关状态 this.messageGroups = []; this.pageQuery.PageIndex = 1; @@ -572,6 +576,12 @@ export default { // 否则按时间升序排列 return timeA - timeB; }); + }) + .finally(() => { + // 延迟重置切换对话标志位,确保滚动事件处理完成 + setTimeout(() => { + this.isSwitchingConversation = false; + }, 500); }); }, @@ -580,6 +590,10 @@ export default { // 关闭弹窗 this.popupShow = false; this.isChat = true; + + // 设置切换对话标志位,防止触发上拉刷新 + this.isSwitchingConversation = true; + this.currentConversationId = ""; this.messageGroups = []; @@ -587,11 +601,20 @@ export default { this.pageQuery.PageIndex = 1; this.isLoadingMore = false; this.noMoreData = false; + + // 延迟重置切换对话标志位 + setTimeout(() => { + this.isSwitchingConversation = false; + }, 500); }, // 开始新对话 handleStartChat() { this.isChat = true; + + // 设置切换对话标志位,防止触发上拉刷新 + this.isSwitchingConversation = true; + this.currentConversationId = ""; this.messageGroups = []; @@ -599,6 +622,11 @@ export default { this.pageQuery.PageIndex = 1; this.isLoadingMore = false; this.noMoreData = false; + + // 延迟重置切换对话标志位 + setTimeout(() => { + this.isSwitchingConversation = false; + }, 500); }, // 滚动到底部事件处理 @@ -610,8 +638,8 @@ export default { onScrollToUpper() { console.log("触发上拉刷新"); - // 如果已经没有更多数据,不再触发上拉刷新 - if (this.noMoreData) { + // 如果已经没有更多数据或正在切换对话,不再触发上拉刷新 + if (this.noMoreData || this.isSwitchingConversation) { return; }