Remove the primary-pushing follow effect so operators can switch lanes while another line is live, keep logs and events tied to the selected lane, and ship the rebuilt console plus a deploy verification helper. Co-authored-by: Cursor <cursoragent@cursor.com>
569 lines
24 KiB
TypeScript
569 lines
24 KiB
TypeScript
"use client";
|
||
|
||
import { AlertTriangle, ExternalLink, Pause, Play, RefreshCw } from "lucide-react";
|
||
import { useCallback, useEffect, useRef, useState } from "react";
|
||
|
||
import { formatPollBadge } from "@/lib/adaptivePoll";
|
||
import {
|
||
douyinSourceDisplayFrom,
|
||
extractDouyinCurrentRoomFromLog,
|
||
extractDouyinLiveUrls,
|
||
extractDouyinRoomHints,
|
||
} from "@/lib/youtubeConfigUtils";
|
||
|
||
type TFn = (zh: string, en: string) => string;
|
||
|
||
type StatusPayload = {
|
||
process_status?: string;
|
||
recent_log?: string;
|
||
recent_error?: string;
|
||
business_status?: string;
|
||
business_note?: string;
|
||
ffmpeg_pids?: number[];
|
||
log_age_seconds?: number | null;
|
||
is_pushing?: boolean;
|
||
source_title?: string;
|
||
source_room_id?: string;
|
||
source_url?: string;
|
||
source_display?: string;
|
||
source_ambiguous?: boolean;
|
||
source_current?: boolean;
|
||
};
|
||
|
||
function fmtDuration(sec: number): string {
|
||
if (sec < 60) return `${sec}s`;
|
||
const m = Math.floor(sec / 60);
|
||
const s = sec % 60;
|
||
if (m < 60) return `${m}m ${s}s`;
|
||
const h = Math.floor(m / 60);
|
||
const mm = m % 60;
|
||
return `${h}h ${mm}m`;
|
||
}
|
||
|
||
function statusLine(t: TFn, raw: string | undefined): string {
|
||
const s = (raw || "unknown").toLowerCase();
|
||
if (s === "online" || s === "running") return t("运行中(PM2/进程在线)", "Running (process online)");
|
||
if (s === "stopped" || s === "stopping") return t("已停止", "Stopped");
|
||
if (s === "not_found" || s === "errored") return t("未运行或未找到", "Not running / not found");
|
||
if (s === "invalid") return t("无效进程名", "Invalid process");
|
||
return raw || "—";
|
||
}
|
||
|
||
type MonitorRowHint = {
|
||
ffmpeg_active?: boolean;
|
||
ffmpeg_speed?: number | null;
|
||
ffmpeg_frame?: number | null;
|
||
is_pushing?: boolean;
|
||
};
|
||
|
||
type Props = {
|
||
t: TFn;
|
||
currentProc: string;
|
||
fetchJson: <T,>(path: string, init?: RequestInit) => Promise<T>;
|
||
/** 用于源站房间线索(与 Electron 一致) */
|
||
urlListText: string;
|
||
/** YouTube 密钥尾码;非 YouTube 进程可传空并关 showKeyRow */
|
||
keySuffixUi: string;
|
||
showKeyRow?: boolean;
|
||
pollMs?: number;
|
||
refreshToken?: number;
|
||
/** process_monitor 行:补全 light status 缺失的 FFmpeg 指标 */
|
||
monitorRow?: MonitorRowHint;
|
||
};
|
||
|
||
function businessLine(t: TFn, raw: string | undefined, note: string | undefined): string {
|
||
const s = (raw || "").toLowerCase();
|
||
if (s === "streaming") return t("正在推流到 YouTube", "Pushing to YouTube");
|
||
if (s === "relay_slow") return t("推流速度偏低", "Relay running slowly");
|
||
if (s === "waiting_source") return t("等待上游直播源开播", "Waiting for the upstream live source");
|
||
if (s === "source_live")
|
||
return t("源站已开播,转推 Worker 未启动", "Source live detected, but no active FFmpeg relay worker");
|
||
if (s === "monitoring") return t("进程在线,监控源站中", "Process online and monitoring the source");
|
||
if (s === "misconfigured") return t("YouTube 密钥缺失或无效", "YouTube key missing or invalid");
|
||
if (s === "youtube_key_rejected")
|
||
return t(
|
||
"YouTube 推流失败:串流密钥无效、过期或不属于当前直播间",
|
||
"YouTube rejected the stream key",
|
||
);
|
||
if (s === "source_stalled") return t("上游源站卡住", "Upstream source stalled");
|
||
if (s === "stale") return t("进程在线但日志心跳过期", "Process online but the log heartbeat is stale");
|
||
if (s === "error") return t("检测到近期进程错误", "Recent process error detected");
|
||
if (note?.trim()) return note.trim();
|
||
return t("暂无业务状态", "No business-state hint yet");
|
||
}
|
||
|
||
function businessShortLine(t: TFn, raw: string | undefined): string {
|
||
const s = (raw || "").toLowerCase();
|
||
if (s === "streaming") return t("推流中", "Pushing");
|
||
if (s === "relay_slow") return t("低速", "Slow");
|
||
if (s === "waiting_source") return t("等源", "Wait source");
|
||
if (s === "source_live") return t("源开播", "Source live");
|
||
if (s === "monitoring") return t("监控中", "Monitoring");
|
||
if (s === "misconfigured") return t("密钥异常", "Key invalid");
|
||
if (s === "youtube_key_rejected") return t("密钥被拒", "Key rejected");
|
||
if (s === "source_stalled") return t("源卡住", "Stalled");
|
||
if (s === "stale") return t("心跳过期", "Stale");
|
||
if (s === "error") return t("异常", "Error");
|
||
return t("未知", "Unknown");
|
||
}
|
||
|
||
function businessBadgeClass(raw: string | undefined): string {
|
||
const s = (raw || "").trim().toLowerCase();
|
||
if (s === "streaming" || s === "relay_slow") return "bg-emerald-500/15 text-emerald-200 ring-emerald-500/30";
|
||
if (s === "waiting_source" || s === "monitoring" || s === "source_live") {
|
||
return "bg-amber-500/15 text-amber-100 ring-amber-500/25";
|
||
}
|
||
if (s === "misconfigured" || s === "youtube_key_rejected" || s === "error" || s === "stale" || s === "source_stalled") {
|
||
return "bg-rose-500/15 text-rose-100 ring-rose-500/30";
|
||
}
|
||
return "bg-zinc-600/20 text-zinc-300 ring-zinc-500/25";
|
||
}
|
||
|
||
function processBadgeClass(raw: string | undefined): string {
|
||
const s = (raw || "").trim().toLowerCase();
|
||
if (s === "online" || s === "running") return "bg-emerald-500/15 text-emerald-200 ring-emerald-500/30";
|
||
if (s === "stopped" || s === "stopping") return "bg-zinc-600/20 text-zinc-300 ring-zinc-500/25";
|
||
if (s === "not_found" || s === "errored" || s === "error") return "bg-rose-500/15 text-rose-100 ring-rose-500/30";
|
||
return "bg-zinc-600/20 text-zinc-300 ring-zinc-500/25";
|
||
}
|
||
|
||
export function LiveProcessLiveLogCard({
|
||
t,
|
||
currentProc,
|
||
fetchJson,
|
||
urlListText,
|
||
keySuffixUi,
|
||
showKeyRow = true,
|
||
pollMs = 1000,
|
||
refreshToken = 0,
|
||
monitorRow,
|
||
}: Props) {
|
||
const [processStatus, setProcessStatus] = useState<string>("");
|
||
const [recentLog, setRecentLog] = useState("");
|
||
const [recentError, setRecentError] = useState("");
|
||
const [businessStatus, setBusinessStatus] = useState("");
|
||
const [businessNote, setBusinessNote] = useState("");
|
||
const [ffmpegPids, setFfmpegPids] = useState<number[]>([]);
|
||
const [logAgeSeconds, setLogAgeSeconds] = useState<number | null>(null);
|
||
const [sourceTitle, setSourceTitle] = useState("");
|
||
const [sourceRoomId, setSourceRoomId] = useState("");
|
||
const [sourceUrl, setSourceUrl] = useState("");
|
||
const [sourceDisplay, setSourceDisplay] = useState("");
|
||
const [sourceAmbiguous, setSourceAmbiguous] = useState(false);
|
||
const [sourceCurrent, setSourceCurrent] = useState(false);
|
||
const [isPushing, setIsPushing] = useState(false);
|
||
const [paused, setPaused] = useState(false);
|
||
const [liveSince, setLiveSince] = useState<number | null>(null);
|
||
const [nowTick, setNowTick] = useState(0);
|
||
const [pageVisible, setPageVisible] = useState(true);
|
||
const outRef = useRef<HTMLPreElement>(null);
|
||
const errRef = useRef<HTMLPreElement>(null);
|
||
const prevOnlineRef = useRef(false);
|
||
const pullInFlightRef = useRef(false);
|
||
const pullQueuedRef = useRef(false);
|
||
const currentProcRef = useRef(currentProc);
|
||
const requestSeqRef = useRef(0);
|
||
|
||
const douyinHints = extractDouyinRoomHints(urlListText);
|
||
const onlineNow = /^(online|running)$/i.test(processStatus);
|
||
const roomFromLog = extractDouyinCurrentRoomFromLog(recentLog);
|
||
const fallbackUrls = extractDouyinLiveUrls(urlListText);
|
||
const fallbackUrl = fallbackUrls[0] ?? "";
|
||
const pushingNow =
|
||
isPushing ||
|
||
!!monitorRow?.is_pushing ||
|
||
["streaming", "relay_slow"].includes(businessStatus.trim().toLowerCase());
|
||
const monitorSpeed =
|
||
typeof monitorRow?.ffmpeg_speed === "number" ? monitorRow.ffmpeg_speed.toFixed(2) : null;
|
||
const monitorFrame = typeof monitorRow?.ffmpeg_frame === "number" ? String(monitorRow.ffmpeg_frame) : null;
|
||
const ffmpegWorkerLabel = ffmpegPids.length
|
||
? ffmpegPids.join(", ")
|
||
: pushingNow || monitorRow?.ffmpeg_active
|
||
? t("转推活跃(PID 未采集)", "Relay active (PID n/a)")
|
||
: t("无", "none");
|
||
const suppressAmbiguousBackend = sourceAmbiguous && pushingNow && !sourceCurrent;
|
||
const backendRoomId = suppressAmbiguousBackend ? "" : sourceRoomId;
|
||
const backendUrl = suppressAmbiguousBackend ? "" : sourceUrl;
|
||
const suppressAmbiguousFallback =
|
||
fallbackUrls.length > 1 &&
|
||
pushingNow &&
|
||
!backendUrl &&
|
||
!backendRoomId &&
|
||
!roomFromLog &&
|
||
(sourceAmbiguous || !!sourceDisplay || !!sourceTitle);
|
||
const primaryRoomId =
|
||
backendRoomId ||
|
||
roomFromLog ||
|
||
(!suppressAmbiguousFallback ? fallbackUrl.match(/live\.douyin\.com\/([a-zA-Z0-9_-]+)/i)?.[1] ?? null : null);
|
||
const primaryUrl =
|
||
backendUrl ||
|
||
(backendRoomId ? `https://live.douyin.com/${backendRoomId}` : "") ||
|
||
(roomFromLog ? `https://live.douyin.com/${roomFromLog}` : "") ||
|
||
(!suppressAmbiguousFallback ? fallbackUrl || null : null);
|
||
const localSourceLabel = suppressAmbiguousBackend
|
||
? douyinSourceDisplayFrom("", recentLog)
|
||
: douyinSourceDisplayFrom(urlListText, recentLog);
|
||
const primarySourceLabel =
|
||
(suppressAmbiguousBackend ? "" : sourceDisplay) ||
|
||
(suppressAmbiguousBackend ? "" : sourceTitle) ||
|
||
localSourceLabel ||
|
||
(primaryRoomId ? `抖音直播间 ${primaryRoomId}` : "");
|
||
const youtubeKeyRejected = businessStatus.trim().toLowerCase() === "youtube_key_rejected";
|
||
|
||
const pull = useCallback(async () => {
|
||
const targetProc = currentProcRef.current.trim();
|
||
if (!targetProc) return;
|
||
if (pullInFlightRef.current) {
|
||
pullQueuedRef.current = true;
|
||
return;
|
||
}
|
||
pullInFlightRef.current = true;
|
||
const requestId = ++requestSeqRef.current;
|
||
try {
|
||
const data = await fetchJson<StatusPayload>(
|
||
`/status?process=${encodeURIComponent(targetProc)}&light=1`,
|
||
);
|
||
if (requestId !== requestSeqRef.current || targetProc !== currentProcRef.current.trim()) return;
|
||
const ps = data.process_status || "unknown";
|
||
setProcessStatus(ps);
|
||
setRecentLog(data.recent_log || "");
|
||
setRecentError(data.recent_error || "");
|
||
setBusinessStatus(data.business_status || "");
|
||
setBusinessNote(data.business_note || "");
|
||
setFfmpegPids(Array.isArray(data.ffmpeg_pids) ? data.ffmpeg_pids : []);
|
||
setLogAgeSeconds(typeof data.log_age_seconds === "number" ? data.log_age_seconds : null);
|
||
setSourceTitle(data.source_title || "");
|
||
setSourceRoomId(data.source_room_id || "");
|
||
setSourceUrl(data.source_url || "");
|
||
setSourceDisplay(data.source_display || "");
|
||
setSourceAmbiguous(!!data.source_ambiguous);
|
||
setSourceCurrent(!!data.source_current);
|
||
setIsPushing(!!data.is_pushing);
|
||
const online = /^(online|running)$/i.test(ps);
|
||
if (online && !prevOnlineRef.current) {
|
||
setLiveSince(Date.now());
|
||
}
|
||
if (!online) {
|
||
setLiveSince(null);
|
||
}
|
||
prevOnlineRef.current = online;
|
||
} catch {
|
||
if (requestId !== requestSeqRef.current || targetProc !== currentProcRef.current.trim()) return;
|
||
setProcessStatus("error");
|
||
setBusinessStatus("error");
|
||
setBusinessNote("");
|
||
setFfmpegPids([]);
|
||
setLogAgeSeconds(null);
|
||
setSourceTitle("");
|
||
setSourceRoomId("");
|
||
setSourceUrl("");
|
||
setSourceDisplay("");
|
||
setSourceAmbiguous(false);
|
||
setSourceCurrent(false);
|
||
setIsPushing(false);
|
||
} finally {
|
||
pullInFlightRef.current = false;
|
||
if (pullQueuedRef.current) {
|
||
pullQueuedRef.current = false;
|
||
window.setTimeout(() => void pull(), 0);
|
||
}
|
||
}
|
||
}, [fetchJson]);
|
||
|
||
useEffect(() => {
|
||
currentProcRef.current = currentProc;
|
||
requestSeqRef.current += 1;
|
||
pullQueuedRef.current = false;
|
||
if (!currentProc) {
|
||
setProcessStatus("");
|
||
setRecentLog("");
|
||
setRecentError("");
|
||
setBusinessStatus("");
|
||
setBusinessNote("");
|
||
setFfmpegPids([]);
|
||
setLogAgeSeconds(null);
|
||
setSourceTitle("");
|
||
setSourceRoomId("");
|
||
setSourceUrl("");
|
||
setSourceDisplay("");
|
||
setSourceAmbiguous(false);
|
||
setSourceCurrent(false);
|
||
setIsPushing(false);
|
||
setLiveSince(null);
|
||
prevOnlineRef.current = false;
|
||
return;
|
||
}
|
||
setProcessStatus("");
|
||
setRecentLog("");
|
||
setRecentError("");
|
||
setBusinessStatus("");
|
||
setBusinessNote("");
|
||
setFfmpegPids([]);
|
||
setLogAgeSeconds(null);
|
||
setSourceTitle("");
|
||
setSourceRoomId("");
|
||
setSourceUrl("");
|
||
setSourceDisplay("");
|
||
setSourceAmbiguous(false);
|
||
setSourceCurrent(false);
|
||
setIsPushing(false);
|
||
setLiveSince(null);
|
||
prevOnlineRef.current = false;
|
||
void pull();
|
||
}, [currentProc, pull]);
|
||
|
||
useEffect(() => {
|
||
const onVis = () => setPageVisible(document.visibilityState === "visible");
|
||
onVis();
|
||
document.addEventListener("visibilitychange", onVis);
|
||
return () => document.removeEventListener("visibilitychange", onVis);
|
||
}, []);
|
||
|
||
useEffect(() => {
|
||
if (!currentProc) return;
|
||
void pull();
|
||
}, [currentProc, pull, refreshToken]);
|
||
|
||
useEffect(() => {
|
||
if (paused || !currentProc || pollMs <= 0) return;
|
||
const id = window.setInterval(() => void pull(), pollMs);
|
||
return () => clearInterval(id);
|
||
}, [paused, currentProc, pull, pollMs]);
|
||
|
||
useEffect(() => {
|
||
const onVis = () => {
|
||
if (document.visibilityState === "visible") void pull();
|
||
};
|
||
document.addEventListener("visibilitychange", onVis);
|
||
return () => document.removeEventListener("visibilitychange", onVis);
|
||
}, [pull]);
|
||
|
||
useEffect(() => {
|
||
if (!liveSince) return;
|
||
const id = window.setInterval(() => setNowTick((n) => n + 1), 1000);
|
||
return () => clearInterval(id);
|
||
}, [liveSince]);
|
||
|
||
useEffect(() => {
|
||
if (paused || !pageVisible) return;
|
||
const el = outRef.current;
|
||
if (el) el.scrollTop = el.scrollHeight;
|
||
}, [recentLog, paused, pageVisible]);
|
||
|
||
useEffect(() => {
|
||
if (paused || !pageVisible) return;
|
||
const el = errRef.current;
|
||
if (el) el.scrollTop = el.scrollHeight;
|
||
}, [recentError, paused, pageVisible]);
|
||
|
||
const durationLabel =
|
||
liveSince == null
|
||
? t("—(未检测到在线)", "— (not online)")
|
||
: fmtDuration(Math.max(0, Math.floor((Date.now() - liveSince) / 1000)));
|
||
const refreshBadgeLabel = paused
|
||
? t("已暂停刷新", "Paused")
|
||
: formatPollBadge(pollMs, t);
|
||
const refreshBadgeClass = paused
|
||
? "bg-amber-500/20 text-amber-100 ring-amber-500/35"
|
||
: pollMs >= 30_000
|
||
? "bg-sky-500/15 text-sky-100 ring-sky-500/25"
|
||
: pollMs >= 4000
|
||
? "bg-zinc-500/15 text-zinc-200/90 ring-zinc-500/25"
|
||
: "bg-emerald-500/15 text-emerald-200/90 ring-emerald-500/25";
|
||
|
||
return (
|
||
<section className="rounded-2xl border border-emerald-500/20 bg-gradient-to-b from-emerald-500/[0.07] to-zinc-950/80 p-6 ring-1 ring-white/[0.04]">
|
||
<span className="sr-only" aria-hidden>
|
||
{nowTick}
|
||
</span>
|
||
<div className="flex flex-wrap items-center justify-between gap-3">
|
||
<div className="flex flex-wrap items-center gap-2">
|
||
<h3 className="text-sm font-semibold text-white">{t("当前直播日志", "Live process log")}</h3>
|
||
{pushingNow ? (
|
||
<span className="inline-flex items-center gap-1.5 rounded-full bg-emerald-500/15 px-2.5 py-0.5 text-[10px] font-medium text-emerald-100 ring-1 ring-emerald-500/25">
|
||
<span className="relative flex h-2 w-2">
|
||
<span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-70" />
|
||
<span className="relative inline-flex h-2 w-2 rounded-full bg-emerald-400" />
|
||
</span>
|
||
{t("推流中", "Pushing")}
|
||
</span>
|
||
) : null}
|
||
<span className="rounded-full bg-white/10 px-2 py-0.5 font-mono text-[10px] text-zinc-300 ring-1 ring-white/10">
|
||
{currentProc || "—"}
|
||
</span>
|
||
<span className={`rounded-full px-2 py-0.5 text-[10px] font-medium ring-1 ${refreshBadgeClass}`}>
|
||
{refreshBadgeLabel}
|
||
</span>
|
||
</div>
|
||
<div className="flex flex-wrap gap-2">
|
||
<button
|
||
type="button"
|
||
onClick={() => void pull()}
|
||
className="inline-flex items-center gap-1 rounded-lg border border-white/10 bg-white/[0.05] px-3 py-1.5 text-xs text-zinc-300 hover:bg-white/[0.08]"
|
||
>
|
||
<RefreshCw className="h-3.5 w-3.5" />
|
||
{t("立即拉取", "Refresh")}
|
||
</button>
|
||
<button
|
||
type="button"
|
||
onClick={() => setPaused((p) => !p)}
|
||
className={`inline-flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs ring-1 ${
|
||
paused
|
||
? "bg-amber-500/20 text-amber-100 ring-amber-500/35"
|
||
: "border border-white/10 bg-black/30 text-zinc-300"
|
||
}`}
|
||
>
|
||
{paused ? <Play className="h-3.5 w-3.5" /> : <Pause className="h-3.5 w-3.5" />}
|
||
{paused ? t("继续自动刷新", "Resume") : t("暂停自动刷新", "Pause")}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div className="mt-4 space-y-3 rounded-xl border border-white/[0.06] bg-black/25 p-4">
|
||
<div className="grid gap-3 sm:grid-cols-2 xl:grid-cols-4">
|
||
<div className="rounded-lg border border-white/[0.05] bg-black/20 p-3">
|
||
<p className="text-[11px] text-zinc-500">{t("进程状态", "Process")}</p>
|
||
<span className={`mt-2 inline-flex rounded-full px-2.5 py-0.5 text-[11px] font-medium ring-1 ${processBadgeClass(processStatus)}`}>
|
||
{statusLine(t, processStatus)}
|
||
</span>
|
||
</div>
|
||
<div className="rounded-lg border border-white/[0.05] bg-black/20 p-3">
|
||
<p className="text-[11px] text-zinc-500">{t("业务状态", "Business")}</p>
|
||
<span
|
||
className={`mt-2 inline-flex max-w-full rounded-full px-2.5 py-0.5 text-[11px] font-medium ring-1 ${businessBadgeClass(businessStatus)}`}
|
||
title={businessLine(t, businessStatus, businessNote)}
|
||
>
|
||
{businessShortLine(t, businessStatus)}
|
||
</span>
|
||
</div>
|
||
<div className="rounded-lg border border-white/[0.05] bg-black/20 p-3">
|
||
<p className="text-[11px] text-zinc-500">{t("本次在线时长(估算)", "Online duration (est.)")}</p>
|
||
<p className="mt-2 font-mono text-sm font-semibold text-cyan-200/90">{durationLabel}</p>
|
||
</div>
|
||
<div className="rounded-lg border border-white/[0.05] bg-black/20 p-3">
|
||
<p className="text-[11px] text-zinc-500">{t("FFmpeg workers", "FFmpeg workers")}</p>
|
||
<p className="mt-2 font-mono text-sm text-zinc-200">{ffmpegWorkerLabel}</p>
|
||
{monitorSpeed || monitorFrame ? (
|
||
<p className="mt-1 font-mono text-[10px] text-zinc-500">
|
||
{monitorSpeed ? `speed ${monitorSpeed}x` : ""}
|
||
{monitorSpeed && monitorFrame ? " · " : ""}
|
||
{monitorFrame ? `frame ${monitorFrame}` : ""}
|
||
</p>
|
||
) : null}
|
||
{logAgeSeconds != null ? (
|
||
<p className="mt-1 text-[10px] text-zinc-600">
|
||
{t("日志心跳", "Log heartbeat")} {fmtDuration(Math.max(0, Math.floor(logAgeSeconds)))}
|
||
</p>
|
||
) : null}
|
||
</div>
|
||
</div>
|
||
{primarySourceLabel ? (
|
||
<div className="rounded-lg border border-white/[0.05] bg-black/20 px-3 py-2.5">
|
||
<p className="text-[11px] text-zinc-500">{t("当前转播源", "Current relay source")}</p>
|
||
<p className="mt-1 text-sm font-medium text-zinc-200">{primarySourceLabel}</p>
|
||
</div>
|
||
) : null}
|
||
{showKeyRow ? (
|
||
<div className="flex flex-wrap gap-2 text-xs">
|
||
<span className="text-zinc-500">{t("YouTube key 尾码(参考)", "YT key suffix")}</span>
|
||
<span className="font-mono text-zinc-300">{keySuffixUi || "—"}</span>
|
||
</div>
|
||
) : null}
|
||
{youtubeKeyRejected ? (
|
||
<div className="rounded-lg border border-rose-500/30 bg-rose-500/[0.10] px-3 py-2.5 text-xs text-rose-100 ring-1 ring-rose-500/15">
|
||
<div className="flex gap-2">
|
||
<AlertTriangle className="mt-0.5 h-4 w-4 shrink-0 text-rose-300" aria-hidden />
|
||
<p>
|
||
{t(
|
||
"YouTube 已拒绝本次 RTMPS 推流。请从 YouTube Studio 当前直播间复制完整串流密钥,保存到当前线路后重新开始;如果密钥确认无误,再检查到 YouTube RTMPS 的网络/代理。",
|
||
"YouTube rejected this RTMPS publish. Copy the full stream key for the current live event from YouTube Studio, save it to this lane, then start again; if the key is correct, check network/proxy access to YouTube RTMPS.",
|
||
)}
|
||
</p>
|
||
</div>
|
||
</div>
|
||
) : null}
|
||
{primaryUrl ? (
|
||
<div className="rounded-lg border border-violet-500/20 bg-violet-500/[0.06] px-3 py-2.5">
|
||
<div className="flex flex-wrap items-center justify-between gap-2">
|
||
<span className="text-[11px] font-medium text-zinc-400">
|
||
{roomFromLog
|
||
? t("当前直播源站(日志)", "Current source (from log)")
|
||
: onlineNow
|
||
? t("配置中的源站地址", "Configured source URL")
|
||
: t("源站快捷入口", "Source quick link")}
|
||
</span>
|
||
<a
|
||
href={primaryUrl}
|
||
target="_blank"
|
||
rel="noreferrer"
|
||
className="inline-flex items-center gap-1.5 rounded-lg bg-violet-500/20 px-3 py-1.5 text-xs font-medium text-violet-100 ring-1 ring-violet-500/35 transition hover:bg-violet-500/30"
|
||
>
|
||
<ExternalLink className="h-3.5 w-3.5 shrink-0 opacity-90" />
|
||
{primarySourceLabel || t("打开抖音直播页", "Open Douyin live")}
|
||
</a>
|
||
</div>
|
||
{primaryRoomId && primarySourceLabel && !primarySourceLabel.includes(primaryRoomId) ? (
|
||
<p className="mt-2 font-mono text-[10px] text-zinc-600">room:{primaryRoomId}</p>
|
||
) : null}
|
||
{douyinHints.length > 1 && roomFromLog ? (
|
||
<p className="mt-2 text-[10px] text-zinc-600">
|
||
{t("配置中还有", "Also in config:")}{" "}
|
||
{douyinHints
|
||
.filter((id) => id !== primaryRoomId)
|
||
.slice(0, 3)
|
||
.map((id) => (
|
||
<a
|
||
key={id}
|
||
href={`https://live.douyin.com/${id}`}
|
||
target="_blank"
|
||
rel="noreferrer"
|
||
className="ml-1 text-violet-400/90 underline-offset-2 hover:underline"
|
||
>
|
||
{id}
|
||
</a>
|
||
))}
|
||
{douyinHints.length > 4 ? "…" : null}
|
||
</p>
|
||
) : null}
|
||
</div>
|
||
) : (
|
||
<p className="text-[11px] text-zinc-600">
|
||
{t("(日志与地址列表中暂无抖音房间)", "(No Douyin room in log or URL list)")}
|
||
</p>
|
||
)}
|
||
</div>
|
||
|
||
{processStatus !== "not_found" && processStatus !== "invalid" ? (
|
||
<div className="mt-4 grid gap-4 lg:grid-cols-2">
|
||
<div>
|
||
<div className="text-[11px] font-semibold uppercase tracking-wider text-emerald-400/90">
|
||
{t("进程输出(stdout / 合并日志)", "Process output")}
|
||
</div>
|
||
<pre
|
||
ref={outRef}
|
||
className="log-live-scroll mt-2 max-h-[min(22rem,42vh)] min-h-[12rem] overflow-auto whitespace-pre-wrap rounded-xl border border-emerald-500/20 bg-black/55 p-3 font-mono text-[10px] leading-relaxed text-emerald-100/95"
|
||
>
|
||
{recentLog.trim() || t("(暂无)", "(empty)")}
|
||
</pre>
|
||
</div>
|
||
<div>
|
||
<div className="text-[11px] font-semibold uppercase tracking-wider text-rose-400/90">
|
||
{t("异常信息(stderr)", "Stderr")}
|
||
</div>
|
||
<pre
|
||
ref={errRef}
|
||
className="log-live-scroll mt-2 max-h-[min(22rem,42vh)] min-h-[12rem] overflow-auto whitespace-pre-wrap rounded-xl border border-rose-500/20 bg-black/55 p-3 font-mono text-[10px] leading-relaxed text-rose-100/95"
|
||
>
|
||
{recentError.trim() || t("(暂无)", "(empty)")}
|
||
</pre>
|
||
</div>
|
||
</div>
|
||
) : (
|
||
<p className="mt-4 text-xs text-zinc-500">
|
||
{t("进程未在 PM2 / 本地注册表中运行,日志区域已隐藏。", "Process not running — log panes hidden.")}
|
||
</p>
|
||
)}
|
||
</section>
|
||
);
|
||
}
|