fix: 获取网元状态定时轮询修复
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user