(taskId, activeReportId = "")
| 2970 | } |
| 2971 | |
| 2972 | async function pollReadingTask(taskId, activeReportId = "") { |
| 2973 | if (!taskId) return; |
| 2974 | const pollToken = ++state.readingPollToken; |
| 2975 | while (pollToken === state.readingPollToken) { |
| 2976 | await new Promise((resolve) => window.setTimeout(resolve, 2500)); |
| 2977 | const data = await api(`/api/read/status?task_id=${encodeURIComponent(taskId)}`); |
| 2978 | if (pollToken !== state.readingPollToken) return; |
| 2979 | const task = data.task; |
| 2980 | if (!task) return; |
| 2981 | await refreshReports({ |
| 2982 | keepSelection: true, |
| 2983 | activeReportId: state.currentReport?.report_id || activeReportId |
| 2984 | }); |
| 2985 | if (task.status === "completed" || task.status === "failed") { |
| 2986 | const detail = `${task.completed_count || 0}/${task.total_count || 0}`; |
| 2987 | showFeedbackToast(task.status === "failed" ? "warning" : "success", task.status === "failed" ? "精读任务结束但有错误" : "精读任务完成", detail); |
| 2988 | return; |
| 2989 | } |
| 2990 | } |
| 2991 | } |
| 2992 | |
| 2993 | function setReportLinks(report) { |
| 2994 | const map = { |
no test coverage detected