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;