feat: 添加对话切换标志位,防止上拉刷新异常出发
This commit is contained in:
parent
1ed96024b4
commit
3ba1e3e0e7
|
@ -275,6 +275,7 @@ export default {
|
||||||
isLoading: false, // loadingMore
|
isLoading: false, // loadingMore
|
||||||
isLoadingMore: false, // 是否正在加载更多的标志位
|
isLoadingMore: false, // 是否正在加载更多的标志位
|
||||||
noMoreData: false, // 是否已加载全部历史消息
|
noMoreData: false, // 是否已加载全部历史消息
|
||||||
|
isSwitchingConversation: false, // 是否正在切换对话的标志位
|
||||||
|
|
||||||
pageQuery: {
|
pageQuery: {
|
||||||
PageIndex: 1,
|
PageIndex: 1,
|
||||||
|
@ -544,6 +545,9 @@ export default {
|
||||||
|
|
||||||
this.isChat = true;
|
this.isChat = true;
|
||||||
|
|
||||||
|
// 设置切换对话标志位,防止触发上拉刷新
|
||||||
|
this.isSwitchingConversation = true;
|
||||||
|
|
||||||
// 重置消息列表和分页相关状态
|
// 重置消息列表和分页相关状态
|
||||||
this.messageGroups = [];
|
this.messageGroups = [];
|
||||||
this.pageQuery.PageIndex = 1;
|
this.pageQuery.PageIndex = 1;
|
||||||
|
@ -572,6 +576,12 @@ export default {
|
||||||
// 否则按时间升序排列
|
// 否则按时间升序排列
|
||||||
return timeA - timeB;
|
return timeA - timeB;
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
// 延迟重置切换对话标志位,确保滚动事件处理完成
|
||||||
|
setTimeout(() => {
|
||||||
|
this.isSwitchingConversation = false;
|
||||||
|
}, 500);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -580,6 +590,10 @@ export default {
|
||||||
// 关闭弹窗
|
// 关闭弹窗
|
||||||
this.popupShow = false;
|
this.popupShow = false;
|
||||||
this.isChat = true;
|
this.isChat = true;
|
||||||
|
|
||||||
|
// 设置切换对话标志位,防止触发上拉刷新
|
||||||
|
this.isSwitchingConversation = true;
|
||||||
|
|
||||||
this.currentConversationId = "";
|
this.currentConversationId = "";
|
||||||
this.messageGroups = [];
|
this.messageGroups = [];
|
||||||
|
|
||||||
|
@ -587,11 +601,20 @@ export default {
|
||||||
this.pageQuery.PageIndex = 1;
|
this.pageQuery.PageIndex = 1;
|
||||||
this.isLoadingMore = false;
|
this.isLoadingMore = false;
|
||||||
this.noMoreData = false;
|
this.noMoreData = false;
|
||||||
|
|
||||||
|
// 延迟重置切换对话标志位
|
||||||
|
setTimeout(() => {
|
||||||
|
this.isSwitchingConversation = false;
|
||||||
|
}, 500);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 开始新对话
|
// 开始新对话
|
||||||
handleStartChat() {
|
handleStartChat() {
|
||||||
this.isChat = true;
|
this.isChat = true;
|
||||||
|
|
||||||
|
// 设置切换对话标志位,防止触发上拉刷新
|
||||||
|
this.isSwitchingConversation = true;
|
||||||
|
|
||||||
this.currentConversationId = "";
|
this.currentConversationId = "";
|
||||||
this.messageGroups = [];
|
this.messageGroups = [];
|
||||||
|
|
||||||
|
@ -599,6 +622,11 @@ export default {
|
||||||
this.pageQuery.PageIndex = 1;
|
this.pageQuery.PageIndex = 1;
|
||||||
this.isLoadingMore = false;
|
this.isLoadingMore = false;
|
||||||
this.noMoreData = false;
|
this.noMoreData = false;
|
||||||
|
|
||||||
|
// 延迟重置切换对话标志位
|
||||||
|
setTimeout(() => {
|
||||||
|
this.isSwitchingConversation = false;
|
||||||
|
}, 500);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 滚动到底部事件处理
|
// 滚动到底部事件处理
|
||||||
|
@ -610,8 +638,8 @@ export default {
|
||||||
onScrollToUpper() {
|
onScrollToUpper() {
|
||||||
console.log("触发上拉刷新");
|
console.log("触发上拉刷新");
|
||||||
|
|
||||||
// 如果已经没有更多数据,不再触发上拉刷新
|
// 如果已经没有更多数据或正在切换对话,不再触发上拉刷新
|
||||||
if (this.noMoreData) {
|
if (this.noMoreData || this.isSwitchingConversation) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue