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 [isGGUF, setIsGGUF] = useState<boolean>(false);
const [fileName, setFileName] = useState<string>(''); const [fileName, setFileName] = useState<string>('');
const modelFileRef = useRef<any>(null); const modelFileRef = useRef<any>(null);
const [loading, setLoading] = useState<boolean>(false);
const generateModelInfo = () => { const generateModelInfo = () => {
if (source === modelSourceMap.huggingface_value) { if (source === modelSourceMap.huggingface_value) {
@@ -87,15 +88,20 @@ const DownloadModel: React.FC<AddModalProps> = (props) => {
setSelectedModel(item); setSelectedModel(item);
}; };
const handleOk = (values: any) => { const handleOk = async (values: any) => {
onOk({ setLoading(true);
await onOk({
...values, ...values,
source: source, source: source,
...generateModelInfo() ...generateModelInfo()
}); });
setLoading(false);
}; };
const handleSumit = () => { const handleSumit = () => {
if (loading) {
return;
}
form.current?.form?.submit?.(); form.current?.form?.submit?.();
}; };
@@ -218,6 +224,9 @@ const DownloadModel: React.FC<AddModalProps> = (props) => {
<ModalFooter <ModalFooter
onCancel={handleCancel} onCancel={handleCancel}
onOk={handleSumit} onOk={handleSumit}
okBtnProps={{
loading: loading
}}
style={{ style={{
padding: '16px 24px', padding: '16px 24px',
display: 'flex', display: 'flex',