(progressPayload = {}, status = "running")
| 1348 | } |
| 1349 | |
| 1350 | function updateVendorRuntimeHint(progressPayload = {}, status = "running") { |
| 1351 | const runtime = document.getElementById("vendor-progress-runtime"); |
| 1352 | if (!runtime) return; |
| 1353 | const elapsed = Math.max( |
| 1354 | 0, |
| 1355 | Number(progressPayload?.elapsed_seconds ?? vendorProgressState.elapsedSeconds ?? 0), |
| 1356 | ); |
| 1357 | const forceStopAfter = Math.max( |
| 1358 | 1, |
| 1359 | Number(progressPayload?.force_stop_after_seconds ?? vendorProgressState.forceStopAfterSeconds ?? 120), |
| 1360 | ); |
| 1361 | const canForceStop = Boolean(progressPayload?.can_force_stop) || elapsed >= forceStopAfter; |
| 1362 | vendorProgressState.elapsedSeconds = elapsed; |
| 1363 | vendorProgressState.forceStopAfterSeconds = forceStopAfter; |
| 1364 | |
| 1365 | const currentStatus = String(status || progressPayload?.status || "running").toLowerCase(); |
| 1366 | if (currentStatus === "completed") { |
| 1367 | runtime.textContent = `任务已完成(总耗时 ${elapsed} 秒)`; |
| 1368 | return; |
| 1369 | } |
| 1370 | if (currentStatus === "failed") { |
| 1371 | runtime.textContent = `任务已失败(运行 ${elapsed} 秒)`; |
| 1372 | return; |
| 1373 | } |
| 1374 | if (currentStatus === "cancelled") { |
| 1375 | runtime.textContent = `任务已停止(运行 ${elapsed} 秒)`; |
| 1376 | return; |
| 1377 | } |
| 1378 | if (currentStatus === "pending") { |
| 1379 | runtime.textContent = `已运行 ${elapsed} 秒 / 接口执行已完成,等待订阅同步`; |
| 1380 | return; |
| 1381 | } |
| 1382 | |
| 1383 | if (canForceStop) { |
| 1384 | runtime.textContent = `已运行 ${elapsed} 秒 / 已可停止`; |
| 1385 | return; |
| 1386 | } |
| 1387 | |
| 1388 | const left = Math.max(0, forceStopAfter - elapsed); |
| 1389 | runtime.textContent = `已运行 ${elapsed} 秒 / 可随时停止(建议 ${forceStopAfter} 秒后强制,剩余 ${left} 秒)`; |
| 1390 | } |
| 1391 | |
| 1392 | function formatBeijingDateTime(dateStr) { |
| 1393 | if (!dateStr) return "-"; |
no outgoing calls
no test coverage detected