fix: improve reservation cleanup and share popup handling
This commit is contained in:
@@ -3181,11 +3181,25 @@ handleDragLeave(e) {
|
||||
|
||||
openShare(url) {
|
||||
if (!url) return;
|
||||
const newWindow = window.open(url, '_blank', 'noopener');
|
||||
if (!newWindow || newWindow.closed || typeof newWindow.closed === 'undefined') {
|
||||
// 弹窗被拦截时提示用户手动打开,避免当前页跳转
|
||||
this.showToast('info', '提示', '浏览器阻止了新标签页,请允许弹窗或手动打开链接');
|
||||
// 仅在真正被拦截(返回 null/undefined)时提示,避免已打开仍误报
|
||||
let newWindow = null;
|
||||
try {
|
||||
newWindow = window.open(url, '_blank');
|
||||
} catch (error) {
|
||||
newWindow = null;
|
||||
}
|
||||
|
||||
if (newWindow) {
|
||||
try {
|
||||
// 防止新窗口通过 opener 反向控制当前页面
|
||||
newWindow.opener = null;
|
||||
} catch (e) {
|
||||
// 忽略跨域写 opener 失败
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this.showToast('info', '提示', '浏览器阻止了新标签页,请允许弹窗或手动打开链接');
|
||||
},
|
||||
|
||||
copyTextToClipboard(text, successMessage = '已复制到剪贴板') {
|
||||
@@ -4559,15 +4573,17 @@ handleDragLeave(e) {
|
||||
|
||||
async cleanupReservations() {
|
||||
if (this.reservationMonitor.cleaning) return;
|
||||
if (!confirm('确认清理过期/历史预扣记录吗?')) return;
|
||||
if (!confirm('确认清理预扣历史吗?将立即删除已完成/已过期/已取消记录。')) return;
|
||||
|
||||
this.reservationMonitor.cleaning = true;
|
||||
try {
|
||||
const response = await axios.post(`${this.apiBase}/api/admin/download-reservations/cleanup`, {
|
||||
keep_days: 7
|
||||
keep_days: 0
|
||||
});
|
||||
if (response.data?.success) {
|
||||
this.showToast('success', '成功', response.data.message || '预扣清理完成');
|
||||
const result = response.data?.result || {};
|
||||
const msg = `已清理历史 ${Number(result.deleted_finalized || 0)} 条,过期待确认 ${Number(result.expired_pending || 0)} 条`;
|
||||
this.showToast('success', '成功', msg);
|
||||
await this.loadDownloadReservationMonitor(1);
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user