From 850e5a56b038841a38e76382deea1e451a2a542a Mon Sep 17 00:00:00 2001 From: QLHazyCoder <2825305047@qq.com> Date: Wed, 8 Apr 2026 14:34:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E9=82=AE=E7=AE=B1?= =?UTF-8?q?=E5=B0=B1=E7=BB=AA=E6=97=B6=E8=87=AA=E5=8A=A8=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E7=9A=84=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=87=AA=E5=8A=A8=E8=BF=90=E8=A1=8C=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- background.js | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/background.js b/background.js index 60f5115..02c435d 100644 --- a/background.js +++ b/background.js @@ -112,6 +112,9 @@ function broadcastDataUpdate(payload) { async function setEmailState(email) { await setState({ email }); broadcastDataUpdate({ email }); + if (email) { + await resumeAutoRunIfWaitingForEmail(); + } } async function setPasswordState(password) { @@ -1081,6 +1084,25 @@ let autoRunCurrentRun = 0; let autoRunTotalRuns = 1; let autoRunAttemptRun = 0; +async function resumeAutoRunIfWaitingForEmail(options = {}) { + const { silent = false } = options; + const state = await getState(); + if (!state.email || !isAutoRunPausedState(state)) { + return false; + } + + if (resumeWaiter) { + if (!silent) { + await addLog('邮箱已就绪,自动继续后续步骤...', 'info'); + } + resumeWaiter.resolve(); + resumeWaiter = null; + return true; + } + + return false; +} + // Outer loop: keep retrying until the target number of successful runs is reached. async function autoRunLoop(totalRuns, options = {}) { if (autoRunActive) { @@ -1268,9 +1290,15 @@ async function autoRunLoop(totalRuns, options = {}) { clearStopRequest(); } -function waitForResume() { +async function waitForResume() { + throwIfStopped(); + const state = await getState(); + if (state.email) { + await addLog('邮箱已就绪,自动继续后续步骤...', 'info'); + return; + } + return new Promise((resolve, reject) => { - throwIfStopped(); resumeWaiter = { resolve, reject }; }); } @@ -1282,10 +1310,7 @@ async function resumeAutoRun() { await addLog('无法继续:当前没有邮箱地址,请先在侧边栏填写邮箱。', 'error'); return; } - if (resumeWaiter) { - resumeWaiter.resolve(); - resumeWaiter = null; - } + await resumeAutoRunIfWaitingForEmail({ silent: true }); } // ============================================================