feat: 添加对话切换标志位,防止上拉刷新异常出发
This commit is contained in:
parent
1ed96024b4
commit
3ba1e3e0e7
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue