From d2aa115b5b65d058495136420faeab0b0cfcadf2 Mon Sep 17 00:00:00 2001 From: yuyx <237899745@qq.com> Date: Thu, 27 Nov 2025 15:24:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20SFTP=E4=B8=8B=E8=BD=BD=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=96=B0=E7=AA=97=E5=8F=A3=E6=89=93=E5=BC=80=E7=9B=B4=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - app.js downloadFile: SFTP有直链时用window.open新窗口打开 - share.html downloadFile: 分享页面同样处理 - 本地存储下载保持原有方式不变 - 解决HTTPS页面下载HTTP直链的Mixed Content问题 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- frontend/app.html | 2 +- frontend/app.js | 12 ++++++++---- frontend/share.html | 5 +++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/frontend/app.html b/frontend/app.html index 63d1bf1..fdf5d2f 100644 --- a/frontend/app.html +++ b/frontend/app.html @@ -2541,6 +2541,6 @@ } - + diff --git a/frontend/app.js b/frontend/app.js index c6dbe58..de3dee8 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -983,11 +983,15 @@ handleDragLeave(e) { downloadFile(file) { console.log("[DEBUG] 下载文件:", file); - const url = file.httpDownloadUrl - ? file.httpDownloadUrl - : `${this.apiBase}/api/files/download?path=${encodeURIComponent(this.currentPath === '/' ? `/${file.name}` : `${this.currentPath}/${file.name}`)}`; - // 统一通过隐藏链接触发下载,避免弹出新窗口 + // SFTP存储且有HTTP直链,新窗口打开直接下载(避免Mixed Content问题) + if (file.httpDownloadUrl) { + window.open(file.httpDownloadUrl, '_blank'); + return; + } + + // 本地存储,使用隐藏链接触发下载 + const url = `${this.apiBase}/api/files/download?path=${encodeURIComponent(this.currentPath === '/' ? `/${file.name}` : `${this.currentPath}/${file.name}`)}`; const link = document.createElement('a'); link.href = url; link.setAttribute('download', file.name); diff --git a/frontend/share.html b/frontend/share.html index c94fcb8..698cfbe 100644 --- a/frontend/share.html +++ b/frontend/share.html @@ -752,9 +752,10 @@ .catch(err => console.error('记录下载次数失败:', err)); if (file.httpDownloadUrl) { - // 如果配置了HTTP下载URL,使用HTTP直接下载 + // 如果配置了HTTP下载URL,新窗口打开直接下载(避免Mixed Content问题) console.log("[分享下载] 使用HTTP下载:", file.httpDownloadUrl); - this.triggerDownload(file.httpDownloadUrl, file.name); + window.open(file.httpDownloadUrl, '_blank'); + return; } else { // 如果没有配置HTTP URL,通过后端SFTP下载 console.log("[分享下载] 使用SFTP下载");