From fb31969195bc5ab9517d7c2d390525fe68a56511 Mon Sep 17 00:00:00 2001 From: yiqiu Date: Fri, 20 Mar 2026 09:48:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=98=E7=BD=91=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E5=B7=B2=E7=99=BB=E5=BD=95=E6=97=B6=E4=B8=8D=E5=86=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=99=BB=E5=BD=95/=E6=B3=A8=E5=86=8C=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tools.js syncLoginStatus 的 else 分支原来默认显示未登录, 但此时 AJAX 可能尚未返回。现在先检查 localStorage.jwt, 有 jwt 则不做操作等 AJAX 回调处理, 只有确认无 jwt 时才显示登录按钮 --- js/tools.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/js/tools.js b/js/tools.js index 39132ca..23556ad 100644 --- a/js/tools.js +++ b/js/tools.js @@ -83,11 +83,15 @@ $(function () { mobileHeadImg.textContent = desktopHeadImg.textContent; } } else { - // 默认显示未登录状态 - if (desktopNoLogin) desktopNoLogin.style.display = 'flex'; - if (desktopLoginIn) desktopLoginIn.style.display = 'none'; - if (mobileNoLogin) mobileNoLogin.style.display = 'block'; - if (mobileLoginIn) mobileLoginIn.style.display = 'none'; + // 两者都隐藏 — 可能是 AJAX 尚未返回 + // 若有 jwt 则不做操作, 等 common.js AJAX 回调处理 + if (!localStorage.jwt) { + // 确认未登录, 显示登录按钮 + if (desktopNoLogin) desktopNoLogin.style.display = 'flex'; + if (desktopLoginIn) desktopLoginIn.style.display = 'none'; + if (mobileNoLogin) mobileNoLogin.style.display = 'block'; + if (mobileLoginIn) mobileLoginIn.style.display = 'none'; + } } }