fix: move share quota block to download and add 3s download alert
This commit is contained in:
@@ -5661,9 +5661,9 @@ app.post('/api/share/:code/list', shareRateLimitMiddleware, async (req, res) =>
|
||||
shareLimiter.recordSuccess(req.shareRateLimitKey);
|
||||
}
|
||||
|
||||
// 获取分享者的用户信息
|
||||
const ownerPolicyState = enforceDownloadTrafficPolicy(share.user_id, 'share_download_url');
|
||||
const shareOwner = ownerPolicyState?.user || UserDB.findById(share.user_id);
|
||||
// 获取分享者的用户信息(查看列表不触发下载流量策略)
|
||||
// 仅在实际下载接口中校验和消耗下载流量,避免“可见性”受配额影响
|
||||
const shareOwner = UserDB.findById(share.user_id);
|
||||
if (!shareOwner) {
|
||||
return res.status(404).json({
|
||||
success: false,
|
||||
|
||||
@@ -791,6 +791,11 @@
|
||||
color: #991b1b;
|
||||
}
|
||||
|
||||
body.enterprise-netdisk-share .download-alert {
|
||||
margin-bottom: 12px;
|
||||
animation: fadeInOut 0.2s ease;
|
||||
}
|
||||
|
||||
body.enterprise-netdisk-share .view-controls {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
@@ -970,6 +975,17 @@
|
||||
padding: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fadeInOut {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-4px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="enterprise-netdisk-share">
|
||||
@@ -1016,6 +1032,7 @@
|
||||
|
||||
<!-- 文件列表 -->
|
||||
<div v-else-if="verified">
|
||||
<div v-if="downloadAlertMessage" class="alert alert-error download-alert">{{ downloadAlertMessage }}</div>
|
||||
<p class="share-meta-bar">
|
||||
分享者: <strong style="color: var(--text-primary);">{{ shareInfo.username }}</strong> |
|
||||
创建时间: {{ formatDate(shareInfo.created_at) }}
|
||||
@@ -1111,6 +1128,8 @@
|
||||
files: [],
|
||||
loading: true,
|
||||
errorMessage: '',
|
||||
downloadAlertMessage: '',
|
||||
downloadAlertTimer: null,
|
||||
viewMode: "grid", // 视图模式: grid 大图标, list 列表(默认大图标)
|
||||
// 主题
|
||||
currentTheme: 'dark',
|
||||
@@ -1176,6 +1195,7 @@
|
||||
|
||||
async verifyShare() {
|
||||
this.errorMessage = '';
|
||||
this.downloadAlertMessage = '';
|
||||
this.loading = true;
|
||||
|
||||
try {
|
||||
@@ -1288,10 +1308,28 @@
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[分享下载] 获取下载链接失败:', error);
|
||||
this.errorMessage = '获取下载链接失败: ' + (error.response?.data?.message || error.message);
|
||||
const message = error.response?.data?.message || '当前网络繁忙,请稍后再试';
|
||||
this.showDownloadAlert(message);
|
||||
}
|
||||
},
|
||||
|
||||
showDownloadAlert(message) {
|
||||
const safeMessage = typeof message === 'string' && message.trim()
|
||||
? message.trim()
|
||||
: '当前网络繁忙,请稍后再试';
|
||||
|
||||
this.downloadAlertMessage = safeMessage;
|
||||
if (this.downloadAlertTimer) {
|
||||
clearTimeout(this.downloadAlertTimer);
|
||||
this.downloadAlertTimer = null;
|
||||
}
|
||||
|
||||
this.downloadAlertTimer = setTimeout(() => {
|
||||
this.downloadAlertMessage = '';
|
||||
this.downloadAlertTimer = null;
|
||||
}, 3000);
|
||||
},
|
||||
|
||||
// 触发下载(使用隐藏的a标签,避免页面闪动)
|
||||
triggerDownload(url, filename) {
|
||||
const link = document.createElement('a');
|
||||
@@ -1430,6 +1468,13 @@
|
||||
}
|
||||
|
||||
this.init();
|
||||
},
|
||||
|
||||
beforeUnmount() {
|
||||
if (this.downloadAlertTimer) {
|
||||
clearTimeout(this.downloadAlertTimer);
|
||||
this.downloadAlertTimer = null;
|
||||
}
|
||||
}
|
||||
}).mount('#app');
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user