(step)
| 4145 | } |
| 4146 | |
| 4147 | async function skipStep(step) { |
| 4148 | const state = await ensureManualInteractionAllowed('跳过步骤'); |
| 4149 | |
| 4150 | if (!Number.isInteger(step) || step < 1 || step > 9) { |
| 4151 | throw new Error(`无效步骤:${step}`); |
| 4152 | } |
| 4153 | |
| 4154 | const statuses = { ...(state.stepStatuses || {}) }; |
| 4155 | const currentStatus = statuses[step]; |
| 4156 | if (currentStatus === 'running') { |
| 4157 | throw new Error(`步骤 ${step} 正在运行中,不能跳过。`); |
| 4158 | } |
| 4159 | if (isStepDoneStatus(currentStatus)) { |
| 4160 | throw new Error(`步骤 ${step} 已完成,无需再跳过。`); |
| 4161 | } |
| 4162 | |
| 4163 | if (step > 1) { |
| 4164 | const prevStatus = statuses[step - 1]; |
| 4165 | if (!isStepDoneStatus(prevStatus)) { |
| 4166 | throw new Error(`请先完成步骤 ${step - 1},再跳过步骤 ${step}。`); |
| 4167 | } |
| 4168 | } |
| 4169 | |
| 4170 | await setStepStatus(step, 'skipped'); |
| 4171 | await addLog(`步骤 ${step} 已跳过`, 'warn'); |
| 4172 | |
| 4173 | if (step === 1) { |
| 4174 | const latestState = await getState(); |
| 4175 | const step2Status = latestState.stepStatuses?.[2]; |
| 4176 | if (!isStepDoneStatus(step2Status) && step2Status !== 'running') { |
| 4177 | await setStepStatus(2, 'skipped'); |
| 4178 | await addLog('步骤 1 已跳过,步骤 2 也已同时跳过。', 'warn'); |
| 4179 | } |
| 4180 | } |
| 4181 | |
| 4182 | return { ok: true, step, status: 'skipped' }; |
| 4183 | } |
| 4184 | |
| 4185 | function throwIfStopped() { |
| 4186 | if (stopRequested) { |
no test coverage detected