修复第三方登录旧响应覆盖新会话并补充跨标签回归

This commit is contained in:
cieanyau committed 2026-11-07 01:05:45 +08:00
1 parent 30415593a6
commit c3467875c6
6 files changed
+484 -25

No files matched your search

+16 -9
View File
@@ -133,6 +133,7 @@ var fe = {
W = null,
G = null,
K = 0,
loginAttempt = null,
q = null;
function J() {
W !== null && (clearInterval(W), (W = null));
@@ -154,6 +155,8 @@ var fe = {
// 只在桌面展示区域申请新二维码,并核对图片、ticket 与 token 的完整性。
if (!k.value || L.value) return;
let e = ++K;
const attempt = C.prepareLogin();
loginAttempt = attempt;
(Z(),
(z.value = ``),
(R.value = !1),
@@ -165,7 +168,7 @@ var fe = {
let t = await E.get(`/mp_weixin_notice/qrcode`, void 0, !1, {
timeoutMs: 15e3,
});
if (e !== K) return;
if (e !== K || !attempt.isCurrent()) return;
if (
typeof t?.img_url != `string` ||
!t.img_url ||
@@ -177,7 +180,7 @@ var fe = {
throw Error(`二维码加载失败,请重新获取`);
((I.value = t), (z.value = ``), Ee());
} catch (t) {
if (e !== K) return;
if (e !== K || !attempt.isCurrent()) return;
(J(),
Y(),
(z.value = loginErrorMessage(t, `二维码加载失败,请稍后重试`)));
@@ -187,7 +190,7 @@ var fe = {
}
async function De() {
// 同一代次最多一个查询在途;Wait/Success/Expired/SelectClient/WaitBind 分别处理。
if (!I.value || q === K) return;
if (!I.value || q === K || !loginAttempt?.isCurrent()) return;
let e = K,
t = I.value;
q = e;
@@ -203,7 +206,7 @@ var fe = {
timeoutMs: 1e4,
},
);
if (e !== K) return;
if (e !== K || !loginAttempt.isCurrent()) return;
if (!n || typeof n.status != `string`)
throw Error(`扫码登录状态异常,请重新获取二维码`);
if (n.status === `Wait`) return;
@@ -252,7 +255,7 @@ var fe = {
}
(Z(), (z.value = `扫码登录状态异常,请重新获取二维码`));
} catch (t) {
if (e !== K) return;
if (e !== K || !loginAttempt.isCurrent()) return;
(Z(),
(z.value = loginErrorMessage(
t,
@@ -270,6 +273,7 @@ var fe = {
(K++,
Z(),
(I.value = null),
(loginAttempt = null),
(L.value = !1),
(H.value = !1),
(R.value = !1),
@@ -283,11 +287,13 @@ var fe = {
z.value = `登录响应无效,请重新扫码;若持续失败,请联系客服。`;
return;
}
(C.loginWithJwt(e), K++, T.push(auth_redirect_r(w.query.redirect)));
(loginAttempt.commit(e),
K++,
T.push(auth_redirect_r(w.query.redirect)));
}
async function Oe() {
// 多账号扫码只能提交当前返回列表中明确可登录的账号,且请求绑定当前二维码代次。
if (H.value) return;
if (H.value || !loginAttempt?.isCurrent()) return;
if (
!I.value ||
!B.value.some((e) => e.id === V.value && e.status === 1)
@@ -310,12 +316,12 @@ var fe = {
timeoutMs: 15e3,
},
);
if (e !== K) return;
if (e !== K || !loginAttempt.isCurrent()) return;
t?.jwt
? $(t.jwt)
: (z.value = `登录响应无效,请重新扫码;若持续失败,请联系客服。`);
} catch (t) {
if (e !== K) return;
if (e !== K || !loginAttempt.isCurrent()) return;
z.value = loginErrorMessage(t);
} finally {
e === K && (H.value = !1);
@@ -329,6 +335,7 @@ var fe = {
await D().catch(() => {}));
}),
watch(N, Q),
watch(() => C.token, Q),
onUnmounted(() => {
(A?.removeEventListener(`change`, j), Q());
}),