From 0494590f304938fa89b041a4f210a7f035e3dea8 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 8 Sep 2025 12:32:17 +0800 Subject: [PATCH] 's' --- frontend/package.json | 2 +- frontend/src/components/files/ListingItem.vue | 38 +++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 680232c..ec8c9ba 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -8,7 +8,7 @@ "pnpm": ">=9.0.0" }, "scripts": { - "dev": "vite dev", + "dev": "vite dev --host 0.0.0.0", "build": "pnpm run typecheck && vite build", "clean": "find ./dist -maxdepth 1 -mindepth 1 ! -name '.gitkeep' -exec rm -r {} +", "typecheck": "vue-tsc -p ./tsconfig.tsc.json --noEmit", diff --git a/frontend/src/components/files/ListingItem.vue b/frontend/src/components/files/ListingItem.vue index 2260687..db408ab 100644 --- a/frontend/src/components/files/ListingItem.vue +++ b/frontend/src/components/files/ListingItem.vue @@ -24,10 +24,10 @@ - - @@ -386,7 +386,7 @@ const stopLive = async () => { const thread_id = props.url.replace(/\//g, "_"); // 调用 FastAPI 停止接口 - const res = await fetch("http://live.local:8700/stop_live", { + const res = await fetch("http://192.168.31.103:8700/stop_live", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ thread_id }) // 如果想停止全部可以 body: {} @@ -414,7 +414,7 @@ const loopLive = async () => { console.log('file_path',file_path) // 调用 FastAPI 后端接口 - const res = await fetch("http://live.local:8700/loop_Live", { + const res = await fetch("http://192.168.31.103:8700/loop_Live", { // const res = await fetch("http://192.168.31.245:8700/start_live", { method: "POST", @@ -436,8 +436,33 @@ const loopLive = async () => { }; const obsLive = async () => { + try { + // props.url 是 FileBrowser 内部路径,例如 /videos/test.mp4 + const file_path = props.url; + // const file_path = encodeURIComponent(props.url); + console.log('file_path for OBS:', file_path); + + // 这里模拟 OBS 推流逻辑,你可以根据实际后端接口来调整 + const res = await fetch("http://192.168.31.103:8700/obs_live", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ filename: file_path }) + }); + + const data = await res.json(); + + if (data.status === "ok") { + alert(`OBS 推流已启动: ${file_path}`); + } else { + alert(`OBS 推流失败: ${data.msg}`); + } + } catch (err) { + console.error(err); + alert("OBS 推流接口调用失败,请检查后端服务是否启动"); + } }; + const startLive = async () => { try { // props.url 是 FileBrowser 内部路径,例如 /videos/test.mp4 @@ -446,7 +471,7 @@ const startLive = async () => { console.log('file_path',file_path) // 调用 FastAPI 后端接口 - const res = await fetch("http://live.local:8700/start_live", { + const res = await fetch("http://192.168.31.103:8700/start_live", { // const res = await fetch("http://192.168.31.245:8700/start_live", { method: "POST", @@ -466,7 +491,6 @@ const startLive = async () => { alert("直播接口调用失败,请检查后端服务是否启动"); } }; -