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) }