mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: Display the knowledge graph on the knowledge base page #4543 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -1,7 +1,10 @@
|
||||
import { ReactComponent as ConfigurationIcon } from '@/assets/svg/knowledge-configration.svg';
|
||||
import { ReactComponent as DatasetIcon } from '@/assets/svg/knowledge-dataset.svg';
|
||||
import { ReactComponent as TestingIcon } from '@/assets/svg/knowledge-testing.svg';
|
||||
import { useFetchKnowledgeBaseConfiguration } from '@/hooks/knowledge-hooks';
|
||||
import {
|
||||
useFetchKnowledgeBaseConfiguration,
|
||||
useFetchKnowledgeGraph,
|
||||
} from '@/hooks/knowledge-hooks';
|
||||
import {
|
||||
useGetKnowledgeSearchParams,
|
||||
useSecondPathName,
|
||||
@ -14,6 +17,8 @@ import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'umi';
|
||||
import { KnowledgeRouteKey } from '../../constant';
|
||||
|
||||
import { isEmpty } from 'lodash';
|
||||
import { GitGraph } from 'lucide-react';
|
||||
import styles from './index.less';
|
||||
|
||||
const KnowledgeSidebar = () => {
|
||||
@ -30,6 +35,8 @@ const KnowledgeSidebar = () => {
|
||||
navigate(`/knowledge/${e.key}?id=${knowledgeId}`);
|
||||
};
|
||||
|
||||
const { data } = useFetchKnowledgeGraph();
|
||||
|
||||
type MenuItem = Required<MenuProps>['items'][number];
|
||||
|
||||
const getItem = useCallback(
|
||||
@ -54,7 +61,7 @@ const KnowledgeSidebar = () => {
|
||||
);
|
||||
|
||||
const items: MenuItem[] = useMemo(() => {
|
||||
return [
|
||||
const list = [
|
||||
getItem(
|
||||
KnowledgeRouteKey.Dataset, // TODO: Change icon color when selected
|
||||
KnowledgeRouteKey.Dataset,
|
||||
@ -71,7 +78,19 @@ const KnowledgeSidebar = () => {
|
||||
<ConfigurationIcon />,
|
||||
),
|
||||
];
|
||||
}, [getItem]);
|
||||
|
||||
if (!isEmpty(data.graph)) {
|
||||
list.push(
|
||||
getItem(
|
||||
KnowledgeRouteKey.KnowledgeGraph,
|
||||
KnowledgeRouteKey.KnowledgeGraph,
|
||||
<GitGraph />,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return list;
|
||||
}, [data, getItem]);
|
||||
|
||||
useEffect(() => {
|
||||
if (windowWidth.width > 957) {
|
||||
@ -81,7 +100,6 @@ const KnowledgeSidebar = () => {
|
||||
}
|
||||
}, [windowWidth.width]);
|
||||
|
||||
// 标记一下
|
||||
useEffect(() => {
|
||||
const widthSize = () => {
|
||||
const width = getWidth();
|
||||
|
||||
Reference in New Issue
Block a user