feat: modify routing to nested mode and rename document (#52)

* feat: modify routing to nested mode

* feat: rename document
This commit is contained in:
balibabu
2024-02-02 18:49:54 +08:00
committed by GitHub
parent 503735cd1d
commit 7b71fb2db6
33 changed files with 681 additions and 175 deletions

View File

@ -0,0 +1,8 @@
import { useSearchParams } from 'umi';
export const useKnowledgeBaseId = (): string => {
const [searchParams] = useSearchParams();
const knowledgeBaseId = searchParams.get('id');
return knowledgeBaseId || '';
};

View 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);
};