Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(library): add CTA in folder hierarchy empty state (#15220)

Innei1d4d5c1c73b5
diff --git a/locales/en-US/file.json b/locales/en-US/file.json
index 18d7a1ddc2c..12dddb23e17 100644
--- a/locales/en-US/file.json
+++ b/locales/en-US/file.json
@@ -53,6 +53,8 @@
"home.uploadEntries.folder.title": "Upload Folder",
"home.uploadEntries.library.title": "Create New Library",
"home.uploadEntries.newPage.title": "New Page",
+ "library.hierarchy.empty.desc": "Add files or create a folder to get started",
+ "library.hierarchy.empty.title": "Nothing here yet",
"library.list.confirmRemoveLibrary": "You are about to delete this library. The files within it will not be deleted but moved to All Files. This action cannot be undone, so please proceed with caution.",
"library.list.empty": "Click <1>+</1> to create a new library",
"library.new": "New Library",
diff --git a/locales/zh-CN/file.json b/locales/zh-CN/file.json
index 18c79f85b65..fe992eab2e8 100644
--- a/locales/zh-CN/file.json
+++ b/locales/zh-CN/file.json
@@ -53,6 +53,8 @@
"home.uploadEntries.folder.title": "上传文件夹",
"home.uploadEntries.library.title": "新建资源库",
"home.uploadEntries.newPage.title": "新建文稿",
+ "library.hierarchy.empty.desc": "上传文件或新建文件夹开始整理",
+ "library.hierarchy.empty.title": "这里还没有内容",
"library.list.confirmRemoveLibrary": "将删除该资源库(其中的文件不会删除,会移入「全部文件」)。删除后不可恢复,建议确认无误再继续",
"library.list.empty": "点击 <1>+</1> 创建第一个资源库",
"library.new": "新建资源库",
diff --git a/src/features/ResourceManager/components/LibraryHierarchy/index.tsx b/src/features/ResourceManager/components/LibraryHierarchy/index.tsx
index 3b246a1c12e..9487077a65d 100644
--- a/src/features/ResourceManager/components/LibraryHierarchy/index.tsx
+++ b/src/features/ResourceManager/components/LibraryHierarchy/index.tsx
@@ -1,7 +1,10 @@
'use client';
-import { Flexbox } from '@lobehub/ui';
+import { Center, Flexbox, Icon, Text } from '@lobehub/ui';
+import { cssVar } from 'antd-style';
+import { FolderPlusIcon } from 'lucide-react';
import { memo, useEffect, useMemo } from 'react';
+import { useTranslation } from 'react-i18next';
import { VList } from 'virtua';
import { useFolderPath } from '@/routes/(main)/resource/features/hooks/useFolderPath';
@@ -9,6 +12,7 @@ import { useResourceManagerStore } from '@/routes/(main)/resource/features/store
import type { TreeItem } from '@/store/tree';
import { useTreeStore } from '@/store/tree';
+import AddButton from '../Header/AddButton';
import { KnowledgeBaseListProvider } from '../KnowledgeBaseListProvider';
import { HierarchyNode } from './HierarchyNode';
import TreeSkeleton from './TreeSkeleton';
@@ -21,6 +25,7 @@ interface VisibleNode {
}
const LibraryHierarchy = memo(() => {
+ const { t } = useTranslation('file');
const { currentFolderSlug } = useFolderPath();
const [libraryId, currentViewItemId] = useResourceManagerStore((s) => [
s.libraryId,
@@ -69,6 +74,24 @@ const LibraryHierarchy = memo(() => {
}
const selectedKey = currentFolderSlug ?? null;
+ const isRootEmpty = !isLoading && libraryId && visibleNodes.length === 0;
+
+ if (isRootEmpty) {
+ return (
+ <KnowledgeBaseListProvider>
+ <Center gap={16} padding={24} style={{ height: '100%', textAlign: 'center' }}>
+ <Icon color={cssVar.colorTextQuaternary} icon={FolderPlusIcon} size={36} />
+ <Flexbox align={'center'} gap={4}>
+ <Text strong>{t('library.hierarchy.empty.title')}</Text>
+ <Text style={{ fontSize: 12 }} type={'secondary'}>
+ {t('library.hierarchy.empty.desc')}
+ </Text>
+ </Flexbox>
+ <AddButton />
+ </Center>
+ </KnowledgeBaseListProvider>
+ );
+ }
return (
<KnowledgeBaseListProvider>
diff --git a/src/locales/default/file.ts b/src/locales/default/file.ts
index 613868a6f1f..f121c0b337e 100644
--- a/src/locales/default/file.ts
+++ b/src/locales/default/file.ts
@@ -55,6 +55,8 @@ export default {
'home.uploadEntries.folder.title': 'Upload Folder',
'home.uploadEntries.library.title': 'Create New Library',
'home.uploadEntries.newPage.title': 'New Page',
+ 'library.hierarchy.empty.desc': 'Add files or create a folder to get started',
+ 'library.hierarchy.empty.title': 'Nothing here yet',
'library.list.confirmRemoveLibrary':
'You are about to delete this library. The files within it will not be deleted but moved to All Files. This action cannot be undone, so please proceed with caution.',
'library.list.empty': 'Click <1>+</1> to create a new library',