update code level

This commit is contained in:
lychang
2026-03-23 02:38:17 +08:00
parent 743d23cfee
commit 4115c04107
8 changed files with 662 additions and 95 deletions

View File

@@ -128,8 +128,7 @@ function displayImages() {
const title = image.title || `图片 ${index + 1}`;
// 检查图片是否已被收藏
const isFavorited = isImageFavorited(image.id || image.original_url);
isImageFavorited(image.id || image.original_url);
return `
<div class="image-item ${orientation}" onclick="openLightbox(${index})">
<img
@@ -334,6 +333,15 @@ function initLightboxControls() {
const lightbox = document.getElementById('lightbox');
if (!lightbox.classList.contains('active')) return;
// 检查点击目标是否是导航按钮或关闭按钮
const target = event.target;
const isNavButton = target.closest('.preview-nav') || target.closest('.preview-close');
if (isNavButton) {
// 如果是按钮点击,不处理轻点关闭逻辑
return;
}
const touchEndX = event.changedTouches[0].clientX;
const touchEndY = event.changedTouches[0].clientY;
@@ -347,6 +355,8 @@ function initLightboxControls() {
} else {
nextImage();
}
// 滑动操作后阻止轻点关闭判断
return;
}
// 轻点关闭(如果移动距离很小)
@@ -435,7 +445,6 @@ function checkLightboxFavoriteStatus() {
const image = images[currentImageIndex];
const imageId = image.id;
const favoriteBtn = document.getElementById('lightbox-favorite-btn');
console.log(image)
if (!imageId || !favoriteBtn) return;
// 检查收藏状态