From fb855fd74eb47a443a52ea2563fe3f24140cff03 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Thu, 21 Nov 2024 18:19:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=8E=B7=E5=8F=96=E7=BD=91=E5=85=83?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=AE=9A=E6=97=B6=E8=BD=AE=E8=AF=A2=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/dashboard/overview/index.vue | 2 ++ src/views/monitor/topology/index.vue | 25 +++++++++++++------ .../monitor/topologyArchitecture/index.vue | 17 +++++++------ 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/views/dashboard/overview/index.vue b/src/views/dashboard/overview/index.vue index bcf03188..231d0588 100644 --- a/src/views/dashboard/overview/index.vue +++ b/src/views/dashboard/overview/index.vue @@ -162,6 +162,7 @@ function loadData() { clearInterval(interval10s.value); interval10s.value = setInterval(() => { + if (!interval10s.value) return if (upfTFActive.value === '0') { upfTFSend('7'); upfTFActive.value = '7'; @@ -176,6 +177,7 @@ function loadData() { clearInterval(interval5s.value); interval5s.value = setInterval(() => { + if (!interval5s.value) return fnGetSkim(); // 获取概览信息 fnGetNeState(); // 获取网元状态 }, 5_000); diff --git a/src/views/monitor/topology/index.vue b/src/views/monitor/topology/index.vue index 3c87d33d..2e30e98c 100644 --- a/src/views/monitor/topology/index.vue +++ b/src/views/monitor/topology/index.vue @@ -30,11 +30,12 @@ function fnRanderData() { } /**网元状态调度器 */ -const interval10s = ref(null); +const interval = ref(true); /**查询网元状态 */ async function fnGetState() { for (const node of graphG6Data.nodes) { + if (!interval.value) return; const ne = node.info; // if (ne.neType === 'OMC') continue; const result = await stateNeInfo(ne.neType, ne.neId); @@ -151,11 +152,21 @@ function fnGetList(refresh: boolean = false) { }) .then(randerGroph => { if (!randerGroph) return; - fnGetState().finally(() => { - interval10s.value = setInterval(() => { - fnGetState(); // 获取网元状态 - }, 10_000); - }); + repeatFn(); + }); +} + +/**递归刷新网元状态 */ +function repeatFn() { + if (!interval.value) { + return; + } + fnGetState() + .finally(() => { + repeatFn(); // 递归调用自己 + }) + .catch(error => { + console.error(error); }); } @@ -165,7 +176,7 @@ onMounted(() => { }); onBeforeUnmount(() => { - clearInterval(interval10s.value); + interval.value = false; }); diff --git a/src/views/monitor/topologyArchitecture/index.vue b/src/views/monitor/topologyArchitecture/index.vue index a5ee3889..289a4ba1 100644 --- a/src/views/monitor/topologyArchitecture/index.vue +++ b/src/views/monitor/topologyArchitecture/index.vue @@ -166,7 +166,7 @@ const graphNodeTooltip = new Tooltip({
${t('views.monitor.topology.expiryDate')}: ${neState.expire ?? '--'} -
+ `; }, @@ -294,7 +294,8 @@ function fnGraphDataLoad(reload: boolean = false) { Reflect.set(node, 'neState', { online: false }); // 图片路径处理 if (node.img) node.img = parseBasePath(node.img); - if (node.icon.show && node.icon?.img) node.icon.img = parseBasePath(node.icon.img); + if (node.icon.show && node.icon?.img) + node.icon.img = parseBasePath(node.icon.img); // 遍历是否有网元数据 const nodeID: string = node.id; const hasNe = res.neList.some(ne => { @@ -352,11 +353,11 @@ function fnGraphDataLoad(reload: boolean = false) { } clearInterval(interval10s.value); interval10s.value = null; - fnGetState().finally(() => { - interval10s.value = setInterval(() => { - fnGetState(); // 获取网元状态 - }, 10_000); - }); + fnGetState(); + interval10s.value = setInterval(async () => { + if (!interval10s.value) return; + fnGetState(); // 获取网元状态 + }, 20_000); }); } @@ -364,7 +365,7 @@ function fnGraphDataLoad(reload: boolean = false) { const interval10s = ref(null); /**查询网元状态 */ -async function fnGetState() { +function fnGetState() { // 获取节点状态 for (const node of graphState.data.nodes) { if (notNeNodes.includes(node.id)) continue;