fix(admin): 微信扫码恢复前台不再换码——修复'已扫未确认被换码丢确认'竞态
This commit is contained in:
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);
|
||||
|
||||
Reference in new issue
Block a user