mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
feat: transform the parser's data structure and add Image to TestingResult (#63)
* feat: add Image to TestingResult * feat: transform the parser's data structure
This commit is contained in:
@ -28,7 +28,7 @@ import {
|
||||
UploadProps,
|
||||
} from 'antd';
|
||||
import classNames from 'classnames';
|
||||
import { ReactElement, useEffect, useRef, useState } from 'react';
|
||||
import { ReactElement, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Nullable } from 'typings';
|
||||
import { Link, useDispatch, useNavigate, useSelector } from 'umi';
|
||||
|
||||
@ -63,6 +63,24 @@ const UploaderItem = ({
|
||||
|
||||
const documentId = file?.response?.id;
|
||||
|
||||
const parserList = useMemo(() => {
|
||||
return parserArray.map((x) => {
|
||||
const arr = x.split(':');
|
||||
return { value: arr[0], label: arr[1] };
|
||||
});
|
||||
}, [parserArray]);
|
||||
|
||||
const saveParser = (parserId: string) => {
|
||||
dispatch({
|
||||
type: 'kFModel/document_change_parser',
|
||||
payload: {
|
||||
parser_id: parserId,
|
||||
doc_id: documentId,
|
||||
parser_config: parserConfig,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const onChange = (e: RadioChangeEvent) => {
|
||||
const val = e.target.value;
|
||||
setValue(val);
|
||||
@ -72,12 +90,12 @@ const UploaderItem = ({
|
||||
const content = (
|
||||
<Radio.Group onChange={onChange} value={value}>
|
||||
<Space direction="vertical">
|
||||
{parserArray.map(
|
||||
{parserList.map(
|
||||
(
|
||||
x, // value is lowercase, key is uppercase
|
||||
) => (
|
||||
<Radio value={x.toLowerCase()} key={x}>
|
||||
{x}
|
||||
<Radio value={x.value} key={x.value}>
|
||||
{x.label}
|
||||
</Radio>
|
||||
),
|
||||
)}
|
||||
@ -92,17 +110,6 @@ const UploaderItem = ({
|
||||
}
|
||||
};
|
||||
|
||||
const saveParser = (parserId: string) => {
|
||||
dispatch({
|
||||
type: 'kFModel/document_change_parser',
|
||||
payload: {
|
||||
parser_id: parserId,
|
||||
doc_id: documentId,
|
||||
parser_config: parserConfig,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setValue(defaultParserId);
|
||||
}, [defaultParserId]);
|
||||
|
||||
Reference in New Issue
Block a user