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:
balibabu
2024-01-30 19:26:29 +08:00
committed by GitHub
parent 96a1a44cb6
commit 362ec6c364
29 changed files with 1911 additions and 1938 deletions

View File

@ -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;