feat: switch OSS download quota to reservation plus log reconcile

This commit is contained in:
2026-02-17 18:12:33 +08:00
parent b171b41599
commit 10a3f09952
3 changed files with 669 additions and 50 deletions

View File

@@ -1554,10 +1554,8 @@ handleDragLeave(e) {
// OSS 下载优先使用直连(避免服务器中转导致带宽与费用双重损耗)
if (canDirectOssDownload) {
const directResult = await this.downloadFromOSS(filePath);
if (directResult) {
return;
}
await this.downloadFromOSS(filePath);
return;
}
// 其他场景走后端下载接口(支持下载流量计量/权限控制)
@@ -1584,7 +1582,12 @@ handleDragLeave(e) {
document.body.removeChild(link);
return true;
} catch (error) {
console.error('OSS直连下载失败,将回退到后端下载:', error);
console.error('OSS直连下载失败:', error);
const message = error.response?.data?.message || '下载失败,请稍后重试';
this.showToast('error', '下载失败', message);
if (error.response?.status === 401) {
this.logout();
}
return false;
}
},
@@ -1888,10 +1891,8 @@ handleDragLeave(e) {
? `/${file.name}`
: `${this.currentPath}/${file.name}`;
const hasDownloadTrafficLimit = Number(this.user?.download_traffic_quota || 0) > 0;
// OSS 模式且未启用下载流量限制时,返回签名 URL用于媒体预览
if (this.storageType === 'oss' && this.user?.oss_config_source !== 'none' && !hasDownloadTrafficLimit) {
// OSS 模式优先直连,避免限流场景回退为后端中转
if (this.storageType === 'oss' && this.user?.oss_config_source !== 'none') {
try {
const { data } = await axios.get(`${this.apiBase}/api/files/download-url`, {
params: { path: filePath }
@@ -1902,6 +1903,7 @@ handleDragLeave(e) {
} catch (error) {
console.error('获取媒体URL失败:', error);
}
return null;
}
// 本地存储模式:通过后端 API