feat: preview and retry sync jobs

This commit is contained in:
2026-07-19 06:01:15 +08:00
parent 9caf598fcb
commit 5997a54f2c
6 changed files with 22 additions and 1 deletions
+3
View File
@@ -0,0 +1,3 @@
"use client";
import { useState } from "react";
export function SyncPreview({ sourceId }: { sourceId: number }) { const [text, setText] = useState(""); async function preview() { setText("讀取中…"); const response = await fetch(`/api/sources/${sourceId}/preview`); const body = await response.json(); setText(response.ok ? `本頁預覽:新增 ${body.added}、已存在 ${body.existing},共檢查 ${body.inspected}${body.hasMore ? "(來源尚有更多頁)" : ""}` : body.error || "無法預覽"); } return <div><button type="button" onClick={preview}></button>{text && <p className="meta">{text}</p>}</div>; }