Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a3def9702b | |||
| cd1f95bb2c |
@@ -146,6 +146,17 @@
|
||||
.modal-buttons { display: flex; gap: 12px; justify-content: flex-end; }
|
||||
.modal-buttons button { padding: 8px 16px; border-radius: 8px; cursor: pointer; }
|
||||
|
||||
/* 图片放大弹窗 */
|
||||
.image-lightbox { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.9); display: none; align-items: center; justify-content: center; z-index: 2000; cursor: zoom-out; }
|
||||
.image-lightbox.show { display: flex; }
|
||||
.image-lightbox img { max-width: 90%; max-height: 90%; border-radius: 8px; box-shadow: 0 0 30px rgba(255,255,255,0.2); }
|
||||
.image-lightbox-close { position: absolute; top: 20px; right: 20px; width: 40px; height: 40px; background: rgba(255,255,255,0.2); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 20px; cursor: pointer; transition: background 0.2s; }
|
||||
.image-lightbox-close:hover { background: rgba(255,255,255,0.3); }
|
||||
|
||||
/* 对话中的图片可点击 */
|
||||
.uploaded-image img { cursor: zoom-in; transition: transform 0.2s; }
|
||||
.uploaded-image img:hover { transform: scale(1.02); }
|
||||
|
||||
.welcome { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: #666; }
|
||||
.welcome h2 { font-size: 28px; margin-bottom: 16px; color: #333; }
|
||||
|
||||
@@ -211,6 +222,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 图片放大弹窗 -->
|
||||
<div class="image-lightbox" id="imageLightbox" onclick="closeImageLightbox()">
|
||||
<div class="image-lightbox-close"><i class="ri-close-line"></i></div>
|
||||
<img id="lightboxImage" src="" alt="放大图片">
|
||||
</div>
|
||||
|
||||
<!-- Markdown渲染库 -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||
<script>
|
||||
@@ -393,19 +410,43 @@
|
||||
html += '</div>';
|
||||
div.innerHTML = html;
|
||||
|
||||
// 如果是用户消息且有搜索结果,在设置innerHTML后追加
|
||||
// 如果是用户消息且有额外数据(搜索结果、图片、文件),在设置innerHTML后追加
|
||||
if (role === 'user' && 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) {
|
||||
console.log('Building search results HTML for', extraData.search_results.length, 'results');
|
||||
const searchHtml = buildSearchResultsHtml(extraData.search_results, extraData.search_query || content);
|
||||
const bodyDiv = div.querySelector('.message-body');
|
||||
console.log('bodyDiv found:', bodyDiv != null);
|
||||
if (bodyDiv) {
|
||||
bodyDiv.insertAdjacentHTML('beforeend', searchHtml);
|
||||
console.log('Search results HTML inserted');
|
||||
}
|
||||
if (bodyDiv) bodyDiv.insertAdjacentHTML('beforeend', searchHtml);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -858,7 +899,7 @@
|
||||
for (const f of files) {
|
||||
if (f.type.startsWith('image/')) {
|
||||
// 图片直接显示
|
||||
html += `<div class="uploaded-image" style="margin-bottom:8px"><img src="${f.content}" style="max-width:300px;border-radius:8px"></div>`;
|
||||
html += `<div class="uploaded-image" style="margin-bottom:8px"><img src="${f.content}" style="max-width:300px;border-radius:8px" onclick="openImageLightbox('${f.content}')"></div>`;
|
||||
} else {
|
||||
// 文本文件显示名称和内容摘要
|
||||
html += `<div class="uploaded-file" style="padding:8px;background:#f5f5f5;border-radius:6px;margin-bottom:8px">`;
|
||||
@@ -1014,6 +1055,26 @@
|
||||
}
|
||||
|
||||
document.getElementById('newPhraseInput').addEventListener('keydown', e => { if (e.key === 'Enter') addPhrase(); if (e.key === 'Escape') hidePhraseModal(); });
|
||||
|
||||
// 图片放大弹窗
|
||||
function openImageLightbox(imageSrc) {
|
||||
const lightbox = document.getElementById('imageLightbox');
|
||||
const lightboxImg = document.getElementById('lightboxImage');
|
||||
lightboxImg.src = imageSrc;
|
||||
lightbox.classList.add('show');
|
||||
}
|
||||
|
||||
function closeImageLightbox() {
|
||||
const lightbox = document.getElementById('imageLightbox');
|
||||
lightbox.classList.remove('show');
|
||||
}
|
||||
|
||||
// ESC键关闭图片弹窗
|
||||
document.addEventListener('keydown', e => {
|
||||
if (e.key === 'Escape') {
|
||||
closeImageLightbox();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user