's'
This commit is contained in:
@@ -175,9 +175,6 @@ export default function LiveControlApp() {
|
||||
const [entries, setEntries] = useState<ProcessEntry[]>([]);
|
||||
const [currentProc, setCurrentProc] = useState("");
|
||||
const [urlConfig, setUrlConfig] = useState("");
|
||||
const [douyinUrl, setDouyinUrl] = useState("");
|
||||
const [businessYoutubeKey, setBusinessYoutubeKey] = useState("");
|
||||
const [syncYoutubeIni, setSyncYoutubeIni] = useState(false);
|
||||
const [apkPath, setApkPath] = useState("/sdcard/app.apk");
|
||||
const [androidSerial, setAndroidSerial] = useState("");
|
||||
const [hubCfgSnapshot, setHubCfgSnapshot] = useState<Record<string, unknown> | null>(null);
|
||||
@@ -267,22 +264,6 @@ export default function LiveControlApp() {
|
||||
})();
|
||||
}, [currentProc, fetchJson, view]);
|
||||
|
||||
useEffect(() => {
|
||||
void (async () => {
|
||||
try {
|
||||
const b = await fetchJson<{
|
||||
streams?: { douyin_input_url?: string; youtube_rtmp_key?: string };
|
||||
}>("/hub/business/douyinyoutube");
|
||||
const u = b.streams?.douyin_input_url;
|
||||
if (u) setDouyinUrl(u);
|
||||
const k = b.streams?.youtube_rtmp_key;
|
||||
if (k !== undefined && k !== null) setBusinessYoutubeKey(k);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
})();
|
||||
}, [fetchJson]);
|
||||
|
||||
useEffect(() => {
|
||||
if (view !== "settings") return;
|
||||
void (async () => {
|
||||
@@ -331,15 +312,16 @@ export default function LiveControlApp() {
|
||||
}
|
||||
};
|
||||
|
||||
const runProcess = async (action: "start" | "stop" | "restart") => {
|
||||
if (!currentProc) return;
|
||||
const runProcess = async (action: "start" | "stop" | "restart", processOverride?: string) => {
|
||||
const proc = (processOverride ?? currentProc).trim();
|
||||
if (!proc) return;
|
||||
setBusy(`proc:${action}`);
|
||||
try {
|
||||
const path = `/${action}`;
|
||||
const data = await fetchJson<{ output?: string; message?: string }>(path, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ process: currentProc }),
|
||||
body: JSON.stringify({ process: proc }),
|
||||
});
|
||||
notify(String(data.output || data.message || "OK"));
|
||||
await refreshDashboard();
|
||||
@@ -364,33 +346,7 @@ export default function LiveControlApp() {
|
||||
notify(t("URL 配置已保存", "URL config saved"));
|
||||
} catch (e) {
|
||||
notify((e as Error).message);
|
||||
} finally {
|
||||
setBusy(null);
|
||||
}
|
||||
};
|
||||
|
||||
const saveBusinessMeta = async () => {
|
||||
setBusy("save:meta");
|
||||
try {
|
||||
const data = await fetchJson<{ message?: string }>("/hub/business/douyinyoutube", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
streams: {
|
||||
douyin_input_url: douyinUrl,
|
||||
youtube_rtmp_key: businessYoutubeKey,
|
||||
},
|
||||
sync_youtube_ini: syncYoutubeIni,
|
||||
}),
|
||||
});
|
||||
const detail = (data.message || "").trim();
|
||||
notify(
|
||||
detail.length > 0 && detail.length < 280
|
||||
? detail
|
||||
: t("业务元数据已同步", "Business metadata saved"),
|
||||
);
|
||||
} catch (e) {
|
||||
notify((e as Error).message);
|
||||
throw e;
|
||||
} finally {
|
||||
setBusy(null);
|
||||
}
|
||||
@@ -1119,15 +1075,8 @@ export default function LiveControlApp() {
|
||||
setCurrentProc={setCurrentProc}
|
||||
urlConfig={urlConfig}
|
||||
setUrlConfig={setUrlConfig}
|
||||
douyinUrl={douyinUrl}
|
||||
setDouyinUrl={setDouyinUrl}
|
||||
businessYoutubeKey={businessYoutubeKey}
|
||||
setBusinessYoutubeKey={setBusinessYoutubeKey}
|
||||
syncYoutubeIni={syncYoutubeIni}
|
||||
setSyncYoutubeIni={setSyncYoutubeIni}
|
||||
onRunProcess={(a) => void runProcess(a)}
|
||||
onSaveUrlConfig={(c) => void saveUrlConfig(c)}
|
||||
onSaveBusinessMeta={() => void saveBusinessMeta()}
|
||||
onRunProcess={(a, pm) => void runProcess(a, pm)}
|
||||
onSaveUrlConfig={(c) => saveUrlConfig(c)}
|
||||
fetchJson={fetchJson}
|
||||
/>
|
||||
) : null}
|
||||
@@ -1141,15 +1090,8 @@ export default function LiveControlApp() {
|
||||
setCurrentProc={setCurrentProc}
|
||||
urlConfig={urlConfig}
|
||||
setUrlConfig={setUrlConfig}
|
||||
douyinUrl={douyinUrl}
|
||||
setDouyinUrl={setDouyinUrl}
|
||||
businessYoutubeKey={businessYoutubeKey}
|
||||
setBusinessYoutubeKey={setBusinessYoutubeKey}
|
||||
syncYoutubeIni={syncYoutubeIni}
|
||||
setSyncYoutubeIni={setSyncYoutubeIni}
|
||||
onRunProcess={(a) => void runProcess(a)}
|
||||
onSaveUrlConfig={(c) => void saveUrlConfig(c)}
|
||||
onSaveBusinessMeta={() => void saveBusinessMeta()}
|
||||
onSaveUrlConfig={(c) => saveUrlConfig(c)}
|
||||
onCopy={copyText}
|
||||
fetchJson={fetchJson}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user