From ed0ba51647dd859e7b1480950d43f41d4e65c7d3 Mon Sep 17 00:00:00 2001 From: zhoulexin <544279058@qq.com> Date: Wed, 1 Jul 2026 17:14:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 3 ++- src/components/WebRtcPlayer.vue | 3 +-- src/utils/fileHttp.js | 4 ++-- src/views/home/components/VideoPlayer.vue | 1 - src/views/home/index.vue | 6 +++--- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.env.development b/.env.development index 0ac8670..55fe65f 100644 --- a/.env.development +++ b/.env.development @@ -2,7 +2,8 @@ VITE_APP_TITLE = 'SOP作业检测系统' # 后端接口地址 -VITE_API_BASE_URL = 'http://10.23.22.43:8188/api' +VITE_API_BASE_IP = '127.0.0.1' +VITE_API_BASE_URL = 'http://${VITE_API_BASE_IP}:8188/api' # 请求超时时间(毫秒) VITE_API_TIMEOUT = 15000 diff --git a/src/components/WebRtcPlayer.vue b/src/components/WebRtcPlayer.vue index 08d684e..2a6d6ff 100644 --- a/src/components/WebRtcPlayer.vue +++ b/src/components/WebRtcPlayer.vue @@ -23,7 +23,6 @@ import { ref, onMounted, onUnmounted, watch } from 'vue' const props = defineProps({ src: { type: String, required: true } }) - const emit = defineEmits(['connection-status']) const videoRef = ref(null) @@ -158,7 +157,7 @@ async function connect() { if (!res.ok) { const errBody = await res.text().catch(() => '') - const isNotPublishing = errBody.includes('no one is publishing') + const isNotPublishing = errBody.includes('no one is publishing') || errBody.includes('no stream is available') if (isNotPublishing) throw new Error('NOT_PUBLISHING') throw new Error(errBody || `HTTP ${res.status}`) } diff --git a/src/utils/fileHttp.js b/src/utils/fileHttp.js index 30007b7..645931e 100644 --- a/src/utils/fileHttp.js +++ b/src/utils/fileHttp.js @@ -1,4 +1,4 @@ -const fileHttp = { - ptApi: '10.23.22.43:8001' +const fileHttp = { + ptApi: `${import.meta.env.VITE_API_BASE_IP}:8001` } export default fileHttp \ No newline at end of file diff --git a/src/views/home/components/VideoPlayer.vue b/src/views/home/components/VideoPlayer.vue index 1130136..588c82b 100644 --- a/src/views/home/components/VideoPlayer.vue +++ b/src/views/home/components/VideoPlayer.vue @@ -33,7 +33,6 @@ const props = defineProps({ offlineVideoUrl: String, videoAutoplayTrigger: Number }) - defineEmits(['connectionChange']) const offlineVideoRef = ref(null) diff --git a/src/views/home/index.vue b/src/views/home/index.vue index edaed98..7ab4854 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -92,12 +92,12 @@ import { downloadAsZip } from '@/utils/zip.js' // ============ 视频流相关 ============ const videoMode = ref('idle') -const streamAddress = ref('rtsp://10.23.22.97:8556/camera2') +const streamAddress = ref('rtsp://127.0.0.1:8556/camera2') const webrtcUrl = ref('') const streamRunning = ref(false) const isLiveMode = computed(() => videoMode.value === 'live') -const RAW_WS_URL = 'ws://10.23.22.43:8001/ws/raw_rtsp' -const DETECT_WS_URL = 'ws://10.23.22.43:8001/ws/detect_rtsp' +const RAW_WS_URL = `ws://${fileHttp.ptApi}/ws/raw_rtsp` +const DETECT_WS_URL = `ws://${fileHttp.ptApi}/ws/detect_rtsp` let rawWsClient = null let detectWsClient = null