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

Function runBatchCheckSubscriptionTask

static/js/accounts.js:1311–1403  ·  view source on GitHub ↗
(payload, count, sourceLabel, options = {})

Source from the content-addressed store, hash-verified

1309}
1310
1311async function runBatchCheckSubscriptionTask(payload, count, sourceLabel, options = {}) {
1312 const showToast = options.showToast !== false;
1313 const reloadAfter = options.reloadAfter !== false;
1314 const onProgress = typeof options.onProgress === 'function' ? options.onProgress : null;
1315 isBatchCheckingSubscription = true;
1316 updateBatchButtons();
1317 elements.batchCheckSubBtn.textContent = '检测中...';
1318
1319 try {
1320 const task = await api.post('/payment/accounts/batch-check-subscription/async', payload, {
1321 timeoutMs: 20000,
1322 retry: 0,
1323 requestKey: 'payment:batch-check-subscription',
1324 cancelPrevious: true,
1325 });
1326 const taskId = task?.id;
1327 if (!taskId) {
1328 throw new Error('任务创建失败:未返回任务 ID');
1329 }
1330 trackBatchTask('subscription', {
1331 id: taskId,
1332 domain: 'payment',
1333 status: task?.status || 'pending',
1334 paused: Boolean(task?.paused),
1335 });
1336
1337 if (showToast) {
1338 toast.info(`${sourceLabel}任务已启动(${taskId.slice(0, 8)})`);
1339 }
1340 const finalTask = await watchPaymentTask(taskId, (progressTask) => {
1341 patchBatchTask('subscription', {
1342 status: progressTask?.status || 'running',
1343 paused: Boolean(progressTask?.paused),
1344 pause_requested: Boolean(progressTask?.pause_requested),
1345 });
1346 const progress = progressTask?.progress || {};
1347 const completed = Number(progress.completed || 0);
1348 const total = Number(progress.total || count);
1349 const paused = Boolean(progressTask?.paused) || String(progressTask?.status || '').toLowerCase() === 'paused';
1350 elements.batchCheckSubBtn.textContent = paused ? `已暂停 ${completed}/${total}` : `检测中 ${completed}/${total}`;
1351 if (onProgress) {
1352 onProgress({ completed, total, task: progressTask });
1353 }
1354 });
1355 patchBatchTask('subscription', {
1356 status: finalTask?.status || 'completed',
1357 paused: false,
1358 pause_requested: false,
1359 });
1360
1361 const result = finalTask?.result || {};
1362 const status = String(finalTask?.status || '').toLowerCase();
1363 if (status === 'completed') {
1364 if (showToast) {
1365 let message = `成功: ${result.success_count || 0}`;
1366 if ((result.failed_count || 0) > 0) message += `, 失败: ${result.failed_count || 0}`;
1367 toast.success(message);
1368 }

Callers 1

Calls 10

trackBatchTaskFunction · 0.85
watchPaymentTaskFunction · 0.85
patchBatchTaskFunction · 0.85
refreshAccountsViewFunction · 0.85
infoMethod · 0.80
successMethod · 0.80
warningMethod · 0.80
errorMethod · 0.80
updateBatchButtonsFunction · 0.70
postMethod · 0.45

Tested by

no test coverage detected