fix: 拓扑状态刷新定时器改调度器

This commit is contained in:
TsMask
2024-03-21 10:10:46 +08:00
parent d15b75e8fd
commit 2a622aa1d6
3 changed files with 21 additions and 22 deletions

View File

@@ -328,16 +328,18 @@ function fnGraphDataLoad(reload: boolean = false) {
} else {
handleRanderGraph(graphG6Dom.value, graphState.data);
}
fnGetState(); // 获取网元状态
fnGetState();
interval10s.value = setInterval(() => {
fnGetState(); // 获取网元状态
}, 10_000);
});
}
/**网元状态定时器 */
const stateTimeout = ref<any>(null);
/**网元状态调度器 */
const interval10s = ref<any>(null);
/**查询网元状态 */
async function fnGetState() {
clearTimeout(stateTimeout.value);
// 获取节点状态
for (const node of graphState.data.nodes) {
if (notNeNodes.includes(node.id)) continue;
@@ -352,8 +354,6 @@ async function fnGetState() {
},
});
}
stateTimeout.value = setTimeout(() => fnGetState(), 30_000);
}
/**接收数据后回调 */
@@ -472,7 +472,7 @@ onMounted(() => {
onBeforeUnmount(() => {
ws.close();
clearTimeout(stateTimeout.value);
clearInterval(interval10s.value);
});
</script>