Revert "fix: 修复HTTPS页面下载HTTP直链的Mixed Content问题"
This reverts commit a4c94b1f68.
This commit is contained in:
@@ -2541,6 +2541,6 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script src="app.js?v=20251127002"></script>
|
<script src="app.js?v=20251127001"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -983,28 +983,9 @@ handleDragLeave(e) {
|
|||||||
|
|
||||||
downloadFile(file) {
|
downloadFile(file) {
|
||||||
console.log("[DEBUG] 下载文件:", file);
|
console.log("[DEBUG] 下载文件:", file);
|
||||||
|
const url = file.httpDownloadUrl
|
||||||
// 构建后端代理下载URL
|
? file.httpDownloadUrl
|
||||||
const proxyUrl = `${this.apiBase}/api/files/download?path=${encodeURIComponent(this.currentPath === '/' ? `/${file.name}` : `${this.currentPath}/${file.name}`)}`;
|
: `${this.apiBase}/api/files/download?path=${encodeURIComponent(this.currentPath === '/' ? `/${file.name}` : `${this.currentPath}/${file.name}`)}`;
|
||||||
|
|
||||||
let url = proxyUrl;
|
|
||||||
|
|
||||||
// 检查是否有HTTP直链可用
|
|
||||||
if (file.httpDownloadUrl) {
|
|
||||||
// 检测Mixed Content:HTTPS页面不能加载HTTP资源
|
|
||||||
const isHttpsPage = window.location.protocol === 'https:';
|
|
||||||
const isHttpLink = file.httpDownloadUrl.startsWith('http://');
|
|
||||||
|
|
||||||
if (isHttpsPage && isHttpLink) {
|
|
||||||
// HTTPS页面 + HTTP直链 = Mixed Content,使用后端代理
|
|
||||||
console.log("[DEBUG] 检测到Mixed Content,使用后端代理下载");
|
|
||||||
this.showToast('info', '提示', '由于安全限制,正在通过服务器代理下载');
|
|
||||||
url = proxyUrl;
|
|
||||||
} else {
|
|
||||||
// 可以使用直链
|
|
||||||
url = file.httpDownloadUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 统一通过隐藏链接触发下载,避免弹出新窗口
|
// 统一通过隐藏链接触发下载,避免弹出新窗口
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
@@ -1222,25 +1203,13 @@ handleDragLeave(e) {
|
|||||||
? `/${file.name}`
|
? `/${file.name}`
|
||||||
: `${this.currentPath}/${file.name}`;
|
: `${this.currentPath}/${file.name}`;
|
||||||
|
|
||||||
// 构建后端代理URL
|
// SFTP存储且配置了HTTP下载URL,使用HTTP直接访问;否则使用API下载
|
||||||
const proxyUrl = `${this.apiBase}/api/files/download?path=${encodeURIComponent(filePath)}`;
|
|
||||||
|
|
||||||
// SFTP存储且配置了HTTP下载URL
|
|
||||||
if (file.httpDownloadUrl) {
|
if (file.httpDownloadUrl) {
|
||||||
// 检测Mixed Content:HTTPS页面不能加载HTTP资源
|
|
||||||
const isHttpsPage = window.location.protocol === 'https:';
|
|
||||||
const isHttpLink = file.httpDownloadUrl.startsWith('http://');
|
|
||||||
|
|
||||||
if (isHttpsPage && isHttpLink) {
|
|
||||||
// HTTPS页面 + HTTP直链 = Mixed Content,使用后端代理
|
|
||||||
console.log("[DEBUG] 媒体预览检测到Mixed Content,使用后端代理");
|
|
||||||
return proxyUrl;
|
|
||||||
}
|
|
||||||
return file.httpDownloadUrl;
|
return file.httpDownloadUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 本地存储或未配置HTTP URL,使用API下载(同域 Cookie 验证)
|
// 本地存储或未配置HTTP URL,使用API下载(同域 Cookie 验证)
|
||||||
return proxyUrl;
|
return `${this.apiBase}/api/files/download?path=${encodeURIComponent(filePath)}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取文件缩略图URL
|
// 获取文件缩略图URL
|
||||||
|
|||||||
Reference in New Issue
Block a user