fix: 平铺库(无子文件夹)直接进瀑布视图 — 修复进入库后误显'素材库似乎是空的'且无法浏览图片
- useImageStore: 新增 foldersLoaded 标记,区分「文件夹加载中」与「确认无子文件夹」 - MainContent: 早退/渲染分支加条件 — folders 加载完成且为空时不再停 Dashboard,直接请求全部图片 - App: scan 回调 images=null 不再清空已显示图片 - Dashboard: 空文案按 totalImageCount 分流(有图时不再误报空库)
This commit is contained in:
1 parent
a365c4ce42
commit
03fb69f892
4 files changed
+14
-9
No files matched your search
@@ -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 */}
|
||||
<div className="flex-1 overflow-hidden">
|
||||
{(!selectedFolder && !searchKeywords && filters.formats.length === 0 && !favoritesView) ? (
|
||||
{(!selectedFolder && !searchKeywords && filters.formats.length === 0 && !favoritesView && (!foldersLoaded || folders.length > 0)) ? (
|
||||
<Dashboard />
|
||||
) : (
|
||||
<ImageWaterfall />
|
||||
|
||||
Reference in new issue
Block a user