diff --git a/frontend/src/app/yt-long/page.tsx b/frontend/src/app/yt-long/page.tsx index b214385..f212fe2 100644 --- a/frontend/src/app/yt-long/page.tsx +++ b/frontend/src/app/yt-long/page.tsx @@ -1,34 +1,29 @@ "use client"; -import { useCallback, useEffect, useMemo, useState } from "react"; +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import Link from "next/link"; import { - Film, + Clock3, + Download, Loader2, + Plus, RefreshCw, RotateCcw, Trash2, - Download, + Upload, + Video, } from "lucide-react"; import { Shell } from "@/components/Shell"; import { useConfirm } from "@/components/ConfirmDialog"; import { useToast } from "@/components/Toast"; +import { OauthClientBadge, normalizeOauthProfileId } from "@/components/OauthClientBadge"; +import { PageLoader, TableSkeleton } from "@/components/ui"; import { fetchJson, fmtTs, todayBeijingISO } from "@/lib/api"; -import { useAutoRefresh } from "@/lib/realtime"; - -const panel = - "rounded-2xl border border-white/10 bg-gradient-to-b from-white/[0.07] to-black/30 p-4 shadow-[0_8px_32px_rgba(0,0,0,0.25)]"; -const field = - "mt-1 w-full rounded-xl border border-white/10 bg-black/45 px-3 py-2 text-sm text-slate-100 outline-none focus:border-sky-400/50"; -const label = "block text-[11px] text-slate-400"; -const btn = - "inline-flex items-center justify-center gap-1.5 rounded-xl px-3 py-2 text-xs font-semibold transition hover:-translate-y-0.5 disabled:opacity-40"; -const primary = `${btn} bg-gradient-to-br from-sky-400 to-indigo-500 text-[#0a1220] shadow-lg shadow-sky-500/20`; -const ghost = `${btn} border border-white/10 bg-white/5 text-slate-200 hover:bg-white/10`; type Channel = { id: string; - name?: string; + name: string; youtube_channel_id?: string; enabled?: boolean; daily_max?: number; @@ -39,74 +34,51 @@ type Channel = { authorized?: boolean; has_refresh_token?: boolean; oauth_profile_id?: string; - oauth_ok?: number; oauth_error?: string; - source_shorts_channel_pk?: string; }; type BoardChannel = { id: string; name?: string; - enabled?: boolean; - authorized?: boolean; - daily_max: number; - used: number; - gap: number; - uploaded: number; - scheduled: number; - pending: number; - failed: number; + youtube_channel_id?: string; oauth_profile_id?: string; - oauth_error?: string; + enabled?: boolean; + daily_max: number; + authorized?: boolean; + used: number; + scheduled: number; + uploaded: number; + pending: number; + failed?: number; + gap?: number; }; type Job = { id: string; - status?: string; + status: string; anchor_name?: string; room_id?: string; - title?: string; + push_date?: string; + channel_pk?: string; + clip_path?: string; + clip_ready?: boolean; clip_seconds?: number; youtube_url?: string; - channel_pk?: string; + title?: string; error?: string; - upload_at?: number; created_at?: number; - push_date?: string; + upload_at?: number; }; -type Ev = { - id: string; - ts?: number; - level?: string; - kind?: string; - message?: string; - anchor_name?: string; - room_id?: string; -}; - -type Status = { - enabled?: boolean; - running?: boolean; - busy?: boolean; - quota_used?: number; - quota_gap?: number; - daily_max?: number; - last_error?: string; - douyin_live_count?: number; - board?: { channels?: BoardChannel[]; total_gap?: number; push_date?: string }; - settings?: Record; -}; - -const STATUS_ZH: Record = { - pending: "排队", - recording: "录制中", - recorded: "已成片", - scheduled: "待上传", - uploading: "上传中", - uploaded: "已上传", - failed: "失败", - skipped: "跳过", +const emptyForm = { + name: "", + enabled: true, + daily_max: 1, + title_template: "{anchor} street food live", + description_template: "{anchor}\n{url}\n#StreetFood #Live", + privacy: "public", + note: "", + oauth_profile_id: "A", }; const STATUS_STYLE: Record = { @@ -120,701 +92,869 @@ const STATUS_STYLE: Record = { skipped: "bg-white/10 text-slate-400", }; +const JOB_PAGE = 50; + export default function YtLongPage() { - const toast = useToast(); const confirm = useConfirm(); - const [tab, setTab] = useState<"channels" | "jobs" | "logs">("channels"); - const [st, setSt] = useState(null); + const toast = useToast(); + const leftPanelRef = useRef(null); + const rightPanelRef = useRef(null); + const [status, setStatus] = useState | null>(null); const [channels, setChannels] = useState([]); const [jobs, setJobs] = useState([]); const [jobTotal, setJobTotal] = useState(0); - const [events, setEvents] = useState([]); - const [eventTotal, setEventTotal] = useState(0); - const [busy, setBusy] = useState(""); + const [upcoming, setUpcoming] = useState([]); + const [form, setForm] = useState({ ...emptyForm }); + const [editId, setEditId] = useState(""); + const [busy, setBusy] = useState(false); + const [msg, setMsg] = useState(""); + const [error, setError] = useState(""); const [jobFilter, setJobFilter] = useState(""); const [jobChannel, setJobChannel] = useState(""); - const [editId, setEditId] = useState(""); - const [form, setForm] = useState({ - name: "", - enabled: true, - daily_max: 1, - title_template: "{anchor} street food live", - description_template: "{anchor}\n{url}\n#StreetFood #Live", - privacy: "public", - note: "", - oauth_profile_id: "A", - }); - const [dailyMax, setDailyMax] = useState("3"); - const [minSec, setMinSec] = useState("180"); - const [maxSec, setMaxSec] = useState("480"); - const [withShorts, setWithShorts] = useState(true); - const [autoUpload, setAutoUpload] = useState(true); - const [dedupe, setDedupe] = useState(true); - - const channelNameMap = useMemo(() => { - const m: Record = {}; - for (const c of channels) m[c.id] = c.name || c.id.slice(0, 8); - return m; - }, [channels]); + const [jobDate, setJobDate] = useState(""); + const [showForm, setShowForm] = useState(false); + const [loading, setLoading] = useState(true); + const [loadingMoreJobs, setLoadingMoreJobs] = useState(false); const load = useCallback( - async (opts?: { silent?: boolean }) => { + async (opts?: { appendJobs?: boolean; jobOffset?: number }) => { + const appendJobs = Boolean(opts?.appendJobs); + if (appendJobs) setLoadingMoreJobs(true); + else setLoading(true); try { - const jobQs = new URLSearchParams({ - push_date: todayBeijingISO(), - limit: "50", - offset: "0", - }); + const off = appendJobs ? Number(opts?.jobOffset ?? 0) : 0; + const jobQs = new URLSearchParams({ limit: String(JOB_PAGE), offset: String(off) }); if (jobFilter) jobQs.set("status", jobFilter); if (jobChannel) jobQs.set("channel_pk", jobChannel); - - const [status, ch, jb, ev] = await Promise.all([ - fetchJson("/api/yt-long/status"), - fetchJson("/api/yt-long/channels"), - fetchJson(`/api/yt-long/jobs?${jobQs}`), - fetchJson("/api/yt-long/events?limit=40"), - ]); - setSt(status); - setChannels(ch.channels || []); - setJobs(jb.jobs || []); - setJobTotal(Number(jb.total) || 0); - setEvents(ev.events || []); - setEventTotal(Number(ev.total) || 0); - const s = status.settings || {}; - if (s.yt_long_daily_max != null) setDailyMax(String(s.yt_long_daily_max)); - if (s.yt_long_min_sec != null) setMinSec(String(s.yt_long_min_sec)); - if (s.yt_long_max_sec != null) setMaxSec(String(s.yt_long_max_sec)); - if (typeof s.yt_long_with_shorts === "boolean") setWithShorts(s.yt_long_with_shorts); - if (typeof s.yt_long_auto_upload === "boolean") setAutoUpload(s.yt_long_auto_upload); - if (typeof s.yt_long_dedupe_room_day === "boolean") setDedupe(s.yt_long_dedupe_room_day); + if (jobDate) jobQs.set("push_date", jobDate); + if (appendJobs) { + const jb = await fetchJson(`/api/yt-long/jobs?${jobQs}`); + setJobs((prev) => [...prev, ...(jb.jobs || [])]); + setJobTotal(jb.total || 0); + } else { + const upQs = new URLSearchParams({ limit: "40", offset: "0", status: "scheduled" }); + if (!jobDate) upQs.set("push_date", todayBeijingISO()); + else upQs.set("push_date", jobDate); + const [st, ch, jb, up] = await Promise.all([ + fetchJson("/api/yt-long/status"), + fetchJson("/api/yt-long/channels"), + fetchJson(`/api/yt-long/jobs?${jobQs}`), + fetchJson(`/api/yt-long/jobs?${upQs}`), + ]); + setStatus(st); + setChannels(ch.channels || []); + setJobs(jb.jobs || []); + setJobTotal(jb.total || 0); + setUpcoming(up.jobs || []); + } } catch (e) { - if (!opts?.silent) toast.push((e as Error).message || "加载失败", "err"); + setError((e as Error).message); + toast.push((e as Error).message, "err"); + } finally { + setLoading(false); + setLoadingMoreJobs(false); } }, - [toast, jobFilter, jobChannel], + [jobChannel, jobDate, jobFilter, toast], ); useEffect(() => { void load(); + const t = setInterval(() => void load(), 10000); + return () => clearInterval(t); }, [load]); - useAutoRefresh(() => load({ silent: true }), { intervalMs: 12000 }); - async function toggle(enable: boolean) { - setBusy(enable ? "start" : "stop"); - try { - await fetchJson(enable ? "/api/yt-long/start" : "/api/yt-long/stop", { method: "POST" }); - toast.push(enable ? "已开启长视频模块" : "已关闭长视频模块", "ok"); - await load(); - } catch (e) { - toast.push((e as Error).message, "err"); - } finally { - setBusy(""); + useEffect(() => { + const left = leftPanelRef.current; + const right = rightPanelRef.current; + if (!left || !right) return; + const sync = () => { + right.style.maxHeight = `${left.getBoundingClientRect().height}px`; + }; + sync(); + const ro = new ResizeObserver(sync); + ro.observe(left); + return () => ro.disconnect(); + }); + + const boardChannels: BoardChannel[] = status?.board?.channels || []; + const beijingWindow = status?.board?.push_date || status?.stats?.push_date || ""; + const quotaGap = Number(status?.quota_gap ?? status?.board?.total_gap ?? 0); + const stats = status?.stats?.by_status || {}; + const settings = status?.settings || {}; + + const channelName = useMemo(() => { + const m: Record = {}; + for (const c of channels) m[c.id] = c.name; + for (const c of boardChannels) if (c.name) m[c.id] = c.name; + return m; + }, [channels, boardChannels]); + + const channelProfileMap = useMemo(() => { + const m: Record = {}; + for (const c of channels) m[c.id] = normalizeOauthProfileId(c.oauth_profile_id); + for (const c of boardChannels) { + const pid = normalizeOauthProfileId(c.oauth_profile_id); + if (pid) m[c.id] = pid; } - } + return m; + }, [channels, boardChannels]); - async function sampleNow() { - setBusy("sample"); - try { - const r = await fetchJson("/api/yt-long/sample-now", { method: "POST" }); - toast.push( - r.enqueued - ? `已取样入队 ${r.enqueued}(在播 ${r.live_count ?? "—"})` - : `未入队:${r.reason || "无候选"}(在播 ${r.live_count ?? 0})`, - r.enqueued ? "ok" : "warn", - ); - await load(); - } catch (e) { - toast.push((e as Error).message, "err"); - } finally { - setBusy(""); + const displayChannels = useMemo(() => { + const base: BoardChannel[] = boardChannels.length + ? boardChannels + : channels.map((c) => ({ + id: c.id, + name: c.name, + youtube_channel_id: c.youtube_channel_id, + oauth_profile_id: c.oauth_profile_id, + enabled: c.enabled, + daily_max: Number(c.daily_max ?? 1), + authorized: Boolean(c.authorized || c.has_refresh_token), + used: 0, + scheduled: 0, + uploaded: 0, + pending: 0, + failed: 0, + gap: Number(c.daily_max ?? 1), + })); + return base.map((ch) => ({ + ...ch, + oauth_profile_id: + normalizeOauthProfileId(ch.oauth_profile_id) || channelProfileMap[ch.id] || "", + })); + }, [boardChannels, channels, channelProfileMap]); + + const channelGroups = useMemo(() => { + const buckets = new Map(); + for (const ch of displayChannels) { + const key = normalizeOauthProfileId(ch.oauth_profile_id) || "_"; + const arr = buckets.get(key) || []; + arr.push(ch); + buckets.set(key, arr); } - } - - async function fillQuota() { - setBusy("fill"); - try { - const r = await fetchJson("/api/yt-long/fill-quota", { method: "POST" }); - toast.push(`补量入队 ${r.enqueued ?? 0}(剩余缺口 ${r.gap ?? "—"})`, "ok"); - await load(); - } catch (e) { - toast.push((e as Error).message, "err"); - } finally { - setBusy(""); - } - } - - async function saveSettings() { - setBusy("save"); - try { - await fetchJson("/api/yt-long/settings", { - method: "POST", - body: JSON.stringify({ - yt_long_daily_max: Number(dailyMax) || 0, - yt_long_min_sec: Number(minSec) || 180, - yt_long_max_sec: Number(maxSec) || 480, - yt_long_with_shorts: withShorts, - yt_long_auto_upload: autoUpload, - yt_long_dedupe_room_day: dedupe, - }), + for (const [k, arr] of buckets) { + arr.sort((a, b) => { + const an = String(a.name || "").localeCompare(String(b.name || ""), "zh"); + if (an !== 0) return an; + return String(a.id || "").localeCompare(String(b.id || "")); }); - toast.push("设置已保存", "ok"); + buckets.set(k, arr); + } + const order = ["A", "B", "C", "D", "_"]; + const keys = [...order.filter((k) => buckets.has(k)), ...[...buckets.keys()].filter((k) => !order.includes(k))]; + return keys.map((k) => ({ + profileId: k === "_" ? "" : k, + channels: buckets.get(k) || [], + })); + }, [displayChannels]); + + const upcomingGroups = useMemo(() => { + const buckets = new Map(); + for (const u of upcoming) { + const pk = String(u.channel_pk || ""); + const key = channelProfileMap[pk] || "_"; + const arr = buckets.get(key) || []; + arr.push(u); + buckets.set(key, arr); + } + const order = ["A", "B", "C", "D", "_"]; + const keys = [...order.filter((k) => buckets.has(k)), ...[...buckets.keys()].filter((k) => !order.includes(k))]; + return keys.map((k) => ({ + profileId: k === "_" ? "" : k, + items: buckets.get(k) || [], + })); + }, [upcoming, channelProfileMap]); + + const totals = useMemo(() => { + const uploaded = displayChannels.reduce((s, c) => s + (c.uploaded || 0), 0); + const scheduled = displayChannels.reduce((s, c) => s + (c.scheduled || 0), 0); + const used = displayChannels.reduce((s, c) => s + (c.used || 0), 0); + const cap = displayChannels.reduce((s, c) => s + (c.daily_max || 0), 0); + const gap = displayChannels + .filter((c) => c.enabled !== false) + .reduce((s, c) => s + (c.gap ?? Math.max(0, (c.daily_max || 0) - (c.used || 0))), 0); + return { uploaded, scheduled, used, cap, gap }; + }, [displayChannels]); + + async function toggle(enabled: boolean) { + setBusy(true); + setMsg(""); + setError(""); + try { + await fetchJson(enabled ? "/api/yt-long/start" : "/api/yt-long/stop", { method: "POST" }); + setMsg(enabled ? "已启用长视频(Shorts 不受影响)" : "已关闭长视频"); await load(); } catch (e) { - toast.push((e as Error).message, "err"); + setError((e as Error).message); } finally { - setBusy(""); + setBusy(false); } } async function importFromShorts() { - setBusy("import"); + setBusy(true); + setMsg(""); + setError(""); try { const r = await fetchJson("/api/yt-long/channels/import-shorts", { method: "POST" }); - toast.push(`已同步 Shorts 频道:新建 ${r.created ?? 0} · 更新 ${r.updated ?? 0}`, "ok"); + setMsg(`已同步 Shorts 频道:新建 ${r.created ?? 0} · 更新 ${r.updated ?? 0}`); + toast.push("频道已同步", "ok"); await load(); } catch (e) { + setError((e as Error).message); toast.push((e as Error).message, "err"); } finally { - setBusy(""); - } - } - - function openEdit(ch?: Channel) { - if (ch) { - setEditId(ch.id); - setForm({ - name: ch.name || "", - enabled: Boolean(ch.enabled), - daily_max: Number(ch.daily_max) || 1, - title_template: ch.title_template || "{anchor} street food live", - description_template: ch.description_template || "", - privacy: ch.privacy || "public", - note: ch.note || "", - oauth_profile_id: ch.oauth_profile_id || "A", - }); - } else { - setEditId(""); - setForm({ - name: "", - enabled: true, - daily_max: 1, - title_template: "{anchor} street food live", - description_template: "{anchor}\n{url}\n#StreetFood #Live", - privacy: "public", - note: "", - oauth_profile_id: "A", - }); + setBusy(false); } } async function saveChannel() { - setBusy("ch"); + setBusy(true); + setMsg(""); + setError(""); try { - const body = { ...form, name: form.name.trim() || "未命名长视频频道" }; + const body: Record = { + name: form.name.trim() || "未命名长视频频道", + enabled: form.enabled, + daily_max: Math.max(0, Number(form.daily_max) || 0), + title_template: form.title_template, + description_template: form.description_template, + privacy: form.privacy, + note: form.note, + oauth_profile_id: String(form.oauth_profile_id || "A").toUpperCase(), + }; if (editId) { - await fetchJson(`/api/yt-long/channels/${editId}`, { - method: "PATCH", - body: JSON.stringify(body), - }); - toast.push("频道已更新", "ok"); + await fetchJson(`/api/yt-long/channels/${editId}`, { method: "PATCH", body: JSON.stringify(body) }); + setMsg("频道已更新"); } else { await fetchJson("/api/yt-long/channels", { method: "POST", body: JSON.stringify(body) }); - toast.push("频道已创建", "ok"); + setMsg("频道已创建"); } + setForm({ ...emptyForm }); setEditId(""); + setShowForm(false); await load(); } catch (e) { - toast.push((e as Error).message, "err"); + setError((e as Error).message); } finally { - setBusy(""); + setBusy(false); } } + function startEdit(ch: Channel) { + setEditId(ch.id); + setShowForm(true); + setForm({ + name: ch.name || "", + enabled: ch.enabled !== false, + daily_max: Number(ch.daily_max ?? 1), + title_template: ch.title_template || "{anchor} street food live", + description_template: ch.description_template || "", + privacy: ch.privacy || "public", + note: ch.note || "", + oauth_profile_id: (ch.oauth_profile_id || "A").toUpperCase(), + }); + } + async function removeChannel(id: string) { const ok = await confirm({ title: "删除长视频频道", - message: "将删除该频道及其长视频任务(不影响 Shorts)。", + message: "确定删除该频道?将同时删除该频道下全部长视频任务(不影响 Shorts)。", + confirmLabel: "删除", + destructive: true, }); if (!ok) return; - setBusy(`del-${id}`); - try { - const r = await fetchJson(`/api/yt-long/channels/${id}`, { method: "DELETE" }); - toast.push(`已删除(任务 ${r.jobs ?? 0})`, "ok"); - await load(); - } catch (e) { - toast.push((e as Error).message, "err"); - } finally { - setBusy(""); - } + const r = await fetchJson(`/api/yt-long/channels/${id}`, { method: "DELETE" }); + toast.push(`频道已删除(任务 ${r.jobs ?? 0})`, "ok"); + await load(); } async function retryJob(id: string) { - setBusy(`retry-${id}`); - try { - await fetchJson(`/api/yt-long/jobs/${id}/retry`, { method: "POST" }); - toast.push("已重新入队", "ok"); - await load(); - } catch (e) { - toast.push((e as Error).message, "err"); - } finally { - setBusy(""); - } + await fetchJson(`/api/yt-long/jobs/${id}/retry`, { method: "POST" }); + toast.push("已重新入队", "ok"); + await load(); } - const board = st?.board?.channels || []; - const used = st?.quota_used ?? 0; - const max = st?.daily_max ?? 0; - const gap = st?.quota_gap ?? 0; - - const tabs: Array<{ id: typeof tab; label: string }> = [ - { id: "channels", label: `频道(${channels.length})` }, - { id: "jobs", label: `任务(${jobTotal})` }, - { id: "logs", label: `日志(${eventTotal})` }, - ]; - return ( -
+
-

- - YouTube 长视频 -

-

- 独立模块:自有频道表 / 任务表 / 日志(yt_long_*)。3–8 分钟 16:9 横屏上传为普通视频,默认关闭,不碰 Shorts 数据。 +

Long Video Pipeline

+

📺 长视频分发台

+

+ 在播放样 → 16:9 成片 → 上传为普通 YouTube 视频(watch?v=)。频道 OAuth 可从 Shorts 同步,数据与 Shorts 隔离。

- - - - {st?.enabled ? ( - - ) : ( - - )}
-
-
-
今日配额
-
- {used}/{max} +
+ {[ + [ + "北京日配额", + `${totals.used} / ${totals.cap || status?.daily_max || "—"}`, + beijingWindow ? `${beijingWindow}(北京时间)` : "按各频道日上限合计", + ], + ["当日缺口", String(totals.gap || quotaGap), `全局上限 ${status?.daily_max ?? "—"}`], + ["已上传", String(totals.uploaded), `排队 ${totals.scheduled}`], + [ + "抖音在播源", + String(status?.douyin_live_count ?? "—"), + settings.yt_long_live_sample === false ? "在播放样已关" : "取样来自监控在播直播间", + ], + [ + "成片规格", + `${Math.round(Number(settings.yt_long_min_sec || 180) / 60)}–${Math.round(Number(settings.yt_long_max_sec || 480) / 60)}分`, + "16:9 横屏 · 非 Shorts", + ], + ].map(([label, value, hint]) => ( +
+
{label}
+
{value}
+
{hint}
-
剩余 {gap}
-
-
-
状态
-
- {st?.enabled ? (st.running ? "运行中" : "已启用") : "已关闭"} -
-
{st?.busy ? "忙碌" : "空闲"}
-
-
-
频道缺口
-
{st?.board?.total_gap ?? 0}
-
-
-
成片规格 / 在播
-
16:9 · 3–8 分钟
-
抖音在播 {st?.douyin_live_count ?? "—"}
-
-
- - {st?.last_error ? ( -
- {st.last_error} -
- ) : null} - -
- {tabs.map((t) => ( - ))}
- {tab === "channels" ? ( -
-
-
-
-
-

频道配额

-

独立 yt_long_channels · 可从 Shorts 导入 OAuth

-
-
- - -
-
- {!board.length && !channels.length ? ( -
- 暂无长视频频道。点「从 Shorts 导入」或「新频道」。 -
- ) : ( -
- {(board.length ? board : channels.map((c) => ({ - id: c.id, - name: c.name, - enabled: c.enabled, - authorized: c.authorized, - daily_max: Number(c.daily_max) || 0, - used: 0, - gap: 0, - uploaded: 0, - scheduled: 0, - pending: 0, - failed: 0, - oauth_profile_id: c.oauth_profile_id, - oauth_error: c.oauth_error, - }))).map((ch) => { - const full = channels.find((x) => x.id === ch.id); - return ( -
-
-
-
{ch.name || "未命名"}
-
- Client {ch.oauth_profile_id || "—"} - {ch.enabled ? " · 启用" : " · 停用"} - {ch.authorized ? " · 已授权" : " · 未授权"} -
-
- - {ch.used}/{ch.daily_max} - -
-
-
0 ? Math.min(100, (ch.used / ch.daily_max) * 100) : 0}%`, - }} - /> -
-
- 上传 {ch.uploaded} - 待传 {ch.scheduled} - 排队 {ch.pending} - 失败 {ch.failed} -
- {ch.oauth_error ? ( -
{ch.oauth_error}
- ) : null} -
- - -
-
- ); - })} -
- )} -
+
+ 开关 + + + + worker {status?.running ? "运行中" : "未运行"} + {status?.busy ? " · 忙碌" : ""} · 处理 {status?.processed ?? 0} · 取样 {status?.sampled ?? 0} + + + + + +
-
-

全局参数

-
- - - + {msg ?
{msg}
: null} + {error ?
{error}
: null} + {status?.last_error ? ( +
+ 最近错误:{status.last_error} +
+ ) : null} + + {loading && !status ? : null} + + {!loading || status ? ( + <> +
+
+
+

频道配额({channels.length})

+ + 按 Client A/B/C/D 分组 · 北京日 {beijingWindow || "—"} · 独立 yt_long_channels +
-
- - - +
+ {channelGroups.length === 0 ? ( +
+ 暂无频道。点「同步 Shorts 频道」或「新频道」。 +
+ ) : ( + channelGroups.map((group) => ( +
+
+ + + {group.profileId ? `谷歌账号 ${group.profileId}` : "未绑定配置档"} + + + {group.channels.length} 个频道 + +
+
+ {group.channels.map((ch) => { + const pct = Math.min(100, Math.round((ch.used / Math.max(1, ch.daily_max)) * 100)); + const full = channels.find((x) => x.id === ch.id); + const gap = ch.gap ?? Math.max(0, ch.daily_max - ch.used); + return ( +
+
+
+
+ +
{ch.name || "未命名"}
+
+
+ {ch.youtube_channel_id || "—"} +
+
+
+ + {ch.enabled === false ? "停用" : "启用"} + + + {ch.authorized ? "已授权" : "未授权"} + +
+
+
+
= 100 ? "bg-teal-400" : "bg-amber-400"}`} + style={{ width: `${pct}%` }} + /> +
+
+ + {ch.used}/{ch.daily_max || 0} + + {gap > 0 ? ( + 缺 {gap} + ) : ( + 已满 + )} + 上传 {ch.uploaded} + 排队 {ch.scheduled} + 待录 {ch.pending} +
+
+ {full ? ( + + ) : null} + +
+
+ ); + })} +
+
+ )) + )}
- -
+
+ +
+
+
+ +

即将上传

+
+ + 素材 {upcoming.length} + +
+

+ 北京日 {beijingWindow || "—"} · 按 Client A/B/C/D 分组 · 成片后自动排程上传 +

+
+ {upcoming.length === 0 ? ( +
+ 暂无排程。取样入队并成片后会出现在这里。 +
+ ) : ( + upcomingGroups.map((group) => ( +
+
+ + {group.items.length} 条待传 +
+ {group.items.map((u) => ( +
+
+
+
{u.anchor_name || "—"}
+
+ {channelName[String(u.channel_pk || "")] || "—"} + {u.upload_at ? ` · ${fmtTs(u.upload_at)}` : ""} +
+
+ + {u.status} + +
+
+ ))} +
+ )) + )} +
+
-
-

{editId ? "编辑频道" : "新增频道"}

-

标题勿含 #Shorts;OAuth 可用「从 Shorts 导入」带入。

- -
- - + + + + + + +
+
+ + +
+ + ) : null} + +
+
+

+ 任务流水({jobTotal}) + + pending {stats.pending || 0} · scheduled {stats.scheduled || 0} · uploaded {stats.uploaded || 0} · + failed {stats.failed || 0} + +

+
+ + + - -
- -