import { useKnowledgeBaseId } from '@/hooks/knowledge-hooks'; import { useNavigateWithFromState, useSecondPathName, useThirdPathName, } from '@/hooks/route-hook'; import { Breadcrumb } from 'antd'; import { ItemType } from 'antd/es/breadcrumb/Breadcrumb'; import { useEffect, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { Link, Outlet, useDispatch, useLocation } from 'umi'; import Siderbar from './components/knowledge-sidebar'; import { KnowledgeDatasetRouteKey, KnowledgeRouteKey } from './constant'; import styles from './index.less'; const KnowledgeAdding = () => { const dispatch = useDispatch(); const knowledgeBaseId = useKnowledgeBaseId(); const { t } = useTranslation(); const location = useLocation(); const activeKey: KnowledgeRouteKey = (useSecondPathName() as KnowledgeRouteKey) || KnowledgeRouteKey.Dataset; const datasetActiveKey: KnowledgeDatasetRouteKey = useThirdPathName() as KnowledgeDatasetRouteKey; const gotoList = useNavigateWithFromState(); const breadcrumbItems: ItemType[] = useMemo(() => { const items: ItemType[] = [ { title: ( gotoList('/knowledge')}> {t('header.knowledgeBase')} ), }, { title: datasetActiveKey ? ( {t(`knowledgeDetails.${activeKey}`)} ) : ( t(`knowledgeDetails.${activeKey}`) ), }, ]; if (datasetActiveKey) { items.push({ title: t(`knowledgeDetails.${datasetActiveKey}`), }); } return items; }, [activeKey, datasetActiveKey, gotoList, knowledgeBaseId, t]); useEffect(() => { const search: string = location.search.slice(1); const map = search.split('&').reduce>((obj, cur) => { const [key, value] = cur.split('='); obj[key] = value; return obj; }, {}); dispatch({ type: 'kAModel/updateState', payload: { doc_id: undefined, ...map, }, }); }, [location, dispatch]); return ( <>
); }; export default KnowledgeAdding;