mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-20 21:06:54 +08:00
Unified API response json schema (#3170)
### What problem does this PR solve? Unified API response json schema ### Type of change - [x] Refactoring
This commit is contained in:
@ -30,7 +30,7 @@ const ChunkCreatingModal: React.FC<IModalProps<any> & kFProps> = ({
|
||||
const { t } = useTranslation();
|
||||
|
||||
useEffect(() => {
|
||||
if (data?.retcode === 0) {
|
||||
if (data?.code === 0) {
|
||||
const { content_with_weight, important_kwd = [] } = data.data;
|
||||
form.setFieldsValue({ content: content_with_weight });
|
||||
setKeywords(important_kwd);
|
||||
|
||||
@ -96,14 +96,14 @@ export const useUpdateChunk = () => {
|
||||
|
||||
const onChunkUpdatingOk = useCallback(
|
||||
async ({ content, keywords }: { content: string; keywords: string }) => {
|
||||
const retcode = await createChunk({
|
||||
const code = await createChunk({
|
||||
content_with_weight: content,
|
||||
doc_id: documentId,
|
||||
chunk_id: chunkId,
|
||||
important_kwd: keywords, // keywords
|
||||
});
|
||||
|
||||
if (retcode === 0) {
|
||||
if (code === 0) {
|
||||
hideChunkUpdatingModal();
|
||||
}
|
||||
},
|
||||
|
||||
@ -148,20 +148,20 @@ export const useHandleUploadDocument = () => {
|
||||
async (fileList: UploadFile[]): Promise<number | undefined> => {
|
||||
if (fileList.length > 0) {
|
||||
const ret: any = await uploadDocument(fileList);
|
||||
if (typeof ret?.retmsg !== 'string') {
|
||||
if (typeof ret?.message !== 'string') {
|
||||
return;
|
||||
}
|
||||
const count = getUnSupportedFilesCount(ret?.retmsg);
|
||||
const count = getUnSupportedFilesCount(ret?.message);
|
||||
/// 500 error code indicates that some file types are not supported
|
||||
let retcode = ret?.retcode;
|
||||
let code = ret?.code;
|
||||
if (
|
||||
ret?.retcode === 0 ||
|
||||
(ret?.retcode === 500 && count !== fileList.length) // Some files were not uploaded successfully, but some were uploaded successfully.
|
||||
ret?.code === 0 ||
|
||||
(ret?.code === 500 && count !== fileList.length) // Some files were not uploaded successfully, but some were uploaded successfully.
|
||||
) {
|
||||
retcode = 0;
|
||||
code = 0;
|
||||
hideDocumentUploadModal();
|
||||
}
|
||||
return retcode;
|
||||
return code;
|
||||
}
|
||||
},
|
||||
[uploadDocument, hideDocumentUploadModal],
|
||||
|
||||
Reference in New Issue
Block a user