* Report step completion. * @param {number} step * @param {Object} data - Step output data
(step, data = {})
| 283 | * @param {Object} data - Step output data |
| 284 | */ |
| 285 | function reportComplete(step, data = {}) { |
| 286 | console.log(LOG_PREFIX, `步骤 ${step} 已完成`, data); |
| 287 | log(`步骤 ${step} 已成功完成`, 'ok'); |
| 288 | const message = { |
| 289 | type: 'STEP_COMPLETE', |
| 290 | source: SCRIPT_SOURCE, |
| 291 | step, |
| 292 | payload: data, |
| 293 | error: null, |
| 294 | }; |
| 295 | Promise.resolve(chrome.runtime.sendMessage(message)) |
| 296 | .then((response) => { |
| 297 | console.log(LOG_PREFIX, `STEP_COMPLETE sent successfully for step ${step}`, { |
| 298 | response, |
| 299 | url: location.href, |
| 300 | payloadKeys: Object.keys(data || {}), |
| 301 | }); |
| 302 | }) |
| 303 | .catch((err) => { |
| 304 | console.error(LOG_PREFIX, `STEP_COMPLETE send failed for step ${step}`, err?.message || err, { |
| 305 | url: location.href, |
| 306 | payloadKeys: Object.keys(data || {}), |
| 307 | }); |
| 308 | }); |
| 309 | } |
| 310 | |
| 311 | /** |
| 312 | * Report step error. |
no test coverage detected