u
This commit is contained in:
23
index.html
23
index.html
@@ -24,6 +24,29 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script>
|
||||
(function () {
|
||||
var host = location.hostname;
|
||||
if (host !== 'localhost' && host !== '127.0.0.1') return;
|
||||
if (!navigator.serviceWorker) return;
|
||||
var hadSw = false;
|
||||
navigator.serviceWorker.getRegistrations().then(function (regs) {
|
||||
hadSw = regs.length > 0;
|
||||
return Promise.all(regs.map(function (r) { return r.unregister(); }));
|
||||
}).then(function () {
|
||||
if (!window.caches) return hadSw;
|
||||
return caches.keys().then(function (keys) {
|
||||
return Promise.all(keys.map(function (k) { return caches.delete(k); }))
|
||||
.then(function () { return hadSw; });
|
||||
});
|
||||
}).then(function (reload) {
|
||||
if (reload && !sessionStorage.getItem('dashfront-sw-cleared')) {
|
||||
sessionStorage.setItem('dashfront-sw-cleared', '1');
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<script type="module" src="/src/main.jsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user