From c1407a84bbcde9836690a15aa6cf83922ee29d8f Mon Sep 17 00:00:00 2001 From: jing <1683105490@qq.com> Date: Sat, 29 Aug 2026 18:22:10 +0800 Subject: [PATCH] =?UTF-8?q?chore=EF=BC=9AH5=E7=99=BB=E5=BD=95=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages_tool/form/form.vue | 12 +++++++++++- pages_tool/form/formdata.vue | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/pages_tool/form/form.vue b/pages_tool/form/form.vue index b449bef..f8537be 100644 --- a/pages_tool/form/form.vue +++ b/pages_tool/form/form.vue @@ -282,7 +282,12 @@ !isFormNotOpen && (isLoginMsg || (dataIsEmpty && !this.storeToken && this.id)); - if (shouldTriggerLogin) { + if (shouldTriggerLogin && this.storeToken) { + // 已登录(storeToken 存在)但后端仍返回登录拦截: + // 登录一次后就不再自动弹登录/跳登录页(防止 H5 登录回跳后 token 未被 + // 及时认可或双请求竞态时反复弹登录的死循环),仅展示空态文案 + 手动登录按钮 + this.formError = this.$lang('form.form.loginRequired'); + } else if (shouldTriggerLogin) { this.formError = this.$lang('form.form.loginRequired'); this._openLoginWithRetry(); } else if (isFormNotOpen) { @@ -314,6 +319,11 @@ // 打开登录:3 次 setTimeout 重试(0ms / 60ms / 320ms) // 彻底覆盖 onLoad→回调→ns-login 尚未挂载的所有时序问题 _openLoginWithRetry() { + // 防重复触发:3 秒内只允许自动弹一次登录 + // (响应回调 / mounted 兜底 / watcher 同时命中时只生效一次,避免 H5 反复跳登录页) + const now = Date.now(); + if (this._lastAutoLoginAt && (now - this._lastAutoLoginAt) < 3000) return; + this._lastAutoLoginAt = now; const url = this.backUrl; let attempts = 0; const delays = [0, 60, 320]; diff --git a/pages_tool/form/formdata.vue b/pages_tool/form/formdata.vue index c7536ab..fd5345c 100644 --- a/pages_tool/form/formdata.vue +++ b/pages_tool/form/formdata.vue @@ -502,7 +502,12 @@ export default { !isFormNotOpen && (isLoginMsg || (dataIsEmpty && !this.storeToken && this.id)); - if (shouldTriggerLogin) { + if (shouldTriggerLogin && this.storeToken) { + // 已登录(storeToken 存在)但后端仍返回登录拦截: + // 登录一次后就不再自动弹登录/跳登录页(防止 H5 登录回跳后 token 未被 + // 及时认可或双请求竞态时反复弹登录的死循环),仅展示空态文案 + 手动登录按钮 + this.formError = this.$lang('form.form.loginRequired'); + } else if (shouldTriggerLogin) { this.formError = this.$lang('form.form.loginRequired'); this._openLoginWithRetry(); } else if (isFormNotOpen) { @@ -533,6 +538,11 @@ export default { // 打开登录:3 次 setTimeout 重试(0ms / 60ms / 320ms) // 彻底覆盖 onLoad→回调→ns-login 尚未挂载的所有时序问题 _openLoginWithRetry() { + // 防重复触发:3 秒内只允许自动弹一次登录 + // (响应回调 / mounted 兜底 / watcher 同时命中时只生效一次,避免 H5 反复跳登录页) + const now = Date.now(); + if (this._lastAutoLoginAt && (now - this._lastAutoLoginAt) < 3000) return; + this._lastAutoLoginAt = now; const url = this.backUrl; let attempts = 0; const delays = [0, 60, 320];