mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
feat: modify routing to nested mode and rename document (#52)
* feat: modify routing to nested mode * feat: rename document
This commit is contained in:
8
web/src/hooks/knowledgeHook.ts
Normal file
8
web/src/hooks/knowledgeHook.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { useSearchParams } from 'umi';
|
||||
|
||||
export const useKnowledgeBaseId = (): string => {
|
||||
const [searchParams] = useSearchParams();
|
||||
const knowledgeBaseId = searchParams.get('id');
|
||||
|
||||
return knowledgeBaseId || '';
|
||||
};
|
||||
21
web/src/hooks/routeHook.ts
Normal file
21
web/src/hooks/routeHook.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { useLocation } from 'umi';
|
||||
|
||||
export enum SegmentIndex {
|
||||
Second = '2',
|
||||
Third = '3',
|
||||
}
|
||||
|
||||
export const useSegmentedPathName = (index: SegmentIndex) => {
|
||||
const { pathname } = useLocation();
|
||||
|
||||
const pathArray = pathname.split('/');
|
||||
return pathArray[index] || '';
|
||||
};
|
||||
|
||||
export const useSecondPathName = () => {
|
||||
return useSegmentedPathName(SegmentIndex.Second);
|
||||
};
|
||||
|
||||
export const useThirdPathName = () => {
|
||||
return useSegmentedPathName(SegmentIndex.Third);
|
||||
};
|
||||
Reference in New Issue
Block a user