diff --git a/js/components/chat-area.js b/js/components/chat-area.js index 7743af3..b9abb5a 100644 --- a/js/components/chat-area.js +++ b/js/components/chat-area.js @@ -221,7 +221,7 @@ export function appendMessageDOM(msg, index) { /** 更新最后一条 assistant 消息(流式输出) */ 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; const loadingDots = lastMsg.querySelector('.loading-dots'); diff --git a/js/components/input-area.js b/js/components/input-area.js index 436a6a1..7411eae 100644 --- a/js/components/input-area.js +++ b/js/components/input-area.js @@ -511,7 +511,7 @@ ${ragContext} console.error('[InputArea] 流式聊天错误:', err); 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 loadingText = placeholder?.querySelector('.loading-text'); if (loadingDots) loadingDots.remove(); @@ -547,7 +547,7 @@ ${ragContext} 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 loadingText = placeholder?.querySelector('.loading-text'); if (loadingDots) loadingDots.remove();