From 72a2b862a384a1d97beec67b0637cff845692cd7 Mon Sep 17 00:00:00 2001 From: x1ao4 Date: Thu, 28 Aug 2025 22:45:31 +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=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E5=8F=AF=E6=81=A2=E5=A4=8D=E9=94=99=E8=AF=AF=E9=87=8D=E8=AF=95?= =?UTF-8?q?=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - retry: 在 `getShareDetail` 将 “非法token/Bad Parameter/request error” 纳入可恢复错误 - 模态仍显示时清空 `stoken` 并延迟 600ms 自动重试一次 - 重试失败统一提示 “获取文件夹列表失败,请关闭窗口再试一次” --- app/templates/index.html | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/app/templates/index.html b/app/templates/index.html index c96ce44..7a1b390 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -4770,11 +4770,38 @@ this.checkPreviewScrollbar(); }); } + // 成功加载后关闭加载状态 + this.modalLoading = false; } else { - // 使用格式化函数处理错误信息 - this.fileSelect.error = this.formatShareUrlBanMessage(response.data.data.error); + // 非法token等可恢复错误:执行一次无感自动重试 + const rawError = (response && response.data && response.data.data && response.data.data.error) ? response.data.data.error : ''; + const errorText = typeof rawError === 'string' ? rawError : String(rawError || ''); + const isIllegalToken = errorText.includes('非法token') || errorText.includes('Bad Parameter'); + const isRequestError = errorText.toLowerCase().includes('request error'); + if (isIllegalToken || isRequestError) { + if (retryCount < maxRetries) { + console.log(`分享详情获取失败(${isIllegalToken ? '非法token' : 'request error'}),进行第 ${retryCount + 1} 次重试...`); + setTimeout(() => { + const fileSelectModal = document.getElementById('fileSelectModal'); + if (!(fileSelectModal && fileSelectModal.classList.contains('show'))) { + this.modalLoading = false; + return; + } + // 清空stoken以强制刷新 + this.fileSelect.stoken = ""; + this.getShareDetail(retryCount + 1, maxRetries); + }, 600); + return; // 等待重试结果,不立刻结束loading + } + // 重试已用尽,给出统一提示 + this.fileSelect.error = "获取文件夹列表失败,请关闭窗口再试一次"; + this.modalLoading = false; + } else { + // 使用格式化函数处理不可恢复错误 + this.fileSelect.error = this.formatShareUrlBanMessage(rawError); + this.modalLoading = false; + } } - this.modalLoading = false; }).catch(error => { // 增强版无感重试:清空 stoken 强制刷新令牌,并仅在模态框仍打开时重试 if (retryCount < maxRetries) {