fix: 官网首页已登录时不再显示登录/注册按钮
All checks were successful
continuous-integration/drone/push Build is passing

tools.js syncLoginStatus 的 else 分支原来默认显示未登录,
但此时 AJAX 可能尚未返回。现在先检查 localStorage.jwt,
有 jwt 则不做操作等 AJAX 回调处理,
只有确认无 jwt 时才显示登录按钮
This commit is contained in:
yiqiu
2026-03-20 09:48:35 +08:00
parent 6089b9d2a5
commit fb31969195

View File

@@ -83,11 +83,15 @@ $(function () {
mobileHeadImg.textContent = desktopHeadImg.textContent; mobileHeadImg.textContent = desktopHeadImg.textContent;
} }
} else { } else {
// 默认显示未登录状态 // 两者都隐藏 — 可能是 AJAX 尚未返回
if (desktopNoLogin) desktopNoLogin.style.display = 'flex'; // 若有 jwt 则不做操作, 等 common.js AJAX 回调处理
if (desktopLoginIn) desktopLoginIn.style.display = 'none'; if (!localStorage.jwt) {
if (mobileNoLogin) mobileNoLogin.style.display = 'block'; // 确认未登录, 显示登录按钮
if (mobileLoginIn) mobileLoginIn.style.display = 'none'; if (desktopNoLogin) desktopNoLogin.style.display = 'flex';
if (desktopLoginIn) desktopLoginIn.style.display = 'none';
if (mobileNoLogin) mobileNoLogin.style.display = 'block';
if (mobileLoginIn) mobileLoginIn.style.display = 'none';
}
} }
} }