From 2bfd46a6368e06ce6b87020f872d3798cadf9a67 Mon Sep 17 00:00:00 2001 From: zjc <1034206993@qq.com> Date: Thu, 27 Feb 2025 14:25:01 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=AE=8C=E5=96=84=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CoreVideo/index.vue | 11 +++----- src/components/RegionTop/index.vue | 42 +++++++++++++++++------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/components/CoreVideo/index.vue b/src/components/CoreVideo/index.vue index 05fb309..9104b67 100644 --- a/src/components/CoreVideo/index.vue +++ b/src/components/CoreVideo/index.vue @@ -64,7 +64,6 @@ pageNum: 1, pageSize: 5 }) - console.log(res, 'res') list.value = res.data nextTick(() => { list.value.forEach(async (item, index) => { @@ -87,8 +86,8 @@ }) } - const initList = () => { - // 释放hls实例 + // 释放hls实例 + const clearHlsRefs = () => { if (hlsRefs.length > 0) { hlsRefs.map((item) => { item.destroy() @@ -99,7 +98,7 @@ } const onVideoCollect = () => { pubSub.subscribe('videoCollect', () => { - initList() + clearHlsRefs() }) } @@ -108,9 +107,7 @@ id, isCollect: 0 }) - list.value.splice(index, 1) - hlsRefs[index].destroy() - hlsRefs.splice(index, 1) + clearHlsRefs() } onMounted(() => { diff --git a/src/components/RegionTop/index.vue b/src/components/RegionTop/index.vue index ecc5975..c9cf03b 100644 --- a/src/components/RegionTop/index.vue +++ b/src/components/RegionTop/index.vue @@ -34,18 +34,30 @@ watch( () => props.list, - (val) => { - if (val.length > 0) { - setTimeout(() => { - init() - }, 1000) - } + () => { + setTimeout(() => { + init() + }, 1000) }, { immediate: true } ) - + const getYAxisData = () => { + return props.list.map((item) => Number(item.value)) + } + const getSeriesData = () => { + return props.list.map((item) => { + return { + name: item.name, + value: Number(item.value), + itemStyle: { + borderRadius: [0, 0, 0, 0], + color: parseFloat(item.value) > 50 ? '#FF7021' : '#00CCFF' + } + } + }) + } const init = () => { if (!params) { params = { @@ -102,7 +114,7 @@ } } }, - data: props.list.map((item) => Number(item.value)) + data: getYAxisData() } ], series: [ @@ -126,19 +138,13 @@ return params.data.name ?? '其他' } }, - data: props.list.map((item) => { - return { - name: item.name, - value: Number(item.value), - itemStyle: { - borderRadius: [0, 0, 0, 0], - color: parseFloat(item.value) > 50 ? '#FF7021' : '#00CCFF' - } - } - }) + data: getSeriesData() } ] } + } else { + params.yAxis[1].data = getYAxisData() + params.series[0].data = getSeriesData() } setOption(params) }