This commit is contained in:
parent
b03a310fc7
commit
334e5c50e9
|
|
@ -538,11 +538,62 @@ export function DetailPageHeader({ data }: { data: any }) {
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!data?.model_parameter && (
|
{/* {!data?.model_parameter && (
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
console.log("开始下载文件...");
|
console.log("开始下载文件...");
|
||||||
window.open("https://example.com/path/to/your/file.tar.gz", "_blank");
|
window.open("https://updsrv.szaiai.com/api/v1/cloud/download", "_blank");
|
||||||
|
}}
|
||||||
|
className="hover:text-gray-700 transition self-end"
|
||||||
|
title="下载模型文件"
|
||||||
|
>
|
||||||
|
<CloudDownload size={20} />
|
||||||
|
</button>
|
||||||
|
)} */}
|
||||||
|
|
||||||
|
{!data?.model_parameter && (
|
||||||
|
<button
|
||||||
|
onClick={async () => {
|
||||||
|
try {
|
||||||
|
const download_url = data?.extra_data?.download_url;
|
||||||
|
const size = data?.extra_data?.size;
|
||||||
|
const id = data?.id;
|
||||||
|
|
||||||
|
if (!download_url || !size || !id) {
|
||||||
|
message.warning("缺少必要的下载参数");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("📥 调用下载接口...", { url: download_url, size, id });
|
||||||
|
|
||||||
|
const res = await fetch("https://updsrv.szaiai.com/api/v1/cloud/download", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
url: download_url,
|
||||||
|
size: size,
|
||||||
|
id: id,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await res.json();
|
||||||
|
console.log("✅ 下载接口返回:", result);
|
||||||
|
|
||||||
|
if (result?.header?.code === 0) {
|
||||||
|
const downloaded = result?.data?.downloaded;
|
||||||
|
const total = result?.data?.total;
|
||||||
|
|
||||||
|
const percent = total > 0 ? ((downloaded / total) * 100).toFixed(2) : "0";
|
||||||
|
message.success(`📦 下载进度:${downloaded} / ${total} 字节(${percent}%)`);
|
||||||
|
} else {
|
||||||
|
message.warning(`❌ 下载失败:${result?.header?.message || "未知错误"}`);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error("❌ 下载请求异常:", err);
|
||||||
|
message.error("请求出错,无法下载");
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
className="hover:text-gray-700 transition self-end"
|
className="hover:text-gray-700 transition self-end"
|
||||||
title="下载模型文件"
|
title="下载模型文件"
|
||||||
|
|
@ -551,7 +602,6 @@ export function DetailPageHeader({ data }: { data: any }) {
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue