mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### 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:
@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user