From d561837a9eaabf268f2a3800ed765be61138373d Mon Sep 17 00:00:00 2001 From: meowrain Date: Mon, 5 Jan 2026 22:48:47 +0800 Subject: [PATCH] fix --- src/pages/gallery.astro | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/pages/gallery.astro b/src/pages/gallery.astro index 361c717..25e1ce7 100644 --- a/src/pages/gallery.astro +++ b/src/pages/gallery.astro @@ -148,7 +148,7 @@ import { Icon } from "astro-icon/components"; // 从JSON文件加载图片数据 async function loadImagesData() { try { - const response = await fetch('/api/i/images.json'); + const response = await fetch('https://blog.meowrain.cn/api/i/images.json'); if (!response.ok) { throw new Error('Failed to load images data'); } @@ -307,6 +307,9 @@ import { Icon } from "astro-icon/components"; grid.classList.remove('opacity-0'); }); + // 显示 sentinel + if (sentinel) sentinel.classList.remove('hidden'); + // 设置 Intersection Observer if (observer) observer.disconnect(); observer = new IntersectionObserver((entries) => { @@ -595,8 +598,13 @@ import { Icon } from "astro-icon/components"; initFilterButtons(); } - // 初始化 - initGallery(); + // 初始化 - 等待 DOM 准备好 + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', initGallery); + } else { + // 延迟执行确保 Swup 容器已准备好 + setTimeout(initGallery, 0); + } // Resize handler if (window.galleryResizeHandler) window.removeEventListener('resize', window.galleryResizeHandler);