feat: 添加对手动执行步骤 4 的前置条件检查,确保认证页标签存在

This commit is contained in:
QLHazyCoder
2026-04-23 01:00:39 +08:00
parent 7ba9e609ab
commit 9dbc7bbf21
5 changed files with 56 additions and 4 deletions
+22
View File
@@ -40,6 +40,7 @@
getPendingAutoRunTimerPlan,
getSourceLabel,
getState,
getTabId,
getStopRequested,
handleAutoRunLoopUnhandledError,
importSettingsBundle,
@@ -50,6 +51,7 @@
isLocalhostOAuthCallbackUrl,
isLuckmailProvider,
isStopError,
isTabAlive,
launchAutoRunTimerPlan,
listIcloudAliases,
listLuckmailPurchasesForManagement,
@@ -108,6 +110,23 @@
return appendAccountRunRecord(status, state, reason);
}
async function ensureManualStepPrerequisites(step) {
if (step !== 4) {
return;
}
const signupTabId = typeof getTabId === 'function'
? await getTabId('signup-page')
: null;
const signupTabAlive = signupTabId && typeof isTabAlive === 'function'
? await isTabAlive('signup-page')
: Boolean(signupTabId);
if (!signupTabId || !signupTabAlive) {
throw new Error('手动执行步骤 4 前,请先执行步骤 1 或步骤 2,确保认证页仍然打开并停留在验证码页。');
}
}
async function handleStepData(step, payload) {
switch (step) {
case 1: {
@@ -402,6 +421,9 @@
await ensureManualInteractionAllowed('手动执行步骤');
}
const step = message.payload.step;
if (message.source === 'sidepanel') {
await ensureManualStepPrerequisites(step);
}
if (message.source === 'sidepanel') {
await invalidateDownstreamAfterStepRestart(step, { logLabel: `步骤 ${step} 重新执行` });
}
+1 -1
View File
@@ -72,7 +72,7 @@
const signupTabId = await getTabId('signup-page');
if (!signupTabId) {
throw new Error('认证页面标签页已关闭,无法继续步骤 4。');
throw new Error('认证页面标签页已关闭,无法继续步骤 4。请先执行步骤 1 或步骤 2,重新打开认证页后再试。');
}
await chrome.tabs.update(signupTabId, { active: true });