(batchId)
| 2526 | |
| 2527 | // 开始轮询 Outlook 批量状态(降级方案) |
| 2528 | function startOutlookBatchPolling(batchId) { |
| 2529 | if (batchPollingInterval) { |
| 2530 | return; |
| 2531 | } |
| 2532 | |
| 2533 | batchPollingInterval = setInterval(async () => { |
| 2534 | try { |
| 2535 | const data = await api.get(`/registration/outlook-batch/${batchId}`); |
| 2536 | |
| 2537 | // 更新进度 |
| 2538 | updateBatchProgress({ |
| 2539 | total: data.total, |
| 2540 | completed: data.completed, |
| 2541 | success: data.success, |
| 2542 | failed: data.failed |
| 2543 | }); |
| 2544 | |
| 2545 | // 输出日志 |
| 2546 | if (data.logs && data.logs.length > 0) { |
| 2547 | const lastLogIndex = batchPollingInterval.lastLogIndex || 0; |
| 2548 | for (let i = lastLogIndex; i < data.logs.length; i++) { |
| 2549 | const log = data.logs[i]; |
| 2550 | const logType = getLogType(log); |
| 2551 | addLog(logType, log); |
| 2552 | } |
| 2553 | batchPollingInterval.lastLogIndex = data.logs.length; |
| 2554 | } |
| 2555 | |
| 2556 | // 检查是否完成 |
| 2557 | if (data.finished) { |
| 2558 | stopBatchPolling(); |
| 2559 | resetButtons(); |
| 2560 | |
| 2561 | // 只显示一次 toast |
| 2562 | if (!toastShown) { |
| 2563 | toastShown = true; |
| 2564 | addLog('info', `[完成] Outlook 批量任务完成!成功: ${data.success}, 失败: ${data.failed}, 跳过: ${data.skipped || 0}`); |
| 2565 | if (data.success > 0) { |
| 2566 | toast.success(`Outlook 批量注册完成,成功 ${data.success} 个`); |
| 2567 | loadRecentAccounts(); |
| 2568 | } else { |
| 2569 | toast.warning('Outlook 批量注册完成,但没有成功注册任何账号'); |
| 2570 | } |
| 2571 | } |
| 2572 | } |
| 2573 | } catch (error) { |
| 2574 | console.error('轮询 Outlook 批量状态失败:', error); |
| 2575 | } |
| 2576 | }, 2000); |
| 2577 | |
| 2578 | batchPollingInterval.lastLogIndex = 0; |
| 2579 | } |
| 2580 | |
| 2581 | // ============== 页面可见性重连机制 ============== |
| 2582 |
no test coverage detected