From 3cbdddf7738c702d38b9a0f31004ff34b4a27f12 Mon Sep 17 00:00:00 2001 From: hubian <908234780@qq.com> Date: Mon, 13 Apr 2026 17:01:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=90=9C=E7=B4=A2=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E6=94=BE=E5=88=B0=E7=94=A8=E6=88=B7=E6=B6=88=E6=81=AF=E4=B8=8B?= =?UTF-8?q?=E9=9D=A2=EF=BC=8C=E6=8A=98=E5=8F=A0=E6=98=BE=E7=A4=BA=20-=20?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=BB=93=E6=9E=9C=E8=BF=BD=E5=8A=A0=E5=88=B0?= =?UTF-8?q?=E6=9C=80=E5=90=8E=E4=B8=80=E6=9D=A1=E7=94=A8=E6=88=B7=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E7=9A=84=20message-body=20=E4=B8=AD=20-=20=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=8A=98=E5=8F=A0=EF=BC=8C=E7=82=B9=E5=87=BB=E5=B1=95?= =?UTF-8?q?=E5=BC=80/=E6=94=B6=E8=B5=B7=20-=20=E6=98=BE=E7=A4=BA=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=85=B3=E9=94=AE=E8=AF=8D=E5=92=8C=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/index.html | 65 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 14 deletions(-) diff --git a/templates/index.html b/templates/index.html index 21a4a16..2bce544 100644 --- a/templates/index.html +++ b/templates/index.html @@ -86,13 +86,17 @@ .thinking-toggle { font-size: 12px; color: #667eea; } .thinking-content { margin-top: 12px; display: none; } .thinking-content.expanded { display: block; } - .search-results-box { margin: 8px 0; padding: 12px; background: #f8f9fa; border-radius: 8px; border: 1px solid #e9ecef; } - .search-results-box h5 { margin: 0 0 8px; font-size: 14px; color: #495057; } - .search-result-item { margin-bottom: 8px; padding: 8px; background: white; border-radius: 6px; } + .search-results-box { margin: 12px 0; padding: 10px 12px; background: linear-gradient(135deg, #f0f7ff 0%, #e8f4f8 100%); border-radius: 8px; border: 1px solid #d0e8f0; } + .search-results-header { display: flex; align-items: center; justify-content: space-between; cursor: pointer; } + .search-results-header h5 { margin: 0; font-size: 13px; color: #10a37f; display: flex; align-items: center; gap: 6px; } + .search-results-toggle { font-size: 12px; color: #666; } + .search-results-content { margin-top: 10px; display: none; } + .search-results-content.expanded { display: block; } + .search-result-item { margin-bottom: 8px; padding: 8px 10px; background: white; border-radius: 6px; border: 1px solid #eee; } .search-result-item:last-child { margin-bottom: 0; } .search-result-title { font-size: 13px; color: #10a37f; font-weight: 500; margin-bottom: 4px; } .search-result-snippet { font-size: 12px; color: #666; line-height: 1.4; } - .search-result-url { font-size: 11px; color: #999; margin-top: 4px; } + .search-result-url { font-size: 11px; color: #999; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; } /* Agent信息 */ .agent-info { font-size: 12px; color: #999; margin-top: 8px; } @@ -635,12 +639,37 @@ if (!results || results.length === 0) return; const container = document.getElementById('messagesContainer'); - const div = document.createElement('div'); - div.className = 'message assistant'; - let html = `
🔍
-
-
搜索: ${escapeHtml(query.substring(0, 50))}${query.length > 50 ? '...' : ''}
`; + // 找到最后一条用户消息 + const userMessages = container.querySelectorAll('.message.user'); + const lastUserMsg = userMessages[userMessages.length - 1]; + + if (!lastUserMsg) { + // 没有用户消息,作为独立消息显示 + const div = document.createElement('div'); + div.className = 'message assistant'; + div.innerHTML = `
🔍
${buildSearchResultsHtml(results, query)}
`; + container.appendChild(div); + } else { + // 在用户消息的 message-body 中追加搜索结果 + const msgBody = lastUserMsg.querySelector('.message-body'); + if (msgBody) { + msgBody.innerHTML += buildSearchResultsHtml(results, query); + } + } + + // 滚动到底部 + container.scrollTop = container.scrollHeight; + } + + function buildSearchResultsHtml(results, query) { + const resultId = 'sr-' + Date.now(); + let html = `
+
+
搜索: ${escapeHtml(query.substring(0, 30))}${query.length > 30 ? '...' : ''} (${results.length}条结果)
+ 展开 +
+
`; for (const r of results) { html += `
@@ -651,11 +680,19 @@ } html += '
'; - div.innerHTML = html; - container.appendChild(div); - - // 滚动到底部 - container.scrollTop = container.scrollHeight; + return html; + } + + function toggleSearchResults(id) { + const content = document.getElementById(id); + const toggle = document.getElementById(id + '-toggle'); + if (content.classList.contains('expanded')) { + content.classList.remove('expanded'); + toggle.innerHTML = '展开 '; + } else { + content.classList.add('expanded'); + toggle.innerHTML = '收起 '; + } } // 会话管理