fix(admin): 微信扫码恢复前台不再换码——修复'已扫未确认被换码丢确认'竞态
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

This commit is contained in:
Aska committed 2026-09-08 01:08:42 +08:00
1 parent d970884ff8
commit 4223f5a19a
1 file changed
+5 -4
@@ -118,14 +118,15 @@ export function WeixinLogin({
// Track tab visibility: while hidden, do NOT swap the QR (show "过期" overlay instead);
// on returning, re-mint a fresh code if we were still waiting.
useEffect(() => {
// Restoring the tab must NOT re-mint a QR: if the user has already scanned
// (but not confirmed) the on-screen code, swapping it mid-flow cancels the
// in-progress bind and WeChat's confirm never lands. Re-minting is only done
// by the periodic timer or the explicit 刷新二维码 button.
const onVis = () => {
const h = document.hidden;
setHidden(h);
if (!h && statusRef.current === "waiting") refreshQR();
setHidden(document.hidden);
};
const onFocus = () => {
setHidden(false);
if (statusRef.current === "waiting") refreshQR();
};
document.addEventListener("visibilitychange", onVis);
window.addEventListener("focus", onFocus);