fix: 获取网元状态定时轮询修复

This commit is contained in:
TsMask
2024-11-21 18:19:07 +08:00
parent 78f963fbea
commit fb855fd74e
3 changed files with 29 additions and 15 deletions

View File

@@ -30,11 +30,12 @@ function fnRanderData() {
}
/**网元状态调度器 */
const interval10s = ref<any>(null);
const interval = ref<boolean>(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;
});
</script>