From 849e6e795250523b364ca65ca1f31f1b66f60566 Mon Sep 17 00:00:00 2001 From: Chen Date: Thu, 4 Dec 2025 18:14:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=E4=B9=8B=E9=97=B4=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/MainContent.jsx | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/MainContent.jsx b/frontend/src/components/MainContent.jsx index 39d6f2c..7536fcc 100644 --- a/frontend/src/components/MainContent.jsx +++ b/frontend/src/components/MainContent.jsx @@ -133,7 +133,7 @@ function MainContent() { } }, [currentLibraryId, searchKeywords, selectedFolder, setImages, setOriginalImages, cancelCurrentRequest]); - // 监听文件夹/搜索/筛选变化 + // 监听文件夹/搜索变化 useEffect(() => { if (!currentLibraryId) return; @@ -145,21 +145,18 @@ function MainContent() { // 立即取消之前的请求(关键!) cancelCurrentRequest(); - // 清空当前图片并设置加载中状态(防止闪烁"暂无图片") - setImages([]); + // 🎯 优化:不立即清空图片,保持当前显示直到新数据加载完成 + // 只设置加载状态,让用户知道正在切换 useImageStore.getState().setImageLoadingState({ - isLoading: true, // 关键:立即设为加载中 - loadedCount: 0, - totalCount: 0, + isLoading: true, + loadedCount: imageLoadingState.loadedCount, + totalCount: imageLoadingState.totalCount, hasMore: false }); - - // 清理图片缓存 - imageCache.clear(); // 使用防抖避免快速连续点击 debounceTimerRef.current = setTimeout(() => { - loadImages(true); // 初始加载 + loadImages(true); // 初始加载(会在完成时替换图片) }, 50); return () => { @@ -167,7 +164,7 @@ function MainContent() { clearTimeout(debounceTimerRef.current); } }; - }, [currentLibraryId, searchKeywords, selectedFolder, loadImages, cancelCurrentRequest, setImages]); + }, [currentLibraryId, searchKeywords, selectedFolder, loadImages, cancelCurrentRequest]); // 组件卸载时清理 useEffect(() => {