(step, options = {})
| 3714 | } |
| 3715 | |
| 3716 | async function invalidateDownstreamAfterStepRestart(step, options = {}) { |
| 3717 | const { logLabel = `步骤 ${step} 重新执行` } = options; |
| 3718 | const state = await getState(); |
| 3719 | const statuses = { ...(state.stepStatuses || {}) }; |
| 3720 | const changedSteps = []; |
| 3721 | |
| 3722 | for (let downstream = step + 1; downstream <= 9; downstream++) { |
| 3723 | if (statuses[downstream] !== 'pending') { |
| 3724 | statuses[downstream] = 'pending'; |
| 3725 | changedSteps.push(downstream); |
| 3726 | } |
| 3727 | } |
| 3728 | |
| 3729 | if (changedSteps.length) { |
| 3730 | await setState({ stepStatuses: statuses }); |
| 3731 | for (const downstream of changedSteps) { |
| 3732 | chrome.runtime.sendMessage({ |
| 3733 | type: 'STEP_STATUS_CHANGED', |
| 3734 | payload: { step: downstream, status: 'pending' }, |
| 3735 | }).catch(() => { }); |
| 3736 | } |
| 3737 | await addLog(`${logLabel},已重置后续步骤状态:${changedSteps.join(', ')}`, 'warn'); |
| 3738 | } |
| 3739 | |
| 3740 | const resets = getDownstreamStateResets(step); |
| 3741 | if (Object.keys(resets).length) { |
| 3742 | await setState(resets); |
| 3743 | broadcastDataUpdate(resets); |
| 3744 | } |
| 3745 | } |
| 3746 | |
| 3747 | function clearStopRequest() { |
| 3748 | stopRequested = false; |
no test coverage detected