diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index e3bb702..df7e220 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -137,12 +137,14 @@ function App() {
// 如果没有选中文件夹且没有搜索条件,不加载图片(保持在 Dashboard)
(imageState.selectedFolder || imageState.searchKeywords || imageState.filters.formats.length > 0 || imageState.favoritesView)
? imageAPI.search(libraryId, params)
- : Promise.resolve({ images: [] }),
+ : Promise.resolve({ images: null }), // null = 本次不刷新图片(平铺库由 MainContent 直接加载,避免清空已显示的图片)
// 扫描完成后重新获取统计信息(包含 totalSize)
imageAPI.getStats(libraryId)
]).then(([foldersRes, imagesRes, statsRes]) => {
useImageStore.getState().setFolders(foldersRes.folders);
- useImageStore.getState().setImages(imagesRes.images);
+ if (imagesRes.images) {
+ useImageStore.getState().setImages(imagesRes.images);
+ }
useImageStore.getState().setTotalImageCount(statsRes.total || 0);
useImageStore.getState().setTotalSize(statsRes.totalSize || 0);
}).catch(err => {
diff --git a/frontend/src/components/Dashboard.jsx b/frontend/src/components/Dashboard.jsx
index f645b68..dc555d3 100644
--- a/frontend/src/components/Dashboard.jsx
+++ b/frontend/src/components/Dashboard.jsx
@@ -99,7 +99,9 @@ function Dashboard() {
- 您的素材库似乎是空的。请将图片添加到素材库目录中,系统会自动扫描。 + {totalImageCount > 0 + ? `此素材库的 ${totalImageCount} 张图片没有子文件夹,已在下方瀑布视图中直接显示。` + : '您的素材库似乎是空的。请将图片添加到素材库目录中,系统会自动扫描。'}
)} diff --git a/frontend/src/components/MainContent.jsx b/frontend/src/components/MainContent.jsx index dd2820e..e3dae46 100644 --- a/frontend/src/components/MainContent.jsx +++ b/frontend/src/components/MainContent.jsx @@ -15,7 +15,7 @@ const logger = createLogger('MainContent'); function MainContent() { const { currentLibraryId } = useLibraryStore(); - const { searchKeywords, filters, selectedFolder, favoritesView, setImages, setOriginalImages, imageLoadingState, images, refreshTick } = useImageStore(); + const { searchKeywords, filters, selectedFolder, favoritesView, setImages, setOriginalImages, imageLoadingState, images, refreshTick, folders, foldersLoaded } = useImageStore(); const { scanProgress } = useScanStore(); // 使用 ref 跟踪最新的请求上下文 @@ -47,8 +47,8 @@ function MainContent() { const loadImages = useCallback(async (isInitialLoad = true) => { if (!currentLibraryId) return; - // 如果没有选中文件夹且没有搜索条件,显示 Dashboard(「我的收藏」视图除外) - if (!selectedFolder && !searchKeywords && filters.formats.length === 0 && !favoritesView) { + // 如果没有选中文件夹且没有搜索条件,显示 Dashboard(「我的收藏」视图除外;无子文件夹的平铺库直接进瀑布) + if (!selectedFolder && !searchKeywords && filters.formats.length === 0 && !favoritesView && (!foldersLoaded || folders.length > 0)) { setImages([]); useImageStore.getState().setImageLoadingState({ isLoading: false, @@ -162,7 +162,7 @@ function MainContent() { clearTimeout(debounceTimerRef.current); } }; - }, [currentLibraryId, searchKeywords, selectedFolder, favoritesView, refreshTick, loadImages, cancelCurrentRequest]); + }, [currentLibraryId, searchKeywords, selectedFolder, favoritesView, refreshTick, folders, foldersLoaded, loadImages, cancelCurrentRequest]); // 恢复撤销前的文件夹状态 useEffect(() => { @@ -233,7 +233,7 @@ function MainContent() { {/* Content */}