From 6d3c965cf72fb0451830a032acff6c0c00eb59ad Mon Sep 17 00:00:00 2001 From: kicer Date: Mon, 31 Aug 2026 19:43:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8B=E8=BD=BD=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=A2=AB=E8=BF=BD=E5=8A=A0=20.bin=20=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E5=90=8D=EF=BC=9Ablob=20=E7=BD=AE=E7=A9=BA=20MIME?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=E7=A7=BB=E5=8A=A8=E7=AB=AF=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E6=8C=89=20octet-stream=20=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E8=A1=A5=20.bin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/server/public/js/app.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/server/public/js/app.js b/app/server/public/js/app.js index c81c9ce..befae69 100644 --- a/app/server/public/js/app.js +++ b/app/server/public/js/app.js @@ -369,15 +369,16 @@ async function downloadFile(name) { const url = '/api/sessions/' + state.sessionId + '/files/download?path=' + encodeURIComponent(name); const res = await fetch(url); if (!res.ok) throw new Error('HTTP ' + res.status); - const blob = await res.blob(); + let blob = await res.blob(); + // 抹掉 blob 的 MIME:响应常为 octet-stream,部分移动端浏览器内核会按类型给下载名追加 .bin,抹掉后按原名保存 + try { blob = new Blob([blob], { type: '' }); } catch (_) {} const dlUrl = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = dlUrl; a.download = name.split('/').pop() || 'download'; document.body.appendChild(a); a.click(); - a.remove(); - setTimeout(function () { URL.revokeObjectURL(dlUrl); }, 1000); + setTimeout(function () { a.remove(); URL.revokeObjectURL(dlUrl); }, 1000); } catch (e) { toast('下载失败:' + e.message); }