chore: preserve step-aware logging after upstream sync

- 吸收 master 的核心改动:按可见步骤归类日志显示,覆盖 OAuth、手机号验证、平台验证和内容脚本日志链路。

- 本地补充修复:保留平台验证成功后的手机号接码确认收尾,避免 #193/#194 恢复的手机号复用链路被合并覆盖。

- 影响范围:background routing、phone verification、platform verify、content scripts、sidepanel 与相关测试/文档。
This commit is contained in:
QLHazyCoder
2026-05-04 04:41:49 +08:00
25 changed files with 690 additions and 290 deletions
+24 -7
View File
@@ -222,6 +222,9 @@
if (typeof markCurrentRegistrationAccountUsed !== 'function') {
await finalizeIcloudAliasAfterSuccessfulFlow(latestState);
}
if (typeof finalizePhoneActivationAfterSuccessfulFlow === 'function') {
await finalizePhoneActivationAfterSuccessfulFlow(latestState);
}
}
async function handleStepData(step, payload) {
@@ -258,7 +261,10 @@
const currentStatus = latestState.stepStatuses?.[loginCodeStep];
if (!isStepProtectedFromAutoSkip(currentStatus)) {
await setStepStatus(loginCodeStep, 'skipped');
await addLog(`步骤 ${step}认证页已直接进入 OAuth 授权页,已自动跳过步骤 ${loginCodeStep} 的登录验证码。`, 'warn');
await addLog(`认证页已直接进入 OAuth 授权页,已自动跳过步骤 ${loginCodeStep} 的登录验证码。`, 'warn', {
step,
stepKey: 'oauth-login',
});
}
}
} else if (payload.loginVerificationRequestedAt) {
@@ -433,6 +439,9 @@
if (typeof markCurrentRegistrationAccountUsed !== 'function' && typeof markCurrentCustomEmailPoolEntryUsed === 'function') {
await markCurrentCustomEmailPoolEntryUsed(latestState);
}
if (typeof finalizePhoneActivationAfterSuccessfulFlow === 'function') {
await finalizePhoneActivationAfterSuccessfulFlow(latestState);
}
break;
}
default:
@@ -453,8 +462,16 @@
}
case 'LOG': {
const { message: msg, level } = message.payload;
await addLog(`[${getSourceLabel(message.source)}] ${msg}`, level);
const { message: msg, level, step: payloadStep, stepKey } = message.payload;
const logStep = Math.floor(Number(message.step || payloadStep) || 0);
await addLog(
`[${getSourceLabel(message.source)}] ${msg}`,
level,
{
step: logStep > 0 ? logStep : null,
stepKey,
}
);
return { ok: true };
}
@@ -479,7 +496,7 @@
}
const errorMessage = error?.message || String(error || '步骤 3 提交后确认失败');
await setStepStatus(message.step, 'failed');
await addLog(`步骤 ${message.step} 失败:${errorMessage}`, 'error');
await addLog(`失败:${errorMessage}`, 'error', { step: message.step });
await appendManualAccountRunRecordIfNeeded(`step${message.step}_failed`, null, errorMessage);
notifyStepError(message.step, errorMessage);
return { ok: true, error: errorMessage };
@@ -491,7 +508,7 @@
: 10;
const completionState = message.step === lastStepId ? completionStateCandidate : null;
await setStepStatus(message.step, 'completed');
await addLog(`步骤 ${message.step} 已完成`, 'ok');
await addLog('已完成', 'ok', { step: message.step });
await handleStepData(message.step, message.payload);
if (message.step === lastStepId && typeof appendAccountRunRecord === 'function') {
await appendAccountRunRecord('success', completionState);
@@ -510,12 +527,12 @@
}
if (isStopError(message.error)) {
await setStepStatus(message.step, 'stopped');
await addLog(`步骤 ${message.step} 已被用户停止`, 'warn');
await addLog('已被用户停止', 'warn', { step: message.step });
await appendManualAccountRunRecordIfNeeded(`step${message.step}_stopped`, null, message.error);
notifyStepError(message.step, message.error);
} else {
await setStepStatus(message.step, 'failed');
await addLog(`步骤 ${message.step} 失败:${message.error}`, 'error');
await addLog(`失败:${message.error}`, 'error', { step: message.step });
await appendManualAccountRunRecordIfNeeded(`step${message.step}_failed`, null, message.error);
notifyStepError(message.step, message.error);
}