MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / stopVendorAutoTask

Function stopVendorAutoTask

static/js/payment.js:1580–1644  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1578}
1579
1580async function stopVendorAutoTask() {
1581 let taskId = Number(vendorProgressState.taskId || 0);
1582 setVendorStopButtonState(true, true);
1583 try {
1584 if (!taskId) {
1585 const activeStop = await api.post("/payment/bind-card/vendor-stop-active", {});
1586 const resolvedId = Number(activeStop?.task?.id || 0);
1587 if (!resolvedId) {
1588 throw new Error("当前没有可停止的卡商任务");
1589 }
1590 taskId = resolvedId;
1591 vendorProgressState.taskId = resolvedId;
1592 appendVendorLogs(activeStop?.progress?.logs || []);
1593 updateVendorProgressUi(activeStop?.progress || { status: "cancelled", progress: 100 }, taskId);
1594 vendorProgressState.cursor = Number(activeStop?.progress?.next_cursor || vendorProgressState.cursor || 0);
1595 stopVendorProgressPolling();
1596 toast.success(`任务 #${taskId} 已发送停止指令`);
1597 await loadBindCardTasks(true);
1598 return;
1599 }
1600 const stopPaths = [
1601 `/payment/bind-card/tasks/${taskId}/vendor-stop`,
1602 `/payment/bind-card/tasks/${taskId}/stop-vendor`,
1603 `/payment/bind-card/tasks/${taskId}/stop`,
1604 `/payment/bind-card/tasks/${taskId}/cancel`,
1605 ];
1606 let data = null;
1607 let lastNotFoundError = null;
1608 for (const path of stopPaths) {
1609 try {
1610 data = await api.post(path, {});
1611 break;
1612 } catch (error) {
1613 const status = Number(error?.response?.status || 0);
1614 const detail = String(error?.data?.detail || error?.message || "").trim();
1615 const isRouteNotFound = status === 404 && (!detail || detail.toLowerCase() === "not found");
1616 if (isRouteNotFound) {
1617 lastNotFoundError = error;
1618 continue;
1619 }
1620 throw error;
1621 }
1622 }
1623 if (!data) {
1624 // 兜底:按“当前活跃任务”停止,避免 taskId 漂移导致无法停止。
1625 const activeStop = await api.post("/payment/bind-card/vendor-stop-active", {});
1626 const resolvedId = Number(activeStop?.task?.id || taskId || 0);
1627 if (!resolvedId) {
1628 throw lastNotFoundError || new Error("停止接口不可用");
1629 }
1630 taskId = resolvedId;
1631 vendorProgressState.taskId = resolvedId;
1632 data = activeStop;
1633 }
1634 appendVendorLogs(data?.progress?.logs || []);
1635 updateVendorProgressUi(data?.progress || { status: "cancelled", progress: 100 }, taskId);
1636 vendorProgressState.cursor = Number(data?.progress?.next_cursor || vendorProgressState.cursor || 0);
1637 stopVendorProgressPolling();

Callers

nothing calls this directly

Calls 9

setVendorStopButtonStateFunction · 0.85
appendVendorLogsFunction · 0.85
updateVendorProgressUiFunction · 0.85
loadBindCardTasksFunction · 0.85
formatErrorMessageFunction · 0.85
successMethod · 0.80
errorMethod · 0.80
postMethod · 0.45

Tested by

no test coverage detected