diff --git a/src/theme/logic.tsx b/src/theme/logic.tsx index 029a83b..43e0fff 100644 --- a/src/theme/logic.tsx +++ b/src/theme/logic.tsx @@ -7,25 +7,24 @@ import { Button } from "@mui/material"; import { saveAs } from 'file-saver'; -async function downloadFile(url: string, filename?: string): Promise { - try { - const response = await fetch(url); +async function downloadFile(url: string): Promise { + try { + url="https://gitproxy.click/"+url; + const response = await fetch(url); - if (!response.ok) { - throw new Error(`HTTP error! Status: ${response.status}`); - } + if (!response.ok) { + throw new Error(`HTTP error! Status: ${response.status}`); + } - const blob = await response.blob(); + const blob = await response.blob(); - if (!filename) { - const urlSegments = url.split('/'); - filename = urlSegments[urlSegments.length - 1]; - } + const urlSegments = url.split('/'); + let filename = urlSegments[urlSegments.length - 1]; - saveAs(blob, filename); - } catch (error) { - console.error('下载文件时出错:', error); - } + saveAs(blob, filename); + } catch (error) { + console.error('下载文件时出错:', error); + } } @@ -51,11 +50,11 @@ const GetDownloadAddress = () => { // 更新 onClick 函数逻辑 const onClick = (req: string) => { - if (req==""){ + if (req == "") { setSnackbarSeverity("error"); setSnackbarMessage("请输入链接再开始下载"); setSnackbarOpen(true); - }else if (req.startsWith('https://')) { + } else if (req.startsWith('https://')) { setSnackbarSeverity("success"); setSnackbarMessage("下载即将开始"); setSnackbarOpen(true); @@ -64,7 +63,7 @@ const GetDownloadAddress = () => { setSnackbarMessage("无效的链接,请使用 HTTPS 链接。"); setSnackbarOpen(true); } - saveAs(req) + downloadFile(req) }; return ( @@ -77,15 +76,15 @@ const GetDownloadAddress = () => { onClick(address.value) }} sx={{ minWidth: 'fit-content' }}> - 开始下载 - + 开始下载 + setSnackbarOpen(false)} message={snackbarMessage} severity={snackbarSeverity} /> - + ); }; diff --git a/tmp/runner-build b/tmp/runner-build deleted file mode 100755 index 46ceff9..0000000 Binary files a/tmp/runner-build and /dev/null differ