From 1d26b682fc4545e943185851a68a56706d289fe5 Mon Sep 17 00:00:00 2001 From: root <3234374354@qq.com> Date: Thu, 6 Feb 2025 20:44:55 +0800 Subject: [PATCH] =?UTF-8?q?refactor(videos):=20=E4=BC=98=E5=8C=96=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E4=B8=8B=E8=BD=BD=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了使用 fetch API 下载视频的复杂逻辑 - 采用直接创建 元素并触发点击的方法简化下载过程 - 修改了下载文件名的生成逻辑,使用 URL 的最后一部分作为文件名 --- index/videos/template-video.html | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/index/videos/template-video.html b/index/videos/template-video.html index e06c8108..5b25188b 100644 --- a/index/videos/template-video.html +++ b/index/videos/template-video.html @@ -98,18 +98,12 @@ }); function downloadVideo() { - fetch(videoUrl) - .then(response => response.blob()) - .then(blob => { - const link = document.createElement('a'); - link.href = URL.createObjectURL(blob); - link.download = videoTitle + '.mp4'; // 设置下载文件名 + var link = document.createElement('a'); + link.href = videoUrl; + link.download = videoUrl.split('/').pop(); document.body.appendChild(link); link.click(); document.body.removeChild(link); - URL.revokeObjectURL(link.href); - }) - .catch(error => console.error('Error downloading the video:', error)); }