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