Commit 18b559c9 authored by Regis's avatar Regis

deal with preventing DDOS

parent a96499cf
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
resourceChecker(); resourceChecker();
goFetch(); goFetch();
const removePipelineInterval = () => { const removePipelineIntervals = () => {
this.allTimeIntervals.forEach(e => clearInterval(e.id)); this.allTimeIntervals.forEach(e => clearInterval(e.id));
}; };
...@@ -51,17 +51,18 @@ ...@@ -51,17 +51,18 @@
this.allTimeIntervals.forEach(e => e.start()); this.allTimeIntervals.forEach(e => e.start());
}; };
window.onbeforeunload = function onClose() { const removeAll = () => {
removePipelineInterval(); removePipelineIntervals();
window.removeEventListener('beforeunload', () => {});
window.removeEventListener('focus', () => {});
window.removeEventListener('blur', () => {});
document.removeEventListener('page:fetch', () => {});
}; };
window.onblur = function remove() { window.addEventListener('beforeunload', removePipelineIntervals);
removePipelineInterval(); window.addEventListener('focus', startIntervalLoops);
}; window.addEventListener('blur', removePipelineIntervals);
document.addEventListener('page:fetch', removeAll);
window.onfocus = function start() {
startIntervalLoops();
};
} }
}; };
})(window.gl || (window.gl = {})); })(window.gl || (window.gl = {}));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment