diff --git a/templates/index.html b/templates/index.html
index e2b529f..23cadae 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -371,16 +371,18 @@
html += '';
div.innerHTML = html;
- container.appendChild(div);
- // 如果是用户消息且有搜索结果,追加显示
+ // 如果是用户消息且有搜索结果,在设置innerHTML后追加
if (role === 'user' && extraData && extraData.search_results && extraData.search_results.length > 0) {
- const msgBody = div.querySelector('.message-body');
- if (msgBody) {
- msgBody.innerHTML += buildSearchResultsHtml(extraData.search_results, extraData.search_query || content);
+ const searchHtml = buildSearchResultsHtml(extraData.search_results, extraData.search_query || content);
+ // 直接追加到 div 的 innerHTML
+ const bodyDiv = div.querySelector('.message-body');
+ if (bodyDiv) {
+ bodyDiv.insertAdjacentHTML('beforeend', searchHtml);
}
}
+ container.appendChild(div);
container.scrollTop = container.scrollHeight;
}