fix: 使用 insertAdjacentHTML 在设置 innerHTML 后添加搜索结果
This commit is contained in:
@@ -371,16 +371,18 @@
|
||||
|
||||
html += '</div>';
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user