From 4a1362d626ba5365abb3477147c75afbd2b4a6c9 Mon Sep 17 00:00:00 2001 From: moux1024 <403053463@qq.com> Date: Tue, 14 Oct 2025 18:50:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E5=85=BC=E5=AE=B9encode?= =?UTF-8?q?=E8=BF=87=E7=9A=84=E4=B8=8B=E8=BD=BDurl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/tools.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/utils/tools.ts b/utils/tools.ts index a51de10..c9940d2 100644 --- a/utils/tools.ts +++ b/utils/tools.ts @@ -86,7 +86,15 @@ export const downloadVideo = async (url: string) => { const blobUrl = window.URL.createObjectURL(blob); const a = document.createElement('a'); a.href = blobUrl; - a.download = modifyUrl.split('/').pop() || 'video.mp4'; + let filename = 'video.mp4'; + try { + const parsed = new URL(modifyUrl); + filename = parsed.pathname.split('/').pop() || 'video.mp4'; + if (filename.includes('?')) filename = filename.split('?')[0]; + if (filename.includes('#')) filename = filename.split('#')[0]; + } catch {} + a.download = filename; + console.log(a.download); document.body.appendChild(a); a.click(); document.body.removeChild(a);