fix: 历史消息显示图片/文件占位符
This commit is contained in:
@@ -410,19 +410,43 @@
|
|||||||
html += '</div>';
|
html += '</div>';
|
||||||
div.innerHTML = html;
|
div.innerHTML = html;
|
||||||
|
|
||||||
// 如果是用户消息且有搜索结果,在设置innerHTML后追加
|
// 如果是用户消息且有额外数据(搜索结果、图片、文件),在设置innerHTML后追加
|
||||||
if (role === 'user' && extraData) {
|
if (role === 'user' && extraData) {
|
||||||
console.log('Processing extraData for user message:', extraData);
|
console.log('Processing extraData for user message:', extraData);
|
||||||
console.log('search_results exists:', extraData.search_results);
|
const bodyDiv = div.querySelector('.message-body');
|
||||||
|
|
||||||
|
// 处理图片
|
||||||
|
if (extraData.images && extraData.images.length > 0) {
|
||||||
|
let imagesHtml = '<div class="history-images" style="margin-top:8px;display:flex;gap:8px;flex-wrap:wrap;">';
|
||||||
|
for (const img of extraData.images) {
|
||||||
|
// 历史记录只有图片元信息,显示占位符
|
||||||
|
imagesHtml += `<div class="history-image-placeholder" style="padding:8px 12px;background:#f0f0f0;border-radius:8px;display:flex;align-items:center;gap:6px;font-size:13px;color:#666;">
|
||||||
|
<i class="ri-image-line" style="color:#10a37f;"></i>
|
||||||
|
<span>${escapeHtml(img.name || '图片')}</span>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
imagesHtml += '</div>';
|
||||||
|
if (bodyDiv) bodyDiv.insertAdjacentHTML('beforeend', imagesHtml);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理文本文件
|
||||||
|
if (extraData.files && extraData.files.length > 0) {
|
||||||
|
let filesHtml = '<div class="history-files" style="margin-top:8px;">';
|
||||||
|
for (const f of extraData.files) {
|
||||||
|
filesHtml += `<div class="history-file-placeholder" style="padding:6px 10px;background:#f5f5f5;border-radius:6px;margin-bottom:4px;display:flex;align-items:center;gap:6px;font-size:12px;color:#666;">
|
||||||
|
<i class="ri-file-text-line" style="color:#10a37f;"></i>
|
||||||
|
<span>${escapeHtml(f.name || '文件')}</span>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
filesHtml += '</div>';
|
||||||
|
if (bodyDiv) bodyDiv.insertAdjacentHTML('beforeend', filesHtml);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理搜索结果
|
||||||
if (extraData.search_results && extraData.search_results.length > 0) {
|
if (extraData.search_results && extraData.search_results.length > 0) {
|
||||||
console.log('Building search results HTML for', extraData.search_results.length, 'results');
|
console.log('Building search results HTML for', extraData.search_results.length, 'results');
|
||||||
const searchHtml = buildSearchResultsHtml(extraData.search_results, extraData.search_query || content);
|
const searchHtml = buildSearchResultsHtml(extraData.search_results, extraData.search_query || content);
|
||||||
const bodyDiv = div.querySelector('.message-body');
|
if (bodyDiv) bodyDiv.insertAdjacentHTML('beforeend', searchHtml);
|
||||||
console.log('bodyDiv found:', bodyDiv != null);
|
|
||||||
if (bodyDiv) {
|
|
||||||
bodyDiv.insertAdjacentHTML('beforeend', searchHtml);
|
|
||||||
console.log('Search results HTML inserted');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user