mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-24 23:46:52 +08:00
### What problem does this PR solve? Feat: Scrolling knowledge base list and set the number of entries per page to 30 #3695 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
.knowledge {
|
||||
padding: 48px 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.topWrapper {
|
||||
|
||||
@ -1,18 +1,26 @@
|
||||
import { useNextFetchKnowledgeList } from '@/hooks/knowledge-hooks';
|
||||
import { useInfiniteFetchKnowledgeList } from '@/hooks/knowledge-hooks';
|
||||
import { useFetchUserInfo } from '@/hooks/user-setting-hooks';
|
||||
import { PlusOutlined, SearchOutlined } from '@ant-design/icons';
|
||||
import { Button, Empty, Flex, Input, Space, Spin } from 'antd';
|
||||
import {
|
||||
Button,
|
||||
Divider,
|
||||
Empty,
|
||||
Flex,
|
||||
Input,
|
||||
Skeleton,
|
||||
Space,
|
||||
Spin,
|
||||
} from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import InfiniteScroll from 'react-infinite-scroll-component';
|
||||
import { useSaveKnowledge } from './hooks';
|
||||
import KnowledgeCard from './knowledge-card';
|
||||
import KnowledgeCreatingModal from './knowledge-creating-modal';
|
||||
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useSaveKnowledge, useSearchKnowledge } from './hooks';
|
||||
import { useMemo } from 'react';
|
||||
import styles from './index.less';
|
||||
|
||||
const KnowledgeList = () => {
|
||||
const { searchString, handleInputChange } = useSearchKnowledge();
|
||||
const { loading, list: data } = useNextFetchKnowledgeList();
|
||||
const list = data.filter((x) => x.name.includes(searchString));
|
||||
const { data: userInfo } = useFetchUserInfo();
|
||||
const { t } = useTranslation('translation', { keyPrefix: 'knowledgeList' });
|
||||
const {
|
||||
@ -22,9 +30,23 @@ const KnowledgeList = () => {
|
||||
onCreateOk,
|
||||
loading: creatingLoading,
|
||||
} = useSaveKnowledge();
|
||||
const {
|
||||
fetchNextPage,
|
||||
data,
|
||||
hasNextPage,
|
||||
searchString,
|
||||
handleInputChange,
|
||||
loading,
|
||||
} = useInfiniteFetchKnowledgeList();
|
||||
console.log('🚀 ~ KnowledgeList ~ data:', data);
|
||||
const nextList = data?.pages?.flatMap((x) => x.kbs) ?? [];
|
||||
|
||||
const total = useMemo(() => {
|
||||
return data?.pages.at(-1).total ?? 0;
|
||||
}, [data?.pages]);
|
||||
|
||||
return (
|
||||
<Flex className={styles.knowledge} vertical flex={1}>
|
||||
<Flex className={styles.knowledge} vertical flex={1} id="scrollableDiv">
|
||||
<div className={styles.topWrapper}>
|
||||
<div>
|
||||
<span className={styles.title}>
|
||||
@ -53,21 +75,30 @@ const KnowledgeList = () => {
|
||||
</Space>
|
||||
</div>
|
||||
<Spin spinning={loading}>
|
||||
<Flex
|
||||
gap={'large'}
|
||||
wrap="wrap"
|
||||
className={styles.knowledgeCardContainer}
|
||||
<InfiniteScroll
|
||||
dataLength={nextList?.length ?? 0}
|
||||
next={fetchNextPage}
|
||||
hasMore={hasNextPage}
|
||||
loader={<Skeleton avatar paragraph={{ rows: 1 }} active />}
|
||||
endMessage={total && <Divider plain>{t('noMoreData')} 🤐</Divider>}
|
||||
scrollableTarget="scrollableDiv"
|
||||
>
|
||||
{list.length > 0 ? (
|
||||
list.map((item: any) => {
|
||||
return (
|
||||
<KnowledgeCard item={item} key={item.name}></KnowledgeCard>
|
||||
);
|
||||
})
|
||||
) : (
|
||||
<Empty className={styles.knowledgeEmpty}></Empty>
|
||||
)}
|
||||
</Flex>
|
||||
<Flex
|
||||
gap={'large'}
|
||||
wrap="wrap"
|
||||
className={styles.knowledgeCardContainer}
|
||||
>
|
||||
{nextList?.length > 0 ? (
|
||||
nextList.map((item: any) => {
|
||||
return (
|
||||
<KnowledgeCard item={item} key={item.name}></KnowledgeCard>
|
||||
);
|
||||
})
|
||||
) : (
|
||||
<Empty className={styles.knowledgeEmpty}></Empty>
|
||||
)}
|
||||
</Flex>
|
||||
</InfiniteScroll>
|
||||
</Spin>
|
||||
<KnowledgeCreatingModal
|
||||
loading={creatingLoading}
|
||||
|
||||
Reference in New Issue
Block a user