From 49e15130f12a7ea8603b6457d42abd5537937a38 Mon Sep 17 00:00:00 2001 From: hubian <908234780@qq.com> Date: Mon, 13 Apr 2026 19:00:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BD=BF=E7=94=A8=20insertAdjacentHTML?= =?UTF-8?q?=20=E5=9C=A8=E8=AE=BE=E7=BD=AE=20innerHTML=20=E5=90=8E=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=90=9C=E7=B4=A2=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/index.html | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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; }