fix: 修复空格格式化换行问题
This commit is contained in:
parent
9eeb8eadac
commit
a2ced17f63
|
@ -21,7 +21,7 @@
|
|||
></image>
|
||||
|
||||
<text class="message-text"
|
||||
>Hi~ 我是源小新,你们的AI校园助手,非常高兴认识您,我可以为你答疑解惑。</text
|
||||
>Hi~ 我是源小新,你们的AI校园助手,非常高兴认识您,我可以为你答疑解惑。</text
|
||||
>
|
||||
</view>
|
||||
|
||||
|
@ -117,7 +117,7 @@
|
|||
<view class="loading-more" v-if="isLoading">
|
||||
<u-loading mode="circle" color="#4370fe"></u-loading>
|
||||
</view>
|
||||
|
||||
|
||||
<!-- 到顶部提示 -->
|
||||
<view class="no-more-data" v-if="noMoreData">
|
||||
<text>已经到顶了</text>
|
||||
|
@ -283,7 +283,7 @@ export default {
|
|||
isLoadingMore: false, // 是否正在加载更多的标志位
|
||||
noMoreData: false, // 是否已加载全部历史消息
|
||||
isSwitchingConversation: false, // 是否正在切换对话的标志位
|
||||
|
||||
|
||||
pageQuery: {
|
||||
PageIndex: 1,
|
||||
PageSize: 20,
|
||||
|
@ -502,7 +502,7 @@ export default {
|
|||
// 添加到消息列表
|
||||
this.messageGroups.push(userMessage);
|
||||
this.messageValue = "";
|
||||
|
||||
|
||||
// 立即添加一个AI回复的加载状态消息
|
||||
const loadingMessage = {
|
||||
id: "loading_" + Math.random().toString(36).substring(2, 15),
|
||||
|
@ -514,9 +514,9 @@ export default {
|
|||
messageType: 0,
|
||||
timeLabel: 0,
|
||||
displayTime: "",
|
||||
isLoading: true // 标记为加载状态
|
||||
isLoading: true, // 标记为加载状态
|
||||
};
|
||||
|
||||
|
||||
// 添加加载状态消息到列表
|
||||
this.messageGroups.push(loadingMessage);
|
||||
|
||||
|
@ -532,7 +532,9 @@ export default {
|
|||
this.currentConversationId = data.conversationId;
|
||||
|
||||
// 从消息列表中移除加载状态消息
|
||||
this.messageGroups = this.messageGroups.filter(msg => !msg.isLoading);
|
||||
this.messageGroups = this.messageGroups.filter(
|
||||
(msg) => !msg.isLoading
|
||||
);
|
||||
|
||||
// 创建AI回复消息对象
|
||||
const aiMessage = {
|
||||
|
@ -554,10 +556,12 @@ export default {
|
|||
})
|
||||
.catch((error) => {
|
||||
console.error("API请求失败:", error);
|
||||
|
||||
|
||||
// 从消息列表中移除加载状态消息
|
||||
this.messageGroups = this.messageGroups.filter(msg => !msg.isLoading);
|
||||
|
||||
this.messageGroups = this.messageGroups.filter(
|
||||
(msg) => !msg.isLoading
|
||||
);
|
||||
|
||||
// 添加错误消息
|
||||
const errorMessage = {
|
||||
id: "error_" + Math.random().toString(36).substring(2, 15),
|
||||
|
@ -570,7 +574,7 @@ export default {
|
|||
timeLabel: 0,
|
||||
displayTime: "",
|
||||
};
|
||||
|
||||
|
||||
this.messageGroups.push(errorMessage);
|
||||
});
|
||||
},
|
||||
|
@ -638,18 +642,18 @@ export default {
|
|||
// 关闭弹窗
|
||||
this.popupShow = false;
|
||||
this.isChat = true;
|
||||
|
||||
|
||||
// 设置切换对话标志位,防止触发上拉刷新
|
||||
this.isSwitchingConversation = true;
|
||||
|
||||
|
||||
this.currentConversationId = "";
|
||||
this.messageGroups = [];
|
||||
|
||||
|
||||
// 重置分页和加载状态
|
||||
this.pageQuery.PageIndex = 1;
|
||||
this.isLoadingMore = false;
|
||||
this.noMoreData = false;
|
||||
|
||||
|
||||
// 延迟重置切换对话标志位
|
||||
setTimeout(() => {
|
||||
this.isSwitchingConversation = false;
|
||||
|
@ -659,18 +663,18 @@ export default {
|
|||
// 开始新对话
|
||||
handleStartChat() {
|
||||
this.isChat = true;
|
||||
|
||||
|
||||
// 设置切换对话标志位,防止触发上拉刷新
|
||||
this.isSwitchingConversation = true;
|
||||
|
||||
|
||||
this.currentConversationId = "";
|
||||
this.messageGroups = [];
|
||||
|
||||
|
||||
// 重置分页和加载状态
|
||||
this.pageQuery.PageIndex = 1;
|
||||
this.isLoadingMore = false;
|
||||
this.noMoreData = false;
|
||||
|
||||
|
||||
// 延迟重置切换对话标志位
|
||||
setTimeout(() => {
|
||||
this.isSwitchingConversation = false;
|
||||
|
@ -685,7 +689,7 @@ export default {
|
|||
// 滚动到顶部事件处理
|
||||
onScrollToUpper() {
|
||||
console.log("触发上拉刷新");
|
||||
|
||||
|
||||
// 如果已经没有更多数据或正在切换对话,不再触发上拉刷新
|
||||
if (this.noMoreData || this.isSwitchingConversation) {
|
||||
return;
|
||||
|
@ -711,7 +715,7 @@ export default {
|
|||
this.$refs.uToast.show({
|
||||
title: "已经到顶了",
|
||||
type: "warning",
|
||||
duration: 1500
|
||||
duration: 1500,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -1002,7 +1006,7 @@ export default {
|
|||
text-align: center;
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
|
||||
.no-more-data {
|
||||
text-align: center;
|
||||
font-size: 24rpx;
|
||||
|
@ -1050,7 +1054,7 @@ export default {
|
|||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
|
||||
|
||||
.dot {
|
||||
display: inline-block;
|
||||
width: 12rpx;
|
||||
|
@ -1060,20 +1064,20 @@ export default {
|
|||
margin: 0 6rpx;
|
||||
opacity: 0.6;
|
||||
animation: dot-flashing 1.5s infinite linear alternate;
|
||||
|
||||
|
||||
&:nth-child(1) {
|
||||
animation-delay: 0s;
|
||||
}
|
||||
|
||||
|
||||
&:nth-child(2) {
|
||||
animation-delay: 0.5s;
|
||||
}
|
||||
|
||||
|
||||
&:nth-child(3) {
|
||||
animation-delay: 1s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@keyframes dot-flashing {
|
||||
0% {
|
||||
opacity: 0.6;
|
||||
|
|
Loading…
Reference in New Issue