's'
This commit is contained in:
203
web-console/components/live-product/LiveTiktokHdmiView.tsx
Normal file
203
web-console/components/live-product/LiveTiktokHdmiView.tsx
Normal file
@@ -0,0 +1,203 @@
|
||||
"use client";
|
||||
|
||||
import { Cable, Copy, Monitor } from "lucide-react";
|
||||
import { useMemo, useState } from "react";
|
||||
|
||||
type ProcessEntry = { pm2: string; script: string; label: string };
|
||||
|
||||
type TFn = (zh: string, en: string) => string;
|
||||
|
||||
function isTiktokProcess(e: ProcessEntry) {
|
||||
return /tiktok/i.test(e.script) || /tiktok/i.test(e.pm2);
|
||||
}
|
||||
|
||||
type HdmiPreset = { id: string; labelZh: string; labelEn: string; spec: string; hintZh: string; hintEn: string };
|
||||
|
||||
const PRESETS: HdmiPreset[] = [
|
||||
{
|
||||
id: "720p60",
|
||||
labelZh: "720p @ 60Hz",
|
||||
labelEn: "720p @ 60Hz",
|
||||
spec: "1280x720, 59.94/60Hz, RGB/YUV 有限",
|
||||
hintZh: "板端 HDMI 输出与采集卡 EDID 对齐;OBS 画布 1280×720。",
|
||||
hintEn: "Match SoC HDMI timing to capture card EDID; OBS 1280×720.",
|
||||
},
|
||||
{
|
||||
id: "1080p30",
|
||||
labelZh: "1080p @ 30Hz",
|
||||
labelEn: "1080p @ 30Hz",
|
||||
spec: "1920x1080, 30Hz, 适合 USB 采集带宽紧张场景",
|
||||
hintZh: "USB3 采集常更稳;检查线缆长度与屏蔽。",
|
||||
hintEn: "Often more stable on USB3 capture; check cable quality.",
|
||||
},
|
||||
{
|
||||
id: "1080p60",
|
||||
labelZh: "1080p @ 60Hz",
|
||||
labelEn: "1080p @ 60Hz",
|
||||
spec: "1920x1080, 60Hz, 高刷转播",
|
||||
hintZh: "需确认采集卡与 SoC 同时支持 1080p60;过热会掉帧。",
|
||||
hintEn: "Requires 1080p60 on both ends; thermal throttling may drop frames.",
|
||||
},
|
||||
];
|
||||
|
||||
type Props = {
|
||||
t: TFn;
|
||||
busy: boolean;
|
||||
entries: ProcessEntry[];
|
||||
currentProc: string;
|
||||
setCurrentProc: (v: string) => void;
|
||||
urlConfig: string;
|
||||
setUrlConfig: (v: string) => void;
|
||||
douyinUrl: string;
|
||||
setDouyinUrl: (v: string) => void;
|
||||
onRunProcess: (a: "start" | "stop" | "restart") => void;
|
||||
onSaveUrlConfig: (content?: string) => void;
|
||||
onSaveBusinessMeta: () => void;
|
||||
onCopy: (text: string) => void;
|
||||
};
|
||||
|
||||
export function LiveTiktokHdmiView({
|
||||
t,
|
||||
busy,
|
||||
entries,
|
||||
currentProc,
|
||||
setCurrentProc,
|
||||
urlConfig,
|
||||
setUrlConfig,
|
||||
douyinUrl,
|
||||
setDouyinUrl,
|
||||
onRunProcess,
|
||||
onSaveUrlConfig,
|
||||
onSaveBusinessMeta,
|
||||
onCopy,
|
||||
}: Props) {
|
||||
const tkEntries = useMemo(() => entries.filter(isTiktokProcess), [entries]);
|
||||
const [expanded, setExpanded] = useState<string | null>("1080p30");
|
||||
|
||||
return (
|
||||
<div className="mx-auto max-w-4xl space-y-6">
|
||||
<div className="rounded-2xl border border-cyan-500/20 bg-gradient-to-br from-cyan-500/10 via-transparent to-violet-500/5 p-6">
|
||||
<div className="flex items-center gap-2">
|
||||
<Cable className="h-5 w-5 text-cyan-300" />
|
||||
<h2 className="text-base font-semibold text-white">{t("TikTok 无人直播 · HDMI", "TikTok unmanned · HDMI")}</h2>
|
||||
</div>
|
||||
<p className="mt-2 text-xs text-zinc-500">
|
||||
{t(
|
||||
"TikTok 无多频道概念:单路转播到 HDMI。下列为常见时序与排障要点,便于你在板子与采集侧做兼容测试。",
|
||||
"Single-path HDMI relay; presets for timing compatibility tests.",
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-3 md:grid-cols-3">
|
||||
{PRESETS.map((p) => {
|
||||
const open = expanded === p.id;
|
||||
return (
|
||||
<button
|
||||
key={p.id}
|
||||
type="button"
|
||||
onClick={() => setExpanded(open ? null : p.id)}
|
||||
className={`rounded-2xl border p-4 text-left transition ${
|
||||
open ? "border-cyan-500/40 bg-cyan-500/10" : "border-white/[0.08] bg-zinc-950/50 hover:border-white/15"
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-center gap-2 text-sm font-semibold text-white">
|
||||
<Monitor className="h-4 w-4 text-cyan-400" />
|
||||
{t(p.labelZh, p.labelEn)}
|
||||
</div>
|
||||
<p className="mt-2 font-mono text-[11px] text-zinc-400">{p.spec}</p>
|
||||
{open ? <p className="mt-2 text-xs text-zinc-500">{t(p.hintZh, p.hintEn)}</p> : null}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
<div className="rounded-2xl border border-white/[0.08] bg-zinc-950/50 p-6">
|
||||
<label className="text-xs font-semibold uppercase tracking-wider text-zinc-500">{t("TikTok 进程", "TikTok process")}</label>
|
||||
<select
|
||||
className="mt-2 w-full rounded-xl border border-white/10 bg-black/40 px-4 py-3 text-sm text-white"
|
||||
value={currentProc}
|
||||
onChange={(e) => setCurrentProc(e.target.value)}
|
||||
>
|
||||
{(tkEntries.length ? tkEntries : entries).map((e) => (
|
||||
<option key={e.pm2} value={e.pm2}>
|
||||
{e.label} ({e.pm2})
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="mt-4 flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
disabled={!!busy}
|
||||
onClick={() => onRunProcess("start")}
|
||||
className="rounded-xl bg-emerald-500/20 px-4 py-2 text-sm font-medium text-emerald-200 ring-1 ring-emerald-500/30"
|
||||
>
|
||||
{t("启动", "Start")}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
disabled={!!busy}
|
||||
onClick={() => onRunProcess("restart")}
|
||||
className="rounded-xl bg-amber-500/15 px-4 py-2 text-sm font-medium text-amber-200 ring-1 ring-amber-500/25"
|
||||
>
|
||||
{t("重启", "Restart")}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
disabled={!!busy}
|
||||
onClick={() => onRunProcess("stop")}
|
||||
className="rounded-xl bg-rose-500/15 px-4 py-2 text-sm font-medium text-rose-200 ring-1 ring-rose-500/25"
|
||||
>
|
||||
{t("停止", "Stop")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="rounded-2xl border border-white/[0.08] bg-zinc-950/50 p-6">
|
||||
<h3 className="text-sm font-semibold text-white">{t("拉流地址(业务元数据)", "Source URL (hub)")}</h3>
|
||||
<input
|
||||
className="mt-4 w-full rounded-xl border border-white/10 bg-black/40 px-4 py-3 text-sm"
|
||||
value={douyinUrl}
|
||||
onChange={(e) => setDouyinUrl(e.target.value)}
|
||||
placeholder="https://live.douyin.com/..."
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
disabled={!!busy}
|
||||
onClick={() => onSaveBusinessMeta()}
|
||||
className="mt-3 rounded-xl bg-violet-500/25 px-4 py-2 text-sm font-medium text-violet-100 ring-1 ring-violet-500/35"
|
||||
>
|
||||
{t("保存", "Save")}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="rounded-2xl border border-white/[0.08] bg-zinc-950/50 p-6">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<h3 className="text-sm font-semibold text-white">URL_config.ini</h3>
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex items-center gap-1 text-xs text-cyan-300 hover:text-cyan-200"
|
||||
onClick={() => onCopy(urlConfig)}
|
||||
>
|
||||
<Copy className="h-3.5 w-3.5" />
|
||||
{t("复制全文", "Copy all")}
|
||||
</button>
|
||||
</div>
|
||||
<textarea
|
||||
className="mt-4 h-40 w-full resize-y rounded-xl border border-white/10 bg-black/50 p-4 font-mono text-xs text-zinc-300"
|
||||
value={urlConfig}
|
||||
onChange={(e) => setUrlConfig(e.target.value)}
|
||||
spellCheck={false}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
disabled={!!busy}
|
||||
onClick={() => onSaveUrlConfig()}
|
||||
className="mt-3 rounded-xl bg-cyan-500/20 px-4 py-2 text-sm font-medium text-cyan-100 ring-1 ring-cyan-500/30"
|
||||
>
|
||||
{t("保存 URL 配置", "Save URL config")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user