Showing
1 changed file
with
9 additions
and
0 deletions
@@ -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 | }); |