From 484e68a82d90ed457e1be25646357700b888ee48 Mon Sep 17 00:00:00 2001 From: x1ao4 Date: Thu, 28 Aug 2025 22:05:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E6=96=87=E4=BB=B6=E5=A4=B9/=E5=88=86?= =?UTF-8?q?=E4=BA=AB=E8=AF=A6=E6=83=85=E5=8A=A0=E8=BD=BD=E5=BC=95=E5=85=A5?= =?UTF-8?q?=E6=97=A0=E6=84=9F=E8=87=AA=E5=8A=A8=E9=87=8D=E8=AF=95=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=B1=E8=B4=A5=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增:在 `getSavepathDetail` 失败时自动无感重试一次 - 仅在 `#fileSelectModal` 仍显示时触发重试,避免误重试 - 为请求参数追加 `_ts` 时间戳,绕过浏览器/代理缓存导致的伪重试 - 新增:在 `getShareDetail` 失败时自动无感重试一次 - 重试前强制清空 `this.fileSelect.stoken`,让后端重新获取有效 `stoken` - 仅在 `#fileSelectModal` 仍显示时触发重试 - 超过最大重试次数后,立即提示“获取文件夹列表失败,请关闭窗口再试一次”,不再继续等待 原因: - 原有“等待1秒再调一次”的重试在令牌失效或缓存命中时无效,用户需手动关窗再点 - 本次改动通过刷新 `stoken` 与规避缓存,实现与“手动关窗再点”接近的效果,且对用户无感 --- app/templates/index.html | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/app/templates/index.html b/app/templates/index.html index 98acf0f..c96ce44 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -4628,15 +4628,23 @@ } this.modalLoading = false; }).catch(error => { - // 如果还有重试次数,则进行重试 + // 增强版无感重试:添加缓存破坏参数,并仅在模态框仍打开时重试 if (retryCount < maxRetries) { console.log(`获取文件夹列表失败,正在进行第 ${retryCount + 1} 次重试...`); - // 短暂延迟后重试 setTimeout(() => { + // 确保模态框仍处于打开状态,否则中止并结束loading + const fileSelectModal = document.getElementById('fileSelectModal'); + if (!(fileSelectModal && fileSelectModal.classList.contains('show'))) { + this.modalLoading = false; + return; + } + // 为请求参数添加时间戳,避免潜在的缓存干扰 + if (typeof params === 'object' && params !== null) { + params._ts = Date.now(); + } this.getSavepathDetail(params, retryCount + 1, maxRetries); - }, 1000); // 1秒后重试 + }, 600); } else { - // 超过最大重试次数,显示错误信息 this.fileSelect.error = "获取文件夹列表失败,请关闭窗口再试一次"; this.modalLoading = false; } @@ -4768,15 +4776,20 @@ } this.modalLoading = false; }).catch(error => { - // 如果还有重试次数,则进行重试 + // 增强版无感重试:清空 stoken 强制刷新令牌,并仅在模态框仍打开时重试 if (retryCount < maxRetries) { console.log(`获取文件夹列表失败,正在进行第 ${retryCount + 1} 次重试...`); - // 短暂延迟后重试 setTimeout(() => { + const fileSelectModal = document.getElementById('fileSelectModal'); + if (!(fileSelectModal && fileSelectModal.classList.contains('show'))) { + this.modalLoading = false; + return; + } + // 清空stoken,促使后端重新获取有效的stoken + this.fileSelect.stoken = ""; this.getShareDetail(retryCount + 1, maxRetries); - }, 1000); // 1秒后重试 + }, 600); } else { - // 超过最大重试次数,显示错误信息 this.fileSelect.error = "获取文件夹列表失败,请关闭窗口再试一次"; this.modalLoading = false; }