v1.4.1 新增「重爬失败页」: 一键把失败页面重新加入待爬队列

- 后端 POST /api/tasks/<tid>/retry-failed: 从指定 run 提取 FAIL 页面,
  解除 visited 标记并注入待爬队列头部(去重, 已排队的不重复注入)
- 前端详情页 run 面板新增「🔄 重爬失败页 (N)」按钮(auto 模式且有失败页时显示),
  点击后自动注入并触发继续爬取
This commit is contained in:
2026-08-14 10:36:00 +08:00
parent ec053266a7
commit 950f5af5ea
2 changed files with 71 additions and 1 deletions
+22
View File
@@ -618,6 +618,26 @@ function pageWindow(cur, pages, width) {
return win;
}
/* 重爬失败页: 注入待爬队列并自动继续爬取 */
async function retryFailed() {
const t = state.detail.task;
if (!t || !state.detail.runId) return;
if (!confirm("将把本次运行失败的页面重新加入待爬队列并立即继续爬取,确定?")) return;
try {
const d = await api(`/api/tasks/${t.id}/retry-failed`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ run: state.detail.runId }),
});
toast(`已注入 ${d.injected} 个失败页,开始继续爬取…`);
if ((d.injected || 0) > 0) {
await api(`/api/tasks/${t.id}/continue`, { method: "POST" });
}
loadTasks();
openDetail(t.id);
} catch (e) { toast(e.message, true); }
}
function renderDetail() {
const t = state.detail.task;
const runs = t.runs || [];
@@ -752,6 +772,8 @@ function renderRunPanel(t, run) {
<span class="ok">✅ ${s.ok}</span>
<span class="fail">❌ ${s.fail}</span>
<span class="img">🖼️ ${s.images}</span>
${t.mode === "auto" && (s.fail || 0) > 0 && run.status !== "running" && run.status !== "paused" ? `
<button class="btn sm" title="将本次运行失败的页面重新加入待爬队列并继续爬取" onclick="retryFailed()">🔄 重爬失败页 (${s.fail})</button>` : ""}
</div>
${prog}
<div class="card-line">当前: <b>${esc(run.progress.current_url || "")}</b></div>