fix: add loading on download button

This commit is contained in:
jialin
2025-11-06 19:38:01 +08:00
parent cd2942405a
commit 39efca0d4c
+11 -2
View File
@@ -63,6 +63,7 @@ const DownloadModel: React.FC<AddModalProps> = (props) => {
const [isGGUF, setIsGGUF] = useState<boolean>(false);
const [fileName, setFileName] = useState<string>('');
const modelFileRef = useRef<any>(null);
const [loading, setLoading] = useState<boolean>(false);
const generateModelInfo = () => {
if (source === modelSourceMap.huggingface_value) {
@@ -87,15 +88,20 @@ const DownloadModel: React.FC<AddModalProps> = (props) => {
setSelectedModel(item);
};
const handleOk = (values: any) => {
onOk({
const handleOk = async (values: any) => {
setLoading(true);
await onOk({
...values,
source: source,
...generateModelInfo()
});
setLoading(false);
};
const handleSumit = () => {
if (loading) {
return;
}
form.current?.form?.submit?.();
};
@@ -218,6 +224,9 @@ const DownloadModel: React.FC<AddModalProps> = (props) => {
<ModalFooter
onCancel={handleCancel}
onOk={handleSumit}
okBtnProps={{
loading: loading
}}
style={{
padding: '16px 24px',
display: 'flex',