(step, error)
| 5822 | } |
| 5823 | |
| 5824 | async function getPostStep6AutoRestartDecision(step, error) { |
| 5825 | const normalizedStep = Number(step); |
| 5826 | const errorMessage = getErrorMessage(error); |
| 5827 | if (!Number.isFinite(normalizedStep) || normalizedStep < 6 || normalizedStep > 9) { |
| 5828 | return { |
| 5829 | shouldRestart: false, |
| 5830 | blockedByAddPhone: false, |
| 5831 | errorMessage, |
| 5832 | authState: null, |
| 5833 | }; |
| 5834 | } |
| 5835 | |
| 5836 | if (isAddPhoneAuthUrl(errorMessage)) { |
| 5837 | return { |
| 5838 | shouldRestart: false, |
| 5839 | blockedByAddPhone: true, |
| 5840 | errorMessage, |
| 5841 | authState: null, |
| 5842 | }; |
| 5843 | } |
| 5844 | |
| 5845 | let authState = null; |
| 5846 | try { |
| 5847 | authState = await getLoginAuthStateFromContent({ |
| 5848 | logMessage: `步骤 ${normalizedStep}:正在确认当前认证页状态,以决定是否回到步骤 6 重开...`, |
| 5849 | }); |
| 5850 | } catch (inspectError) { |
| 5851 | console.warn(LOG_PREFIX, '[AutoRun] failed to inspect login auth state after post-step6 error', { |
| 5852 | step: normalizedStep, |
| 5853 | sourceError: errorMessage, |
| 5854 | inspectError: inspectError?.message || inspectError, |
| 5855 | }); |
| 5856 | } |
| 5857 | |
| 5858 | if (isAddPhoneAuthState(authState)) { |
| 5859 | return { |
| 5860 | shouldRestart: false, |
| 5861 | blockedByAddPhone: true, |
| 5862 | errorMessage, |
| 5863 | authState, |
| 5864 | }; |
| 5865 | } |
| 5866 | |
| 5867 | return { |
| 5868 | shouldRestart: true, |
| 5869 | blockedByAddPhone: false, |
| 5870 | errorMessage, |
| 5871 | authState, |
| 5872 | }; |
| 5873 | } |
| 5874 | |
| 5875 | async function getLoginAuthStateFromContent(options = {}) { |
| 5876 | const { logMessage = '步骤 7:认证页正在切换,等待页面重新就绪后继续确认验证码页状态...' } = options; |
no test coverage detected