From 3ea730b29bdd2e587575e343a54023555ae15a97 Mon Sep 17 00:00:00 2001 From: lq Date: Tue, 17 Jun 2025 20:28:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E7=9B=B8=E5=86=8C=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/css/index.css | 2 +- resources/views/detail.blade.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/public/css/index.css b/public/css/index.css index da29f233..906b550d 100644 --- a/public/css/index.css +++ b/public/css/index.css @@ -235,7 +235,7 @@ body::after { .photo-grid { display: grid; - grid-template-columns: repeat(auto-fill, minmax(45%, 1fr)); + grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 2rem; } diff --git a/resources/views/detail.blade.php b/resources/views/detail.blade.php index 40d5e0ba..771e0c9b 100644 --- a/resources/views/detail.blade.php +++ b/resources/views/detail.blade.php @@ -81,6 +81,7 @@ let currentPhotos = []; let currentRotation = 0; + // 显示相册详情 // 显示相册详情 function showAlbumDetail(album) { currentAlbum = album; @@ -108,7 +109,6 @@ // 添加点击事件 photoItem.addEventListener('click', () => { currentPhotoIndex = index; - // showPhotoPreview(photo.original); showPhotoPreview(photo.compressed); }); @@ -117,7 +117,13 @@ entries.forEach(entry => { if (entry.isIntersecting) { const lazyImage = entry.target; - lazyImage.src = lazyImage.dataset.src; + const src = lazyImage.dataset.src; + + // 移除data-src属性确保只加载一次 + lazyImage.removeAttribute('data-src'); + + // 设置src属性开始加载 + lazyImage.src = src; // 图片加载完成后显示 lazyImage.onload = () => { @@ -127,6 +133,7 @@ } }; + // 停止观察 observer.unobserve(lazyImage); } });