Group Shorts channels and upcoming uploads by OAuth Client A/B/C/D.

Same-named channels are split into account sections with colored Client badges on cards, schedule rows, and job lists.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
eric 2026-08-11 19:43:24 -05:00
parent 74e2b91228
commit b752943d22
6 changed files with 335 additions and 139 deletions

View File

@ -400,6 +400,13 @@ def _enrich_shorts_job(job: dict[str, Any] | None) -> dict[str, Any] | None:
out = dict(job) out = dict(job)
clip = str(out.get("clip_path") or "").strip() clip = str(out.get("clip_path") or "").strip()
out["clip_ready"] = bool(clip) and Path(clip).is_file() out["clip_ready"] = bool(clip) and Path(clip).is_file()
ch = db.get_shorts_channel(str(out.get("channel_pk") or "")) or {}
if ch:
out["channel_name"] = str(ch.get("name") or out.get("channel_name") or "")
out["oauth_profile_id"] = str(ch.get("oauth_profile_id") or "").strip().upper()
else:
out.setdefault("channel_name", "")
out.setdefault("oauth_profile_id", "")
return out return out

View File

@ -185,6 +185,7 @@ def schedule_board(limit: int = 24) -> dict[str, Any]:
"room_id": j.get("room_id"), "room_id": j.get("room_id"),
"channel_pk": j.get("channel_pk"), "channel_pk": j.get("channel_pk"),
"channel_name": ch.get("name") or "", "channel_name": ch.get("name") or "",
"oauth_profile_id": str(ch.get("oauth_profile_id") or "").strip().upper(),
"status": j.get("status"), "status": j.get("status"),
"clip_ready": clip_ready, "clip_ready": clip_ready,
"can_upload_now": str(j.get("status") or "") in {"scheduled", "recorded"} "can_upload_now": str(j.get("status") or "") in {"scheduled", "recorded"}
@ -215,10 +216,11 @@ def schedule_board(limit: int = 24) -> dict[str, Any]:
"id": cid, "id": cid,
"name": c.get("name"), "name": c.get("name"),
"youtube_channel_id": c.get("youtube_channel_id"), "youtube_channel_id": c.get("youtube_channel_id"),
"oauth_profile_id": str(c.get("oauth_profile_id") or "").strip().upper(),
"enabled": bool(c.get("enabled")), "enabled": bool(c.get("enabled")),
"authorized": bool(str(c.get("refresh_token") or "").strip()),
"daily_min": daily_min, "daily_min": daily_min,
"daily_max": daily_max, "daily_max": daily_max,
"authorized": bool(str(c.get("refresh_token") or "").strip()),
"gap": gap, "gap": gap,
"min_met": min_met, "min_met": min_met,
"max_met": used >= daily_max, "max_met": used >= daily_max,

View File

