This commit is contained in:
root
2026-05-17 07:16:36 +00:00
parent 71ea4da318
commit a10ffe332d
17 changed files with 178 additions and 99 deletions

View File

@@ -224,6 +224,8 @@ export default function LiveControlApp() {
const [showStreamProbes, setShowStreamProbes] = useState(true);
const dashboardInFlightRef = useRef<Promise<void> | null>(null);
const processMonitorInFlightRef = useRef<Promise<void> | null>(null);
const currentProcRef = useRef(currentProc);
const urlConfigRequestSeqRef = useRef(0);
const t = useCallback((zh: string, en: string) => tr(lang, zh, en), [lang]);
@@ -345,13 +347,20 @@ export default function LiveControlApp() {
return () => clearInterval(id);
}, [autoRefreshEnabled, refreshProcessMonitor, view]);
useEffect(() => {
currentProcRef.current = currentProc;
}, [currentProc]);
useEffect(() => {
if (!currentProc || view !== "live_youtube") return;
void (async () => {
const targetProc = currentProcRef.current.trim();
const requestId = ++urlConfigRequestSeqRef.current;
try {
const data = await fetchJson<{ content?: string }>(
`/get_url_config?process=${encodeURIComponent(currentProc)}`,
`/get_url_config?process=${encodeURIComponent(targetProc)}`,
);
if (requestId !== urlConfigRequestSeqRef.current || targetProc !== currentProcRef.current.trim()) return;
setUrlConfig(data.content || "");
} catch {
/* 保留当前草稿,避免临时读取失败把编辑器清空 */