Feat: Jump from the chunk page to the dataset page #3221 (#4961)

### What problem does this PR solve?
Feat: Jump from the chunk page to the dataset page #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-02-14 13:30:55 +08:00
committed by GitHub
parent 986062a604
commit 26add87c3d
7 changed files with 111 additions and 4 deletions

View File

@ -1,9 +1,14 @@
import { Routes } from '@/routes';
import { useCallback } from 'react';
import { useNavigate } from 'umi';
import { useNavigate, useSearchParams } from 'umi';
export enum QueryStringMap {
KnowledgeId = 'knowledgeId',
}
export const useNavigatePage = () => {
const navigate = useNavigate();
const [searchParams] = useSearchParams();
const navigateToDatasetList = useCallback(() => {
navigate(Routes.Datasets);
@ -32,6 +37,30 @@ export const useNavigatePage = () => {
navigate(Routes.Chat);
}, [navigate]);
const navigateToChunkParsedResult = useCallback(
(id: string, knowledgeId?: string) => () => {
navigate(
`${Routes.ParsedResult}/${id}?${QueryStringMap.KnowledgeId}=${knowledgeId}`,
);
},
[navigate],
);
const getQueryString = useCallback(
(queryStringKey?: QueryStringMap) => {
const allQueryString = {
[QueryStringMap.KnowledgeId]: searchParams.get(
QueryStringMap.KnowledgeId,
),
};
if (queryStringKey) {
return allQueryString[queryStringKey];
}
return allQueryString;
},
[searchParams],
);
return {
navigateToDatasetList,
navigateToDataset,
@ -39,5 +68,7 @@ export const useNavigatePage = () => {
navigateToProfile,
navigateToChatList,
navigateToChat,
navigateToChunkParsedResult,
getQueryString,
};
};