mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-26 08:56:47 +08:00
feat: remove loading from model and use DvaModel instead of redundant types such as kAModelType (#47)
* feat: use DvaModel instead of redundant types such as kAModelType * feat: set the type for registerServer * feat: remove loading from model
This commit is contained in:
@ -1,33 +1,39 @@
|
||||
import React from 'react';
|
||||
import { connect } from 'umi'
|
||||
import uploadService from '@/services/uploadService';
|
||||
import type { UploadProps } from 'antd';
|
||||
import { Button, Upload } from 'antd';
|
||||
import uploadService from '@/services/uploadService'
|
||||
import React from 'react';
|
||||
interface PropsType {
|
||||
kb_id: string;
|
||||
getKfList: () => void
|
||||
kb_id: string;
|
||||
getKfList: () => void;
|
||||
}
|
||||
|
||||
type UploadRequestOption = Parameters<
|
||||
NonNullable<UploadProps["customRequest"]>
|
||||
NonNullable<UploadProps['customRequest']>
|
||||
>[0];
|
||||
const Index: React.FC<PropsType> = ({ kb_id, getKfList }) => {
|
||||
const createRequest: (props: UploadRequestOption) => void = async function ({ file, onSuccess, onError }) {
|
||||
const { retcode, data } = await uploadService.uploadFile(file, kb_id);
|
||||
if (retcode === 0) {
|
||||
onSuccess && onSuccess(data, file);
|
||||
|
||||
} else {
|
||||
onError && onError(data);
|
||||
}
|
||||
getKfList && getKfList()
|
||||
};
|
||||
const uploadProps: UploadProps = {
|
||||
customRequest: createRequest,
|
||||
showUploadList: false,
|
||||
};
|
||||
return (<Upload {...uploadProps} >
|
||||
<Button type="link">导入文件</Button>
|
||||
</Upload>)
|
||||
}
|
||||
const FileUpload: React.FC<PropsType> = ({ kb_id, getKfList }) => {
|
||||
const createRequest: (props: UploadRequestOption) => void = async function ({
|
||||
file,
|
||||
onSuccess,
|
||||
onError,
|
||||
}) {
|
||||
const { retcode, data } = await uploadService.uploadFile(file, kb_id);
|
||||
if (retcode === 0) {
|
||||
onSuccess && onSuccess(data, file);
|
||||
} else {
|
||||
onError && onError(data);
|
||||
}
|
||||
getKfList && getKfList();
|
||||
};
|
||||
const uploadProps: UploadProps = {
|
||||
customRequest: createRequest,
|
||||
showUploadList: false,
|
||||
};
|
||||
return (
|
||||
<Upload {...uploadProps}>
|
||||
<Button type="link">导入文件</Button>
|
||||
</Upload>
|
||||
);
|
||||
};
|
||||
|
||||
export default connect(({ kFModel, settingModel, loading }) => ({ kFModel, settingModel, loading }))(Index);
|
||||
export default FileUpload;
|
||||
|
||||
Reference in New Issue
Block a user