From 7edb14c0317666f9fc133da069125ebd777b18e2 Mon Sep 17 00:00:00 2001 From: lixuefeng <1126141216@qq.com> Date: Tue, 25 Nov 2025 20:48:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B1=BB=E5=9E=8B=EF=BC=9A=E5=BC=80=E5=8F=91?= =?UTF-8?q?=20=E6=8F=8F=E8=BF=B0=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/PieRow/index.vue | 6 -- src/views/home/components/box-2.vue | 6 +- src/views/hotel/components/video-box.vue | 109 ++++++++++++++--------- src/views/scenic/components/box-1.vue | 2 +- 4 files changed, 71 insertions(+), 52 deletions(-) diff --git a/src/components/PieRow/index.vue b/src/components/PieRow/index.vue index 16f581f..2fa2456 100644 --- a/src/components/PieRow/index.vue +++ b/src/components/PieRow/index.vue @@ -175,12 +175,6 @@ } }) defaultCofig.series[0].label.formatter = `{value|${parseInt(echartsNum/100*props.total)}}` + '\n' + `{name|${props.label}}`; - console.log(111111) - console.log({ - ...defaultCofig, - ...props.config - }) - console.log(222222) setOption({ ...defaultCofig, ...props.config diff --git a/src/views/home/components/box-2.vue b/src/views/home/components/box-2.vue index ea8ae18..fe63fd1 100644 --- a/src/views/home/components/box-2.vue +++ b/src/views/home/components/box-2.vue @@ -25,7 +25,7 @@
{{ item.name }}
-
{{ +
{{ item.value }}
@@ -439,6 +439,10 @@ @extend .value; color: #ff4400; } + &--warning { + @extend .value; + color: #DCBB48; + } &--primary { @extend .value; color: #02f9fa; diff --git a/src/views/hotel/components/video-box.vue b/src/views/hotel/components/video-box.vue index ad67912..3205916 100644 --- a/src/views/hotel/components/video-box.vue +++ b/src/views/hotel/components/video-box.vue @@ -55,7 +55,7 @@
- 未接入 + 加载中...
{ if(!videoList.value.length) return false videoList.value.forEach(async (x, index) => { - const video = document.getElementById(`monitorVideo${index}`) - const hls = new Hls({ - maxBufferLength: 10, // 最大缓冲长度(秒) - maxMaxBufferLength: 15, // 缓冲区长度的上限 - maxBufferSize: 30 * 1000 * 1000 // 最大缓冲大小(字节) - }) - hls.loadSource(x.hlsUrl) - hls.attachMedia(video) - hls.on(Hls.Events.MANIFEST_PARSED, () => { - video.play() - }) - hls.on(Hls.Events.ERROR, (event, data) => { - console.error('HLS 播放器遇到错误:', data); - // 根据错误类型进行处理 - // initVideo() - if (data.fatal) { - switch (data.type) { - case Hls.ErrorTypes.NETWORK_ERROR: - console.log('网络错误,尝试重新加载'); - hls.startLoad(); - break; - case Hls.ErrorTypes.MEDIA_ERROR: - console.log('媒体错误,尝试修复'); - hls.recoverMediaError(); - break; - default: - console.log('无法恢复的错误,销毁播放器'); - // hls.destroy(); - break; - } - } - }) - hlsRefs.push(hls) + const video = document.getElementById(`monitorVideo${index}`) + if(x.hlsUrl.startsWith('ws')){ + const player = mpegtsjs.createPlayer({ + url: x.hlsUrl, + type: 'flv', + isLive: true, + hasAudio: false + }) + player.attachMediaElement(video) + player.load() + player.play() + // 错误处理和重连机制 + player.on('error', (err) => { + // 3 秒后尝试重新加载 + setTimeout(() => { + player.load() + player.play() + }, 3000) + }) + }else{ + const hls = new Hls({ + maxBufferLength: 10, // 最大缓冲长度(秒) + maxMaxBufferLength: 15, // 缓冲区长度的上限 + maxBufferSize: 30 * 1000 * 1000 // 最大缓冲大小(字节) + }) + hls.loadSource(x.hlsUrl) + hls.attachMedia(video) + hls.on(Hls.Events.MANIFEST_PARSED, () => { + video.play() + }) + hls.on(Hls.Events.ERROR, (event, data) => { + console.error('HLS 播放器遇到错误:', data); + // 根据错误类型进行处理 + // initVideo() + if (data.fatal) { + switch (data.type) { + case Hls.ErrorTypes.NETWORK_ERROR: + console.log('网络错误,尝试重新加载'); + hls.startLoad(); + break; + case Hls.ErrorTypes.MEDIA_ERROR: + console.log('媒体错误,尝试修复'); + hls.recoverMediaError(); + break; + default: + console.log('无法恢复的错误,销毁播放器'); + // hls.destroy(); + break; + } + }}) + hlsRefs.push(hls) + } + }) }) } else { @@ -416,22 +437,22 @@ ) // 更新视频 const postVideoRemain = async () => { - timer = setInterval(() => { - postVideoRemainApi({ - cameraIndexCode: videoList.value.map((item) => item.cameraIndexCode) - }) - }, 1500) + // timer = setInterval(() => { + // postVideoRemainApi({ + // cameraIndexCode: videoList.value.map((item) => item.cameraIndexCode) + // }) + // }, 1500) } const getVideoRegions = async () => { let res = await getVideoRegionsApi({ cameraName: cameraName.value, businessScenicArea: params.businessScenicArea }) - regionList.value = res.data - regionList.value.forEach((item,index)=>{ - // item.show = true - item.videoResources=item.resourcesList[0].videoResources - }) + regionList.value = res.data[0].resourcesList; + // regionList.value.forEach((item,index)=>{ + // // item.show = true + // item.videoResources=item.resourcesList[0].videoResources + // }) regionList.value[0].show = false } diff --git a/src/views/scenic/components/box-1.vue b/src/views/scenic/components/box-1.vue index daf7882..163a75d 100644 --- a/src/views/scenic/components/box-1.vue +++ b/src/views/scenic/components/box-1.vue @@ -435,7 +435,7 @@ import pubSub from 'pubsub-js' .content { margin-left: vw(4); padding: 0 vw(10); - width: vw(760); + width: vw(460); height: vh(24); line-height: vh(24); white-space: nowrap;