feat: 图片点击放大功能
This commit is contained in:
@@ -146,6 +146,17 @@
|
|||||||
.modal-buttons { display: flex; gap: 12px; justify-content: flex-end; }
|
.modal-buttons { display: flex; gap: 12px; justify-content: flex-end; }
|
||||||
.modal-buttons button { padding: 8px 16px; border-radius: 8px; cursor: pointer; }
|
.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 { 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; }
|
.welcome h2 { font-size: 28px; margin-bottom: 16px; color: #333; }
|
||||||
|
|
||||||
@@ -211,6 +222,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</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渲染库 -->
|
<!-- Markdown渲染库 -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
@@ -858,7 +875,7 @@
|
|||||||
for (const f of files) {
|
for (const f of files) {
|
||||||
if (f.type.startsWith('image/')) {
|
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 {
|
} else {
|
||||||
// 文本文件显示名称和内容摘要
|
// 文本文件显示名称和内容摘要
|
||||||
html += `<div class="uploaded-file" style="padding:8px;background:#f5f5f5;border-radius:6px;margin-bottom:8px">`;
|
html += `<div class="uploaded-file" style="padding:8px;background:#f5f5f5;border-radius:6px;margin-bottom:8px">`;
|
||||||
@@ -1014,6 +1031,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById('newPhraseInput').addEventListener('keydown', e => { if (e.key === 'Enter') addPhrase(); if (e.key === 'Escape') hidePhraseModal(); });
|
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>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user