import React from 'react'; import { connect } from 'umi' import type { UploadProps } from 'antd'; import { Button, Upload } from 'antd'; import uploadService from '@/services/uploadService' interface PropsType { kb_id: string; getKfList: () => void } type UploadRequestOption = Parameters< NonNullable >[0]; const Index: React.FC = ({ 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 ( ) } export default connect(({ kFModel, settingModel, loading }) => ({ kFModel, settingModel, loading }))(Index);