输出后闪白修复

This commit is contained in:
2026-08-04 15:31:01 +08:00
parent 2f1702c858
commit b7c3fc9ff6
2 changed files with 194 additions and 190 deletions

View File

@@ -212,6 +212,194 @@
background: linear-gradient(135deg, #8b5cf6, #7c3aed); background: linear-gradient(135deg, #8b5cf6, #7c3aed);
} }
/* ========== 智能体选择弹窗 ========== */
.agent-modal-mask {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.45);
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
z-index: 1000;
display: flex;
align-items: center;
justify-content: center;
}
.agent-modal {
width: 85%;
max-height: 70%;
background-color: #ffffff;
border-radius: 24rpx;
overflow: hidden;
display: flex;
flex-direction: column;
box-shadow: 0 16rpx 48rpx rgba(0, 0, 0, 0.12);
}
.agent-modal-header {
display: flex;
justify-content: center;
align-items: center;
padding: 30rpx 30rpx 20rpx;
position: relative;
border-bottom: 2rpx solid #f0f0f0;
}
.agent-modal-title {
font-size: 34rpx;
font-weight: 700;
color: #1a1a2e;
}
.agent-modal-close {
position: absolute;
right: 24rpx;
top: 50%;
transform: translateY(-50%);
padding: 10rpx;
}
.agent-list {
box-sizing: border-box;
flex: 1;
padding: 20rpx 24rpx;
max-height: 600rpx;
}
.agent-loading {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 60rpx 0;
}
.agent-loading-text {
margin-top: 16rpx;
font-size: 26rpx;
color: #999;
}
.agent-empty {
display: flex;
align-items: center;
justify-content: center;
padding: 80rpx 0;
}
.agent-empty-text {
font-size: 28rpx;
color: #999;
}
.agent-card {
box-sizing: border-box;
width: 100%;
background: linear-gradient(135deg, #f8f5ff, #efe8ff);
border: 2rpx solid #c4b5fd;
border-radius: 20rpx;
padding: 28rpx 24rpx;
margin-bottom: 20rpx;
transition: all 0.2s ease;
overflow: hidden;
}
.agent-card:active {
transform: scale(0.98);
border-color: #a78bfa;
background: linear-gradient(135deg, #f3efff, #e8dcff);
}
.agent-card-header {
display: flex;
align-items: center;
margin-bottom: 16rpx;
}
.agent-avatar {
width: 70rpx;
height: 70rpx;
border-radius: 20rpx;
background: linear-gradient(135deg, #8b5cf6, #7c3aed);
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.agent-card-info {
margin-left: 16rpx;
display: flex;
flex-direction: column;
flex: 1;
min-width: 0;
}
.agent-card-title {
font-size: 30rpx;
font-weight: 600;
color: #1a1a2e;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.agent-card-category {
font-size: 22rpx;
color: #8b5cf6;
margin-top: 4rpx;
}
.agent-card-desc {
font-size: 26rpx;
color: #555;
line-height: 1.5;
word-break: break-all;
display: -webkit-box;
-webkit-line-clamp: 5;
-webkit-box-orient: vertical;
overflow: hidden;
}
.agent-card-welcome {
font-size: 24rpx;
color: #7c3aed;
margin-top: 12rpx;
padding-top: 12rpx;
border-top: 2rpx dashed #ddd6fe;
word-break: break-all;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.agent-modal-footer {
padding: 20rpx 30rpx 30rpx;
border-top: 2rpx solid #f0f0f0;
display: flex;
justify-content: flex-end;
}
.agent-modal-btn {
padding: 18rpx 48rpx;
border-radius: 16rpx;
font-size: 28rpx;
font-weight: 500;
}
.agent-modal-btn-cancel {
background: #f0f0f0;
color: #666;
}
.agent-modal-btn-cancel:active {
background: #e0e0e0;
}
/* ==========新建聊天列表相关====== */ /* ==========新建聊天列表相关====== */
.close-option-card { .close-option-card {
width: 100%; width: 100%;

View File

@@ -1362,7 +1362,7 @@ import { openFile as openFileNative, downloadAndOpen } from '@/utils/fileOpener.
} }
// 全局监听 socketStore.isThinking跨设备同步思考状态锁/解锁输入框 // 全局监听 socketStore.isThinking跨设备同步思考状态锁/解锁输入框
watch(() => socketStore.isThinking, (newVal, oldVal) => { watch(() => socketStore.isThinking, async (newVal, oldVal) => {
console.log("isThinking 变化:", oldVal, "→", newVal, "messageString:", socketStore.messageString); console.log("isThinking 变化:", oldVal, "→", newVal, "messageString:", socketStore.messageString);
// false → true后端开始回复锁定输入框 // false → true后端开始回复锁定输入框
if (!oldVal && newVal) { if (!oldVal && newVal) {
@@ -1383,12 +1383,14 @@ import { openFile as openFileNative, downloadAndOpen } from '@/utils/fileOpener.
// true → falseAI 回复结束或中断,解锁输入框并刷新消息列表 // true → falseAI 回复结束或中断,解锁输入框并刷新消息列表
if (oldVal && !newVal) { if (oldVal && !newVal) {
console.log('AI回复结束正常/中断),解锁并刷新消息列表'); console.log('AI回复结束正常/中断),解锁并刷新消息列表');
// 移除流式消息气泡,从服务器加载完整消息
// 先从服务器加载完整消息列表
await takeConversationMessages()
// 加载完成后再移除流式消息气泡,避免闪白
if (streamingMessageId.value) { if (streamingMessageId.value) {
allmessages.value = allmessages.value.filter(m => m._id !== streamingMessageId.value) allmessages.value = allmessages.value.filter(m => m._id !== streamingMessageId.value)
streamingMessageId.value = null streamingMessageId.value = null
} }
takeConversationMessages()
isThinking.value = false isThinking.value = false
isSelfSent.value = false isSelfSent.value = false
textMessage.value = '' textMessage.value = ''
@@ -1808,193 +1810,7 @@ import { openFile as openFileNative, downloadAndOpen } from '@/utils/fileOpener.
<style lang="scss" scoped> <style lang="scss" scoped>
@import "./chat.css"; @import "./chat.css";
/* ========== 智能体选择弹窗 ========== */
.agent-modal-mask {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.45);
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
z-index: 1000;
display: flex;
align-items: center;
justify-content: center;
}
.agent-modal {
width: 85%;
max-height: 70%;
background-color: #ffffff;
border-radius: 24rpx;
overflow: hidden;
display: flex;
flex-direction: column;
box-shadow: 0 16rpx 48rpx rgba(0, 0, 0, 0.12);
}
.agent-modal-header {
display: flex;
justify-content: center;
align-items: center;
padding: 30rpx 30rpx 20rpx;
position: relative;
border-bottom: 2rpx solid #f0f0f0;
}
.agent-modal-title {
font-size: 34rpx;
font-weight: 700;
color: #1a1a2e;
}
.agent-modal-close {
position: absolute;
right: 24rpx;
top: 50%;
transform: translateY(-50%);
padding: 10rpx;
}
.agent-list {
box-sizing: border-box;
flex: 1;
padding: 20rpx 24rpx;
max-height: 600rpx;
}
.agent-loading {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 60rpx 0;
}
.agent-loading-text {
margin-top: 16rpx;
font-size: 26rpx;
color: #999;
}
.agent-empty {
display: flex;
align-items: center;
justify-content: center;
padding: 80rpx 0;
}
.agent-empty-text {
font-size: 28rpx;
color: #999;
}
.agent-card {
box-sizing: border-box;
width: 100%;
background: linear-gradient(135deg, #f8f5ff, #efe8ff);
border: 2rpx solid #c4b5fd;
border-radius: 20rpx;
padding: 28rpx 24rpx;
margin-bottom: 20rpx;
transition: all 0.2s ease;
overflow: hidden;
}
.agent-card:active {
transform: scale(0.98);
border-color: #a78bfa;
background: linear-gradient(135deg, #f3efff, #e8dcff);
}
.agent-card-header {
display: flex;
align-items: center;
margin-bottom: 16rpx;
}
.agent-avatar {
width: 70rpx;
height: 70rpx;
border-radius: 20rpx;
background: linear-gradient(135deg, #8b5cf6, #7c3aed);
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.agent-card-info {
margin-left: 16rpx;
display: flex;
flex-direction: column;
flex: 1;
min-width: 0;
}
.agent-card-title {
font-size: 30rpx;
font-weight: 600;
color: #1a1a2e;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.agent-card-category {
font-size: 22rpx;
color: #8b5cf6;
margin-top: 4rpx;
}
.agent-card-desc {
font-size: 26rpx;
color: #555;
line-height: 1.5;
word-break: break-all;
display: -webkit-box;
-webkit-line-clamp: 5;
-webkit-box-orient: vertical;
overflow: hidden;
}
.agent-card-welcome {
font-size: 24rpx;
color: #7c3aed;
margin-top: 12rpx;
padding-top: 12rpx;
border-top: 2rpx dashed #ddd6fe;
word-break: break-all;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.agent-modal-footer {
padding: 20rpx 30rpx 30rpx;
border-top: 2rpx solid #f0f0f0;
display: flex;
justify-content: flex-end;
}
.agent-modal-btn {
padding: 18rpx 48rpx;
border-radius: 16rpx;
font-size: 28rpx;
font-weight: 500;
}
.agent-modal-btn-cancel {
background: #f0f0f0;
color: #666;
}
.agent-modal-btn-cancel:active {
background: #e0e0e0;
}
</style> </style>
<!-- v-html 渲染的 markdown 内容无法被 scoped 样式命中需非 scoped 样式块 --> <!-- v-html 渲染的 markdown 内容无法被 scoped 样式命中需非 scoped 样式块 -->