@ -20,6 +20,7 @@ import { Shell } from "@/components/Shell";
import { useConfirm } from "@/components/ConfirmDialog"; import { useConfirm } from "@/components/ConfirmDialog";
import { useToast } from "@/components/Toast"; import { useToast } from "@/components/Toast";
import { GoogleOauthSetupWizard } from "@/components/GoogleOauthSetupWizard"; import { GoogleOauthSetupWizard } from "@/components/GoogleOauthSetupWizard";
import { OauthClientBadge, normalizeOauthProfileId } from "@/components/OauthClientBadge";
import { ShortsJobDetailModal } from "@/components/ShortsJobDetailModal"; import { ShortsJobDetailModal } from "@/components/ShortsJobDetailModal";
import { import {
ShortsUploadConfirmModal, ShortsUploadConfirmModal,
@ -67,6 +68,7 @@ type BoardChannel = {
id: string; id: string;
name?: string; name?: string;
youtube_channel_id?: string; youtube_channel_id?: string;
oauth_profile_id?: string;
enabled?: boolean; enabled?: boolean;
daily_min: number; daily_min: number;
daily_max: number; daily_max: number;
@ -272,19 +274,104 @@ export default function ShortsPage() {
for (const c of boardChannels) if (c.name) m[c.id] = c.name; for (const c of boardChannels) if (c.name) m[c.id] = c.name;
return m; return m;
}, [channels, boardChannels]); }, [channels, boardChannels]);
const channelProfileMap = useMemo(() => {
const m: Record<string, string> = {};
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]);
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_min: Number(c.daily_min ?? 9),
daily_max: Number(c.daily_max ?? 9),
authorized: Boolean(c.authorized || c.has_refresh_token),
used: 0,
scheduled: 0,
uploaded: 0,
pending: 0,
gap: Number(c.daily_max ?? 9),
min_met: false,
max_met: false,
behind_pace: false,
}));
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<string, BoardChannel[]>();
for (const ch of displayChannels) {
const key = normalizeOauthProfileId(ch.oauth_profile_id) || "_";
const arr = buckets.get(key) || [];
arr.push(ch);
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,
channels: buckets.get(k) || [],
}));
}, [displayChannels]);
const upcomingGroups = useMemo(() => {
const buckets = new Map<string, any[]>();
for (const u of upcoming) {
const pk = String(u.channel_pk || "");
const key =
normalizeOauthProfileId(u.oauth_profile_id) || 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 profileLabelMap = useMemo(() => {
const m: Record<string, string> = {};
for (const p of (status?.oauth_profiles || []) as OauthProfile[]) {
m[normalizeOauthProfileId(p.id)] = String(p.label || `谷歌账号 ${p.id}`);
}
for (const c of channels) {
const pid = normalizeOauthProfileId(c.oauth_profile_id);
if (pid && c.oauth_profile_label) m[pid] = c.oauth_profile_label;
}
return m;
}, [status?.oauth_profiles, channels]);
const totals = useMemo(() => { const totals = useMemo(() => {
const uploaded = boardChannels.reduce((s, c) => s + (c.uploaded || 0), 0); const uploaded = displayChannels.reduce((s, c) => s + (c.uploaded || 0), 0);
const scheduled = boardChannels.reduce((s, c) => s + (c.scheduled || 0), 0); const scheduled = displayChannels.reduce((s, c) => s + (c.scheduled || 0), 0);
const used = boardChannels.reduce((s, c) => s + (c.used || 0), 0); const used = displayChannels.reduce((s, c) => s + (c.used || 0), 0);
const cap = boardChannels.reduce((s, c) => s + (c.daily_max || 9), 0); const cap = displayChannels.reduce((s, c) => s + (c.daily_max || 9), 0);
const minTarget = boardChannels.filter((c) => c.enabled !== false).reduce((s, c) => s + (c.daily_min || 9), 0); const minTarget = displayChannels.filter((c) => c.enabled !== false).reduce((s, c) => s + (c.daily_min || 9), 0);
const gap = boardChannels.filter((c) => c.enabled !== false).reduce((s, c) => s + (c.gap ?? Math.max(0, (c.daily_max || 9) - (c.used || 0))), 0); const gap = displayChannels
.filter((c) => c.enabled !== false)
.reduce((s, c) => s + (c.gap ?? Math.max(0, (c.daily_max || 9) - (c.used || 0))), 0);
return { uploaded, scheduled, used, cap, minTarget, gap }; return { uploaded, scheduled, used, cap, minTarget, gap };
}, [boardChannels]); }, [displayChannels]);
const hoursLeft = secondsLeft > 0 ? `${Math.floor(secondsLeft / 3600)}h${Math.floor((secondsLeft % 3600) / 60)}m` : "—"; const hoursLeft = secondsLeft > 0 ? `${Math.floor(secondsLeft / 3600)}h${Math.floor((secondsLeft % 3600) / 60)}m` : "—";
const behindChannels = boardChannels.filter((c) => c.enabled !== false && c.behind_pace); const behindChannels = displayChannels.filter((c) => c.enabled !== false && c.behind_pace);
const oauthIssues = (status?.oauth_issues || []) as Array<{ const oauthIssues = (status?.oauth_issues || []) as Array<{
id: string; id: string;
name?: string; name?: string;
@ -482,12 +569,15 @@ export default function ShortsPage() {
} }
function toUploadTarget(u: Record<string, unknown>, channelMap: Record<string, string>): ShortsUploadTarget { function toUploadTarget(u: Record<string, unknown>, channelMap: Record<string, string>): ShortsUploadTarget {
const pk = String(u.channel_pk || "");
return { return {
id: String(u.id || ""), id: String(u.id || ""),
anchor_name: String(u.anchor_name || ""), anchor_name: String(u.anchor_name || ""),
room_id: String(u.room_id || ""), room_id: String(u.room_id || ""),
channel_name: String(u.channel_name || channelMap[String(u.channel_pk || "")] || ""), channel_name: String(u.channel_name || channelMap[pk] || ""),
channel_pk: String(u.channel_pk || ""), channel_pk: pk,
oauth_profile_id:
normalizeOauthProfileId(String(u.oauth_profile_id || "")) || channelProfileMap[pk] || "",
upload_at: Number(u.upload_at || 0) || undefined, upload_at: Number(u.upload_at || 0) || undefined,
clip_ready: u.clip_ready !== false, clip_ready: u.clip_ready !== false,
status: String(u.status || ""), status: String(u.status || ""),
@ -949,125 +1039,130 @@ export default function ShortsPage() {
<div className="mb-3 flex items-center justify-between gap-2"> <div className="mb-3 flex items-center justify-between gap-2">
<h3 className="text-sm font-medium text-slate-100">频道配额({channels.length})</h3> <h3 className="text-sm font-medium text-slate-100">频道配额({channels.length})</h3>
<span className="text-[11px] text-slate-500"> <span className="text-[11px] text-slate-500">
北京日 {beijingWindow || "—"} · 每频道强制 9 条/日 按 Client A/B/C/D 分组 · 北京日 {beijingWindow || "—"} · 每频道 9 条/日
</span> </span>
</div> </div>
<div className="grid gap-3 sm:grid-cols-2"> <div className="space-y-4">
{(boardChannels.length ? boardChannels : channels.map((c) => ({ {channelGroups.length === 0 ? (
id: c.id, <div className="rounded-xl border border-dashed border-white/10 px-3 py-8 text-center text-sm text-slate-500">
name: c.name, 暂无频道。点「新频道」并选择 OAuth 配置档 A/B/C/D。
youtube_channel_id: c.youtube_channel_id, </div>
enabled: c.enabled, ) : (
daily_min: Number(c.daily_min ?? 9), channelGroups.map((group) => (
daily_max: Number(c.daily_max ?? 9), <div key={group.profileId || "none"} className="space-y-2">
authorized: Boolean(c.authorized || c.has_refresh_token), <div className="flex flex-wrap items-center gap-2 border-b border-white/5 pb-2">
used: 0, <OauthClientBadge
scheduled: 0, profileId={group.profileId}
uploaded: 0, label={profileLabelMap[group.profileId]}
pending: 0, size="lg"
gap: Number(c.daily_max ?? 9),
min_met: false,
max_met: false,
behind_pace: false,
}))).map((ch) => {
const pct = Math.min(100, Math.round((ch.used / Math.max(1, ch.daily_max)) * 100));
const minPct = Math.round((ch.daily_min / 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);
const warn = ch.enabled !== false && (ch.behind_pace || (!ch.min_met && gap > 0));
return (
<div
key={ch.id}
className={`rounded-xl border bg-gradient-to-br from-white/[0.04] to-transparent p-3 ${
warn ? "border-amber-500/35" : ch.max_met ? "border-teal-500/30" : "border-white/10"
}`}
>
<div className="flex items-start justify-between gap-2">
<div className="min-w-0">
<div className="flex flex-wrap items-center gap-2">
<div className="truncate font-medium text-slate-100">{ch.name || "未命名"}</div>
<YouTubeLiveBadge refKey={shortsLiveRef(ch.id)} compact showOffline />
</div>
<div className="mt-0.5 truncate font-mono text-[10px] text-slate-500">
{ch.youtube_channel_id || "—"}
</div>
</div>
<div className="flex shrink-0 flex-col items-end gap-1 text-[10px]">
<span className={ch.enabled === false ? "text-slate-500" : "text-teal-300"}>
{ch.enabled === false ? "停用" : "启用"}
</span>
<span
className={
oauthIssues.some((x) => x.id === ch.id)
? "text-rose-300"
: ch.authorized
? "text-teal-300"
: "text-amber-300"
}
>
{oauthIssues.some((x) => x.id === ch.id)
? "OAuth 异常"
: ch.authorized
? "已授权"
: "未授权"}
</span>
{full?.oauth_profile_id ? (
<span className="text-violet-300" title={full.oauth_profile_label || full.oauth_profile_id}>
OAuth {full.oauth_profile_id}
</span>
) : full?.oauth_client_source === "global" ? (
<span className="text-slate-500" title="使用全局 / 默认 Client">
默认 Client
</span>
) : null}
</div>
</div>
<div className="relative mt-3 h-1.5 overflow-hidden rounded-full bg-white/10">
<div
className="pointer-events-none absolute inset-y-0 w-0.5 bg-amber-400/60"
style={{ left: `${minPct}%` }}
/> />
<div <span className="text-xs text-slate-400">
className={`h-full rounded-full ${pct >= 100 ? "bg-teal-400" : pct >= minPct ? "bg-amber-400" : "bg-rose-400"}`} {profileLabelMap[group.profileId] || (group.profileId ? `谷歌账号 ${group.profileId}` : "未绑定配置档")}
style={{ width: `${pct}%` }} </span>
/> <span className="rounded-full bg-white/5 px-2 py-0.5 text-[11px] text-slate-300">
</div> {group.channels.length} 个频道
<div className="mt-2 flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-slate-400">
<span>
{ch.used}/{ch.daily_max || 9}
<span className="text-slate-600">(强制 9)</span>
</span> </span>
{gap > 0 ? <span className="text-amber-300">缺 {gap}</span> : <span className="text-teal-300">已满</span>}
<span>上传 {ch.uploaded}</span>
<span>排队 {ch.scheduled}</span>
<span>待录 {ch.pending}</span>
</div> </div>
<div className="mt-3 flex flex-wrap gap-1.5"> <div className="grid gap-3 sm:grid-cols-2">
<button {group.channels.map((ch) => {
type="button" const pct = Math.min(100, Math.round((ch.used / Math.max(1, ch.daily_max)) * 100));
onClick={() => goAuthorize(ch.id)} const minPct = Math.round((ch.daily_min / Math.max(1, ch.daily_max)) * 100);
className="inline-flex items-center gap-1 rounded-lg bg-amber-500/15 px-2 py-1 text-[11px] text-amber-100" const full = channels.find((x) => x.id === ch.id);
> const gap = ch.gap ?? Math.max(0, ch.daily_max - ch.used);
<KeyRound className="h-3 w-3" /> const warn = ch.enabled !== false && (ch.behind_pace || (!ch.min_met && gap > 0));
{ch.authorized ? "重授权" : "授权"} return (
</button> <div
{full ? ( key={ch.id}
<button type="button" onClick={() => startEdit(full)} className="rounded-lg bg-white/5 px-2 py-1 text-[11px]"> className={`rounded-xl border bg-gradient-to-br from-white/[0.04] to-transparent p-3 ${
编辑 warn ? "border-amber-500/35" : ch.max_met ? "border-teal-500/30" : "border-white/10"
</button> }`}
) : null} >
<button <div className="flex items-start justify-between gap-2">
type="button" <div className="min-w-0">
onClick={() => void removeChannel(ch.id)} <div className="flex flex-wrap items-center gap-2">
className="inline-flex items-center gap-1 rounded-lg bg-rose-500/10 px-2 py-1 text-[11px] text-rose-200" <OauthClientBadge profileId={ch.oauth_profile_id} size="sm" />
> <div className="truncate font-medium text-slate-100">{ch.name || "未命名"}</div>
<Trash2 className="h-3 w-3" /> <YouTubeLiveBadge refKey={shortsLiveRef(ch.id)} compact showOffline />
删 </div>
</button> <div className="mt-0.5 truncate font-mono text-[10px] text-slate-500">
{ch.youtube_channel_id || "—"}
</div>
</div>
<div className="flex shrink-0 flex-col items-end gap-1 text-[10px]">
<span className={ch.enabled === false ? "text-slate-500" : "text-teal-300"}>
{ch.enabled === false ? "停用" : "启用"}
</span>
<span
className={
oauthIssues.some((x) => x.id === ch.id)
? "text-rose-300"
: ch.authorized
? "text-teal-300"
: "text-amber-300"
}
>
{oauthIssues.some((x) => x.id === ch.id)
? "OAuth 异常"
: ch.authorized
? "已授权"
: "未授权"}
</span>
</div>
</div>
<div className="relative mt-3 h-1.5 overflow-hidden rounded-full bg-white/10">
<div
className="pointer-events-none absolute inset-y-0 w-0.5 bg-amber-400/60"
style={{ left: `${minPct}%` }}
/>
<div
className={`h-full rounded-full ${pct >= 100 ? "bg-teal-400" : pct >= minPct ? "bg-amber-400" : "bg-rose-400"}`}
style={{ width: `${pct}%` }}
/>
</div>
<div className="mt-2 flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-slate-400">
<span>
{ch.used}/{ch.daily_max || 9}
<span className="text-slate-600">(强制 9)</span>
</span>
{gap > 0 ? <span className="text-amber-300">缺 {gap}</span> : <span className="text-teal-300">已满</span>}
<span>上传 {ch.uploaded}</span>
<span>排队 {ch.scheduled}</span>
<span>待录 {ch.pending}</span>
</div>
<div className="mt-3 flex flex-wrap gap-1.5">
<button
type="button"
onClick={() => goAuthorize(ch.id)}
className="inline-flex items-center gap-1 rounded-lg bg-amber-500/15 px-2 py-1 text-[11px] text-amber-100"
>
<KeyRound className="h-3 w-3" />
{ch.authorized ? "重授权" : "授权"}
</button>
{full ? (
<button
type="button"
onClick={() => startEdit(full)}
className="rounded-lg bg-white/5 px-2 py-1 text-[11px]"
>
编辑
</button>
) : null}
<button
type="button"
onClick={() => void removeChannel(ch.id)}
className="inline-flex items-center gap-1 rounded-lg bg-rose-500/10 px-2 py-1 text-[11px] text-rose-200"
>
<Trash2 className="h-3 w-3" />
删
</button>
</div>
</div>
);
})}
</div> </div>
</div> </div>
); ))
})} )}
</div> </div>
</section> </section>
@ -1082,22 +1177,34 @@ export default function ShortsPage() {
</span> </span>
</div> </div>
<p className="mb-3 shrink-0 text-[11px] text-slate-500"> <p className="mb-3 shrink-0 text-[11px] text-slate-500">
北京 {status?.board?.beijing_hint || "—"} · 点击「立即上传」确认后发布 · 上传过程有进度提示 北京 {status?.board?.beijing_hint || "—"} · 按 Client A/B/C/D 分组 · 点击「立即上传」确认后发布
</p> </p>
<div className="min-h-0 flex-1 space-y-2 overflow-y-auto pr-1"> <div className="min-h-0 flex-1 space-y-3 overflow-y-auto pr-1">
{upcoming.length === 0 ? ( {upcoming.length === 0 ? (
<div className="rounded-xl border border-dashed border-white/10 px-3 py-8 text-center text-sm text-slate-500"> <div className="rounded-xl border border-dashed border-white/10 px-3 py-8 text-center text-sm text-slate-500">
暂无排程。取样或开播入队后,成片会自动分散到今日各时段。 暂无排程。取样或开播入队后,成片会自动分散到今日各时段。
</div> </div>
) : ( ) : (
upcoming.map((u: any) => ( upcomingGroups.map((group) => (
<ShortsUpcomingUploadRow <div key={group.profileId || "none"} className="space-y-2">
key={u.id} <div className="flex flex-wrap items-center gap-2">
item={toUploadTarget(u, channelName)} <OauthClientBadge
track={uploadUx.tracks[u.id]} profileId={group.profileId}
onRequestUpload={uploadUx.openConfirm} label={profileLabelMap[group.profileId]}
onRetry={uploadUx.retryUpload} size="md"
/> />
<span className="text-[11px] text-slate-400">{group.items.length} 条待传</span>
</div>
{group.items.map((u: any) => (
<ShortsUpcomingUploadRow
key={u.id}
item={toUploadTarget(u, channelName)}
track={uploadUx.tracks[u.id]}
onRequestUpload={uploadUx.openConfirm}
onRetry={uploadUx.retryUpload}
/>
))}
</div>
)) ))
)} )}
</div> </div>
@ -1255,7 +1362,9 @@ export default function ShortsPage() {
<option value="">全部频道</option> <option value="">全部频道</option>
{channels.map((c) => ( {channels.map((c) => (
<option key={c.id} value={c.id}> <option key={c.id} value={c.id}>
{c.name} {normalizeOauthProfileId(c.oauth_profile_id)
? `[Client ${normalizeOauthProfileId(c.oauth_profile_id)}] ${c.name}`
: c.name}
</option> </option>
))} ))}
</select> </select>
@ -1354,7 +1463,13 @@ export default function ShortsPage() {
</button> </button>
</td> </td>
<td className="py-2.5 pr-2 text-xs text-slate-400"> <td className="py-2.5 pr-2 text-xs text-slate-400">
{channelName[String(j.channel_pk || "")] || "—"} <div className="flex flex-wrap items-center gap-1.5">
<OauthClientBadge
profileId={channelProfileMap[String(j.channel_pk || "")]}
size="sm"
/>
<span>{channelName[String(j.channel_pk || "")] || "—"}</span>
</div>
</td> </td>
<td className="py-2.5 pr-2 text-xs text-slate-400"> <td className="py-2.5 pr-2 text-xs text-slate-400">
{j.upload_at ? fmtTs(Number(j.upload_at)) : "—"} {j.upload_at ? fmtTs(Number(j.upload_at)) : "—"}

View File

@ -0,0 +1,57 @@
"use client";
/** Distinct A/B/C/D OAuth client tags for same-named YouTube channels. */
const PROFILE_STYLE: Record<string, string> = {
A: "border-sky-400/50 bg-sky-500/25 text-sky-100",
B: "border-violet-400/50 bg-violet-500/25 text-violet-100",
C: "border-amber-400/50 bg-amber-500/25 text-amber-100",
D: "border-rose-400/50 bg-rose-500/25 text-rose-100",
};
export function normalizeOauthProfileId(raw?: string | null): string {
return String(raw || "").trim().toUpperCase();
}
export function OauthClientBadge({
profileId,
label,
size = "md",
className = "",
}: {
profileId?: string | null;
label?: string | null;
size?: "sm" | "md" | "lg";
className?: string;
}) {
const id = normalizeOauthProfileId(profileId);
if (!id) {
return (
<span
className={`inline-flex shrink-0 items-center rounded border border-white/15 bg-white/5 font-semibold tracking-wide text-slate-400 ${
size === "lg" ? "px-2 py-0.5 text-xs" : size === "sm" ? "px-1.5 py-0 text-[10px]" : "px-1.5 py-0.5 text-[10px]"
} ${className}`}
title="未绑定 OAuth 配置档"
>
Client —
</span>
);
}
const style = PROFILE_STYLE[id] || "border-teal-400/40 bg-teal-500/20 text-teal-100";
const sizeCls =
size === "lg" ? "px-2.5 py-1 text-xs" : size === "sm" ? "px-1.5 py-0 text-[10px]" : "px-2 py-0.5 text-[11px]";
return (
<span
className={`inline-flex shrink-0 items-center rounded border font-bold tracking-wide ${style} ${sizeCls} ${className}`}
title={label || `OAuth 配置档 ${id}`}
>
Client {id}
</span>
);
}
export function channelLabelWithProfile(name?: string | null, profileId?: string | null): string {
const n = String(name || "").trim() || "未命名";
const id = normalizeOauthProfileId(profileId);
return id ? `${n} · Client ${id}` : n;
}

View File

@ -4,6 +4,7 @@ import { ExternalLink, Loader2, X } from "lucide-react";
import { useEffect, useState, type ReactNode } from "react"; import { useEffect, useState, type ReactNode } from "react";
import { Modal } from "@/components/Modal"; import { Modal } from "@/components/Modal";
import { OauthClientBadge } from "@/components/OauthClientBadge";
import { fetchJson, fmtTs } from "@/lib/api"; import { fetchJson, fmtTs } from "@/lib/api";
type JobDetail = { type JobDetail = {
@ -13,6 +14,7 @@ type JobDetail = {
room_id?: string; room_id?: string;
channel_name?: string; channel_name?: string;
channel_pk?: string; channel_pk?: string;
oauth_profile_id?: string;
push_date?: string; push_date?: string;
clip_path?: string; clip_path?: string;
clip_ready?: boolean; clip_ready?: boolean;
@ -124,7 +126,12 @@ export function ShortsJobDetailModal({
{job.status} {job.status}
</span> </span>
</Row> </Row>
<Row label="频道">{job.channel_name || "—"}</Row> <Row label="频道">
<div className="flex flex-wrap items-center gap-2">
<OauthClientBadge profileId={job.oauth_profile_id} size="sm" />
<span>{job.channel_name || "—"}</span>
</div>
</Row>
<Row label="北京日">{job.push_date || "—"}</Row> <Row label="北京日">{job.push_date || "—"}</Row>
<Row label="排程上传">{job.upload_at ? fmtTs(Number(job.upload_at)) : "—"}</Row> <Row label="排程上传">{job.upload_at ? fmtTs(Number(job.upload_at)) : "—"}</Row>
<Row label="创建">{job.created_at ? fmtTs(Number(job.created_at)) : "—"}</Row> <Row label="创建">{job.created_at ? fmtTs(Number(job.created_at)) : "—"}</Row>

View File

@ -11,6 +11,7 @@ import {
} from "lucide-react"; } from "lucide-react";
import { Modal } from "@/components/Modal"; import { Modal } from "@/components/Modal";
import { OauthClientBadge } from "@/components/OauthClientBadge";
import { useToast } from "@/components/Toast"; import { useToast } from "@/components/Toast";
import { fetchJson, fmtTs } from "@/lib/api"; import { fetchJson, fmtTs } from "@/lib/api";
@ -20,6 +21,7 @@ export type ShortsUploadTarget = {
room_id?: string; room_id?: string;
channel_name?: string; channel_name?: string;
channel_pk?: string; channel_pk?: string;
oauth_profile_id?: string;
upload_at?: number; upload_at?: number;
clip_ready?: boolean; clip_ready?: boolean;
status?: string; status?: string;
@ -200,7 +202,10 @@ export function ShortsUploadConfirmModal({
<div className="rounded-xl border border-white/10 bg-black/30 p-3"> <div className="rounded-xl border border-white/10 bg-black/30 p-3">
<div className="font-medium text-slate-100">{label}</div> <div className="font-medium text-slate-100">{label}</div>
<div className="mt-2 space-y-1 text-xs text-slate-400"> <div className="mt-2 space-y-1 text-xs text-slate-400">
<div>目标频道 · {target.channel_name || "—"}</div> <div className="flex flex-wrap items-center gap-2">
<span>目标频道 · {target.channel_name || "—"}</span>
<OauthClientBadge profileId={target.oauth_profile_id} size="sm" />
</div>
<div>原错峰排程 · {scheduled}</div> <div>原错峰排程 · {scheduled}</div>
<div>{target.clip_ready === false ? "成片状态 · 等待录制完成" : "成片状态 · 已就绪"}</div> <div>{target.clip_ready === false ? "成片状态 · 等待录制完成" : "成片状态 · 已就绪"}</div>
</div> </div>
@ -301,8 +306,11 @@ export function ShortsUpcomingUploadRow({
)} )}
</div> </div>
<div className="min-w-0 flex-1"> <div className="min-w-0 flex-1">
<div className="text-sm font-medium text-slate-100">{label}</div> <div className="flex flex-wrap items-center gap-2">
<div className="text-[11px] text-slate-500"> <div className="text-sm font-medium text-slate-100">{label}</div>
<OauthClientBadge profileId={item.oauth_profile_id} size="sm" />
</div>
<div className="mt-0.5 text-[11px] text-slate-500">
{item.channel_name || "频道"} {item.channel_name || "频道"}
{item.upload_at ? ` · 排程 ${fmtTs(Number(item.upload_at))}` : " · 待排程"} {item.upload_at ? ` · 排程 ${fmtTs(Number(item.upload_at))}` : " · 待排程"}
{!clipReady ? " · 等待成片" : phase === "idle" ? " · 成片就绪" : ""} {!clipReady ? " · 等待成片" : phase === "idle" ? " · 成片就绪" : ""}