diff --git a/public/config/config.json b/public/config/config.json index 55d823b..bcfef2d 100644 --- a/public/config/config.json +++ b/public/config/config.json @@ -1,4 +1,5 @@ { + "update": "2025-05-27", "title": "智能一体机管理系统", "baseUrl": "http://192.168.10.236:9000", "playerType": "get", diff --git a/public/config/config.json b/public/config/config.json index 55d823b..bcfef2d 100644 --- a/public/config/config.json +++ b/public/config/config.json @@ -1,4 +1,5 @@ { + "update": "2025-05-27", "title": "智能一体机管理系统", "baseUrl": "http://192.168.10.236:9000", "playerType": "get", diff --git a/src/views/page/device/components/addDialog.vue b/src/views/page/device/components/addDialog.vue index e47072e..e595f24 100644 --- a/src/views/page/device/components/addDialog.vue +++ b/src/views/page/device/components/addDialog.vue @@ -56,6 +56,7 @@ const drawHeight = ref(240) const showDraw = ref(true) const webRtcServer = ref(null) +const loadingPonit = ref(true) // 初始化对话框 const initDialog = (row: any, dialogStatusValue: string) => { dialogStatus.value = dialogStatusValue @@ -110,6 +111,7 @@ }) } else if (dataForm.value.mode === '2') { + loadingPonit.value = true getSceneRelations({ id: row.id }).then(res => { if (res.data.range_points) { areaRef.value.setPonits(res.data.range_points) @@ -117,6 +119,7 @@ else { areaRef.value.setPonits() } + loadingPonit.value = false }) playerVideo() } @@ -172,6 +175,12 @@ emits('refresh') resetForm() cancel() + // if (webRtcServer.value) { + console.log('销毁视频') + webRtcServer.value?.disconnect() + webRtcServer.value = null + showVideo.value = false + // } } (dialogStatus.value === 'update' ? updateDevice : addDevice)(dataForm.value).then((res) => { // 算法 @@ -264,28 +273,38 @@ webRtcServer.value.connect(dataForm.value.input_stream_url) const myVideo = document.getElementById('video-rtsp-container') as HTMLMediaElement myVideo.addEventListener('loadedmetadata', () => { - const width = myVideo.videoWidth - const height = myVideo.videoHeight + let width = myVideo.videoWidth + let height = myVideo.videoHeight console.log(width, height, '视频分辨率') + if (width === 0 || height === 0) { + width = 426.4 * 3 + height = 240 * 3 + } // 获取到视频分辨率后 设置 canvans 和 video 的 宽高比 const resolution = width / height console.log(resolution, '宽高比') myVideo.style.width = `${width / 3}px` myVideo.style.height = `${height / 3}px` + // const drawWidth = ref(426.4) + // const drawHeight = ref(240) // 设置canvans drawWidth.value = width / 3 drawHeight.value = height / 3 showDraw.value = false setTimeout(() => { showDraw.value = true - if(!dataForm.value.id) return + if (!dataForm.value.id) return + loadingPonit.value = true getSceneRelations({ id: dataForm.value.id }).then(res => { - if (res.data.range_points) { - areaRef.value.setPonits(res.data.range_points) - } - else { - areaRef.value.setPonits() - } + setTimeout(() => { + if (res.data.range_points) { + areaRef.value.setPonits(res.data.range_points) + } + else { + areaRef.value.setPonits() + } + loadingPonit.value = false + }, 500); }) }, 100) }) @@ -425,16 +444,16 @@ -
+
-
恢复默认
+
恢复默认
清空 + style="margin: 0 auto;" :disabled="loadingPonit">清空
diff --git a/public/config/config.json b/public/config/config.json index 55d823b..bcfef2d 100644 --- a/public/config/config.json +++ b/public/config/config.json @@ -1,4 +1,5 @@ { + "update": "2025-05-27", "title": "智能一体机管理系统", "baseUrl": "http://192.168.10.236:9000", "playerType": "get", diff --git a/src/views/page/device/components/addDialog.vue b/src/views/page/device/components/addDialog.vue index e47072e..e595f24 100644 --- a/src/views/page/device/components/addDialog.vue +++ b/src/views/page/device/components/addDialog.vue @@ -56,6 +56,7 @@ const drawHeight = ref(240) const showDraw = ref(true) const webRtcServer = ref(null) +const loadingPonit = ref(true) // 初始化对话框 const initDialog = (row: any, dialogStatusValue: string) => { dialogStatus.value = dialogStatusValue @@ -110,6 +111,7 @@ }) } else if (dataForm.value.mode === '2') { + loadingPonit.value = true getSceneRelations({ id: row.id }).then(res => { if (res.data.range_points) { areaRef.value.setPonits(res.data.range_points) @@ -117,6 +119,7 @@ else { areaRef.value.setPonits() } + loadingPonit.value = false }) playerVideo() } @@ -172,6 +175,12 @@ emits('refresh') resetForm() cancel() + // if (webRtcServer.value) { + console.log('销毁视频') + webRtcServer.value?.disconnect() + webRtcServer.value = null + showVideo.value = false + // } } (dialogStatus.value === 'update' ? updateDevice : addDevice)(dataForm.value).then((res) => { // 算法 @@ -264,28 +273,38 @@ webRtcServer.value.connect(dataForm.value.input_stream_url) const myVideo = document.getElementById('video-rtsp-container') as HTMLMediaElement myVideo.addEventListener('loadedmetadata', () => { - const width = myVideo.videoWidth - const height = myVideo.videoHeight + let width = myVideo.videoWidth + let height = myVideo.videoHeight console.log(width, height, '视频分辨率') + if (width === 0 || height === 0) { + width = 426.4 * 3 + height = 240 * 3 + } // 获取到视频分辨率后 设置 canvans 和 video 的 宽高比 const resolution = width / height console.log(resolution, '宽高比') myVideo.style.width = `${width / 3}px` myVideo.style.height = `${height / 3}px` + // const drawWidth = ref(426.4) + // const drawHeight = ref(240) // 设置canvans drawWidth.value = width / 3 drawHeight.value = height / 3 showDraw.value = false setTimeout(() => { showDraw.value = true - if(!dataForm.value.id) return + if (!dataForm.value.id) return + loadingPonit.value = true getSceneRelations({ id: dataForm.value.id }).then(res => { - if (res.data.range_points) { - areaRef.value.setPonits(res.data.range_points) - } - else { - areaRef.value.setPonits() - } + setTimeout(() => { + if (res.data.range_points) { + areaRef.value.setPonits(res.data.range_points) + } + else { + areaRef.value.setPonits() + } + loadingPonit.value = false + }, 500); }) }, 100) }) @@ -425,16 +444,16 @@ -
+
-
恢复默认
+
恢复默认
清空 + style="margin: 0 auto;" :disabled="loadingPonit">清空
diff --git a/src/views/page/device/components/drawArea.vue b/src/views/page/device/components/drawArea.vue index ccefe0c..f2010fb 100644 --- a/src/views/page/device/components/drawArea.vue +++ b/src/views/page/device/components/drawArea.vue @@ -42,7 +42,7 @@ ctx.clearRect(0, 0, container.clientWidth, container.clientHeight) // 初始位置 function draw() { - if(points.value.length !== 4) { return} + if (points.value.length !== 4) { return } ctx.clearRect(0, 0, canvas.width, canvas.height) ctx.beginPath() ctx.moveTo(points.value[0].x, points.value[0].y) @@ -109,8 +109,11 @@ } function init() { + if (points.value.length !== 4) { return } draw() - addDragEvents() + setTimeout(() => { + addDragEvents() + }) } init() } @@ -141,9 +144,9 @@ ]) watch(() => points.value, () => { - if(points.value.length !== 4) { + if (points.value.length !== 4) { style.value = [] - return + return } style.value = [ { @@ -180,6 +183,7 @@ initDraw() return } + const pointsArr = JSON.parse(data) points.value = pointsArr.map((item: any) => ({ x: Number(item[0]) * $props.width,