Commit d5f2436df858ff1b85ceb850f2101b9214f49540

Authored by ww
1 parent 387c34bd

优化告警通知,页面失焦时不再调用

... ... @@ -127,10 +127,19 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) {
127 127 clearInterval(timeout as NodeJS.Timer);
128 128 timeout = null;
129 129 };
  130 +
130 131 onMounted(() => {
131 132 if (getRoleHasNotifyFlag()) polling();
132 133 });
133 134
  135 + document.addEventListener('visibilitychange', () => {
  136 + if (document.hidden) {
  137 + clearTimeout();
  138 + } else {
  139 + polling();
  140 + }
  141 + });
  142 +
134 143 onUnmounted(() => {
135 144 clearTimeout();
136 145 });
... ...