Commit 390ee0dd081e5c5070b8622eeda86728c2377e0e

Authored by xp.Huang
2 parents 387c34bd d5f2436d

Merge branch 'perf/alarm-notify' into 'main_dev'

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

See merge request yunteng/thingskit-front!1015
@@ -127,10 +127,19 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { @@ -127,10 +127,19 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) {
127 clearInterval(timeout as NodeJS.Timer); 127 clearInterval(timeout as NodeJS.Timer);
128 timeout = null; 128 timeout = null;
129 }; 129 };
  130 +
130 onMounted(() => { 131 onMounted(() => {
131 if (getRoleHasNotifyFlag()) polling(); 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 onUnmounted(() => { 143 onUnmounted(() => {
135 clearTimeout(); 144 clearTimeout();
136 }); 145 });