-
+
})
Date: Tue, 7 Jul 2026 19:18:42 +0800
Subject: [PATCH 5/5] feat: add generateTinyThumbnails config switch and remove
progressive loading frontend settings
---
src/components/common/CoverImage.astro | 30 +++++++------
src/components/common/ImageWrapper.astro | 29 ++++++------
.../controls/DisplaySettingsIntegrated.svelte | 44 +------------------
src/components/pages/gallery/AlbumCard.astro | 3 +-
src/components/pages/gallery/PhotoCard.astro | 13 +++---
src/config/siteConfig.ts | 2 +
src/pages/gallery/[album].astro | 2 +-
src/pages/sponsor.astro | 30 +++++++------
src/types/siteConfig.ts | 2 +
9 files changed, 65 insertions(+), 90 deletions(-)
diff --git a/src/components/common/CoverImage.astro b/src/components/common/CoverImage.astro
index b0be0b29c5..403bfe8a32 100644
--- a/src/components/common/CoverImage.astro
+++ b/src/components/common/CoverImage.astro
@@ -2,7 +2,7 @@
import { getImage, Picture } from "astro:assets";
import * as path from "node:path";
import type { ImageMetadata } from "astro";
-import { coverImageConfig } from "@/config";
+import { coverImageConfig, siteConfig } from "@/config";
import type { ImageFormat, ResponsiveImageLayout } from "@/types/config";
import {
getFallbackFormat,
@@ -139,19 +139,21 @@ const remoteReferrerPolicy =
// Generate tiny image for local or public images if available
let tinyImgUrl = "";
-if (isLocal && img) {
- try {
- const tinyImg = await getImage({ src: img, width: 32, quality: 30 });
- tinyImgUrl = tinyImg.src;
- } catch (e) {
- console.error("Failed to generate tiny thumbnail:", e);
- }
-} else if (isPublic && src) {
- try {
- const tinyImg = await getImage({ src: src, width: 32, quality: 30 });
- tinyImgUrl = tinyImg.src;
- } catch (e) {
- console.error("Failed to generate tiny thumbnail for public image:", e);
+if (siteConfig.post.generateTinyThumbnails) {
+ if (isLocal && img) {
+ try {
+ const tinyImg = await getImage({ src: img, width: 32, quality: 30 });
+ tinyImgUrl = tinyImg.src;
+ } catch (e) {
+ console.error("Failed to generate tiny thumbnail:", e);
+ }
+ } else if (isPublic && src) {
+ try {
+ const tinyImg = await getImage({ src: src, width: 32, quality: 30 });
+ tinyImgUrl = tinyImg.src;
+ } catch (e) {
+ console.error("Failed to generate tiny thumbnail for public image:", e);
+ }
}
}
---
diff --git a/src/components/common/ImageWrapper.astro b/src/components/common/ImageWrapper.astro
index 180e67b5af..0f211dd3aa 100644
--- a/src/components/common/ImageWrapper.astro
+++ b/src/components/common/ImageWrapper.astro
@@ -11,6 +11,7 @@ import {
} from "@/utils/image-utils";
import { getLqipProps } from "@/utils/lqip-utils";
import { url } from "@/utils/url-utils";
+import { siteConfig } from "@/config";
interface Props {
id?: string;
@@ -106,19 +107,21 @@ const lqipProps = isLocal
// Generate tiny image for local or public images if available
let tinyImgUrl = "";
-if (isLocal && img) {
- try {
- const tinyImg = await getImage({ src: img, width: 32, quality: 30 });
- tinyImgUrl = tinyImg.src;
- } catch (e) {
- console.error("Failed to generate tiny thumbnail:", e);
- }
-} else if (isPublic && src) {
- try {
- const tinyImg = await getImage({ src: src, width: 32, quality: 30 });
- tinyImgUrl = tinyImg.src;
- } catch (e) {
- console.error("Failed to generate tiny thumbnail for public image:", e);
+if (siteConfig.post.generateTinyThumbnails) {
+ if (isLocal && img) {
+ try {
+ const tinyImg = await getImage({ src: img, width: 32, quality: 30 });
+ tinyImgUrl = tinyImg.src;
+ } catch (e) {
+ console.error("Failed to generate tiny thumbnail:", e);
+ }
+ } else if (isPublic && src) {
+ try {
+ const tinyImg = await getImage({ src: src, width: 32, quality: 30 });
+ tinyImgUrl = tinyImg.src;
+ } catch (e) {
+ console.error("Failed to generate tiny thumbnail for public image:", e);
+ }
}
}
---
diff --git a/src/components/controls/DisplaySettingsIntegrated.svelte b/src/components/controls/DisplaySettingsIntegrated.svelte
index e53c295886..d863617e89 100644
--- a/src/components/controls/DisplaySettingsIntegrated.svelte
+++ b/src/components/controls/DisplaySettingsIntegrated.svelte
@@ -24,7 +24,6 @@ import {
getStoredOverlayBlur,
getStoredOverlayCardOpacity,
getStoredOverlayOpacity,
- getStoredProgressiveLoadingEnabled,
getStoredSakuraEnabled,
getStoredWallpaperMode,
getStoredWavesEnabled,
@@ -35,7 +34,6 @@ import {
setOverlayBlur,
setOverlayCardOpacity,
setOverlayOpacity,
- setProgressiveLoadingEnabled,
setSakuraEnabled,
setWallpaperMode,
setWavesEnabled,
@@ -84,7 +82,6 @@ let bannerCarouselEnabled = $state(true);
const defaultBannerCarouselEnabled = getDefaultBannerCarouselEnabled();
let sakuraEnabled = $state(true);
const defaultSakuraEnabled = getDefaultSakuraEnabled();
-let progressiveLoadingEnabled = $state(true);
let overlayOpacity = $state(getDefaultOverlayOpacity());
const defaultOverlayOpacity = getDefaultOverlayOpacity();
let overlayBlur = $state(getDefaultOverlayBlur());
@@ -312,10 +309,7 @@ function toggleSakuraEnabled() {
setSakuraEnabled(sakuraEnabled);
}
-function toggleProgressiveLoading() {
- progressiveLoadingEnabled = !progressiveLoadingEnabled;
- setProgressiveLoadingEnabled(progressiveLoadingEnabled);
-}
+
function switchWallpaperMode(newMode: WALLPAPER_MODE) {
wallpaperMode = newMode;
@@ -405,9 +399,6 @@ onMount(() => {
// 从localStorage读取樱花特效状态
sakuraEnabled = getStoredSakuraEnabled();
- // 从localStorage读取渐进式图片加载状态
- progressiveLoadingEnabled = getStoredProgressiveLoadingEnabled();
-
// 从localStorage读取全屏透明设置状态
overlayOpacity = getStoredOverlayOpacity();
overlayBlur = getStoredOverlayBlur();
@@ -757,38 +748,7 @@ $effect(() => {
{/if}
-
-