mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-10-01 19:16:43 +00:00

* feat: select the corresponding parsing method according to the file type * feat: after the document is successfully uploaded, use the ChunkMethodModal to select the parsing method. * feat: add pdf types to ParserListMap * feat: remove ChunkMethodModal from knowledge-file
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
|
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
|
import { useCallback, useState } from 'react';
|
|
import { useSetModalState } from './commonHooks';
|
|
import { useSetDocumentParser } from './documentHooks';
|
|
import { useOneNamespaceEffectsLoading } from './storeHooks';
|
|
|
|
export const useChangeDocumentParser = (documentId: string) => {
|
|
const setDocumentParser = useSetDocumentParser();
|
|
|
|
const {
|
|
visible: changeParserVisible,
|
|
hideModal: hideChangeParserModal,
|
|
showModal: showChangeParserModal,
|
|
} = useSetModalState();
|
|
const loading = useOneNamespaceEffectsLoading('kFModel', [
|
|
'document_change_parser',
|
|
]);
|
|
|
|
const onChangeParserOk = useCallback(
|
|
async (parserId: string, parserConfig: IChangeParserConfigRequestBody) => {
|
|
const ret = await setDocumentParser(parserId, documentId, parserConfig);
|
|
if (ret === 0) {
|
|
hideChangeParserModal();
|
|
}
|
|
},
|
|
[hideChangeParserModal, setDocumentParser, documentId],
|
|
);
|
|
|
|
return {
|
|
changeParserLoading: loading,
|
|
onChangeParserOk,
|
|
changeParserVisible,
|
|
hideChangeParserModal,
|
|
showChangeParserModal,
|
|
};
|
|
};
|
|
|
|
export const useSetSelectedRecord = <T = IKnowledgeFile>() => {
|
|
const [currentRecord, setCurrentRecord] = useState<T>({} as T);
|
|
|
|
const setRecord = (record: T) => {
|
|
setCurrentRecord(record);
|
|
};
|
|
|
|
return { currentRecord, setRecord };
|
|
};
|