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