...
|
...
|
@@ -7,23 +7,25 @@ function register() { |
|
|
const t = window.STATIC_RESOURCE_HASH || '';
|
|
|
const staticServer = window.STATIC_RESOURCE_PATH || '';
|
|
|
|
|
|
navigator.serviceWorker.register(`/sw.js?t=${t}&staticServer=${staticServer}`, {
|
|
|
scope: '/'
|
|
|
}).then(() => {
|
|
|
if (window._hmt && window._hmt.push) {
|
|
|
window._hmt.push(['_trackEvent', 'SW registered', 'SUCCESS',
|
|
|
document.title, location.href]);
|
|
|
}
|
|
|
}).catch(err => {
|
|
|
if (window._hmt && window._hmt.push) {
|
|
|
window._hmt.push(['_trackEvent', 'SW registered', 'FAILED',
|
|
|
document.title, JSON.stringify(err)]);
|
|
|
}
|
|
|
});
|
|
|
if (navigator && navigator.serviceWorker && navigator.serviceWorker.register) {
|
|
|
navigator.serviceWorker.register(`/sw.js?t=${t}&staticServer=${staticServer}`, {
|
|
|
scope: '/'
|
|
|
}).then(() => {
|
|
|
if (window._hmt && window._hmt.push) {
|
|
|
window._hmt.push(['_trackEvent', 'SW registered', 'SUCCESS',
|
|
|
document.title, location.href]);
|
|
|
}
|
|
|
}).catch(err => {
|
|
|
if (window._hmt && window._hmt.push) {
|
|
|
window._hmt.push(['_trackEvent', 'SW registered', 'FAILED',
|
|
|
document.title, JSON.stringify(err)]);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function unregister() {
|
|
|
if (isHttps) {
|
|
|
if (isHttps && navigator && navigator.serviceWorker && navigator.serviceWorker.getRegistrations) {
|
|
|
navigator.serviceWorker.getRegistrations().then(registrations => {
|
|
|
for (let registration of registrations) {
|
|
|
registration.unregister().then(() => {
|
...
|
...
|
|