"use client"; import { ExternalLink, Loader2, X } from "lucide-react"; import { useEffect, useState, type ReactNode } from "react"; import { Modal } from "@/components/Modal"; import { OauthClientBadge } from "@/components/OauthClientBadge"; import { fetchJson, fmtTs } from "@/lib/api"; type JobDetail = { id: string; status: string; anchor_name?: string; room_id?: string; channel_name?: string; channel_pk?: string; oauth_profile_id?: string; push_date?: string; clip_path?: string; clip_ready?: boolean; clip_seconds?: number; youtube_url?: string; youtube_video_id?: string; error?: string; attempts?: number; session_id?: string; source_url?: string; created_at?: number; updated_at?: number; upload_at?: number; started_at?: number; finished_at?: number; preview_title?: string; preview_description?: string; }; const STATUS_STYLE: Record = { pending: "bg-slate-500/20 text-slate-200", recording: "bg-sky-500/20 text-sky-100", recorded: "bg-indigo-500/20 text-indigo-100", scheduled: "bg-amber-500/20 text-amber-100", uploading: "bg-violet-500/20 text-violet-100", uploaded: "bg-teal-500/20 text-teal-100", failed: "bg-rose-500/20 text-rose-100", }; function Row({ label, children }: { label: string; children: ReactNode }) { return (
{label}
{children}
); } export function ShortsJobDetailModal({ jobId, onClose, }: { jobId: string | null; onClose: () => void; }) { const [job, setJob] = useState(null); const [loading, setLoading] = useState(false); const [err, setErr] = useState(""); useEffect(() => { if (!jobId) { setJob(null); return; } let cancelled = false; setLoading(true); setErr(""); void fetchJson(`/api/shorts/jobs/${jobId}`) .then((data) => { if (!cancelled) setJob(data.job || data); }) .catch((e) => { if (!cancelled) setErr((e as Error).message); }) .finally(() => { if (!cancelled) setLoading(false); }); return () => { cancelled = true; }; }, [jobId]); const clipUrl = job?.clip_ready ? `/api/shorts/jobs/${job.id}/clip` : ""; return (

任务详情

{job?.anchor_name || job?.room_id || jobId || "—"}

{loading ? (
加载中…
) : err ? (

{err}

) : job ? ( <> {clipUrl ? (
); }