fix: RAG开启时AI回复后loading动画不消失的问题
根因:appendSystemMessage() 在 assistant placeholder 之后插入了一个无 .message class 的 div, 导致 CSS 选择器 .message.assistant:last-child 无法命中 placeholder(它不再是 :last-child)。 updateLastAssistantMessage() 返回 null,loading 动画永远不会被移除。 修复:将 3 处 :last-child 改为 :last-of-type,使选择器基于元素类型(div)而非精确的最后一个子节点匹配。
This commit is contained in:
@@ -221,7 +221,7 @@ export function appendMessageDOM(msg, index) {
|
|||||||
|
|
||||||
/** 更新最后一条 assistant 消息(流式输出) */
|
/** 更新最后一条 assistant 消息(流式输出) */
|
||||||
export function updateLastAssistantMessage(content, think, stats, model) {
|
export function updateLastAssistantMessage(content, think, stats, model) {
|
||||||
const lastMsg = messagesContainerEl.querySelector('.message.assistant:last-child');
|
const lastMsg = messagesContainerEl.querySelector('.message.assistant:last-of-type');
|
||||||
if (!lastMsg) return;
|
if (!lastMsg) return;
|
||||||
|
|
||||||
const loadingDots = lastMsg.querySelector('.loading-dots');
|
const loadingDots = lastMsg.querySelector('.loading-dots');
|
||||||
|
|||||||
@@ -511,7 +511,7 @@ ${ragContext}
|
|||||||
console.error('[InputArea] 流式聊天错误:', err);
|
console.error('[InputArea] 流式聊天错误:', err);
|
||||||
|
|
||||||
if (err.name === 'AbortError') {
|
if (err.name === 'AbortError') {
|
||||||
const placeholder = document.querySelector('#messagesContainer .message.assistant:last-child');
|
const placeholder = document.querySelector('#messagesContainer .message.assistant:last-of-type');
|
||||||
const loadingDots = placeholder?.querySelector('.loading-dots');
|
const loadingDots = placeholder?.querySelector('.loading-dots');
|
||||||
const loadingText = placeholder?.querySelector('.loading-text');
|
const loadingText = placeholder?.querySelector('.loading-text');
|
||||||
if (loadingDots) loadingDots.remove();
|
if (loadingDots) loadingDots.remove();
|
||||||
@@ -547,7 +547,7 @@ ${ragContext}
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const placeholder = document.querySelector('#messagesContainer .message.assistant:last-child');
|
const placeholder = document.querySelector('#messagesContainer .message.assistant:last-of-type');
|
||||||
const loadingDots = placeholder?.querySelector('.loading-dots');
|
const loadingDots = placeholder?.querySelector('.loading-dots');
|
||||||
const loadingText = placeholder?.querySelector('.loading-text');
|
const loadingText = placeholder?.querySelector('.loading-text');
|
||||||
if (loadingDots) loadingDots.remove();
|
if (loadingDots) loadingDots.remove();
|
||||||
|
|||||||
Reference in New Issue
Block a user