server worker fix

Co-authored-by: GM <giulio.migani@studenti.unitn.it>
This commit is contained in:
Alberto Xamin 2021-06-07 18:28:04 +02:00
parent 4f4007873a
commit ae6b6fbae4
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
14 changed files with 35 additions and 85 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 799 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8.00251 14.9297L0 1.07422H6.14651L8.00251 4.27503L9.84583 1.07422H16L8.00251 14.9297Z" fill="black"/>
</svg>

After

Width:  |  Height:  |  Size: 215 B

View File

@ -25,9 +25,7 @@ const i18n = new VueI18n({
messages messages
}) })
import wb from "./registerServiceWorker"; import './registerServiceWorker'
Vue.prototype.$workbox = wb;
new Vue({ new Vue({
i18n, i18n,

View File

@ -1,84 +1,32 @@
import { Workbox } from 'workbox-window'; /* eslint-disable no-console */
if ('serviceWorker' in navigator) {
const wb = new Workbox('/service-worker.js'); import { register } from 'register-service-worker'
wb.addEventListener('activated', event => {
// `event.isUpdate` will be true if another version of the service
// worker was controlling the page when this version was registered.
if (!event.isUpdate) {
console.log('Service worker activated for the first time!');
// If your service worker is configured to precache assets, those if (process.env.NODE_ENV === 'production') {
// assets should all be available now. register(`${process.env.BASE_URL}service-worker.js`, {
} ready () {
});
wb.addEventListener('waiting', () => {
console.log( console.log(
`A new service worker has installed, but it can't activate` + 'App is being served from cache by a service worker.\n' +
`until all tabs running the current version have fully unloaded.`, 'For more details, visit https://goo.gl/AFskqB'
); )
}); },
registered () {
wb.addEventListener('message', event => { console.log('Service worker has been registered.')
if (event.data.type === 'CACHE_UPDATE') { },
const { updatedURL } = event.data.payload; cached () {
console.log('Content has been cached for offline use.')
console.log(`A newer version of ${updatedURL} is available!`); },
updatefound () {
console.log('New content is downloading.')
},
updated () {
console.log('New content is available; please refresh.')
},
offline () {
console.log('No internet connection found. App is running in offline mode.')
},
error (error) {
console.error('Error during service worker registration:', error)
} }
}); })
wb.addEventListener('installed', event => {
if (!event.isUpdate) {
console.log('First install');
} else {
console.log('updated install');
}
});
wb.addEventListener('controlling', event => {
if (!event.isUpdate) {
console.log('First control');
} else {
console.log('updated control');
}
});
wb.addEventListener('externalinstalled', event => {
if (!event.isUpdate) {
console.log('external first install');
} else {
console.log('external update install');
}
});
wb.addEventListener('externalwaiting', event => {
if (!event.isUpdate) {
console.log('external first waiting');
} else {
console.log('external update waiting');
}
});
wb.addEventListener('externalactivated', event => {
if (!event.isUpdate) {
console.log('external first acvtive');
} else {
console.log('external update acvtive');
}
});
wb.addEventListener('redundant', event => {
// `event.isUpdate` will be true if another version of the service
// worker was controlling the page when this version was registered.
if (!event.isUpdate) {
console.log('Service worker redundant for the first time!');
// If your service worker is configured to precache assets, those
// assets should all be available now.
}
console.log(event);
});
wb.register();
} }

View File

@ -6,6 +6,7 @@ module.exports = {
name: 'PewPew!', name: 'PewPew!',
appleMobileWebAppCache: "yes", appleMobileWebAppCache: "yes",
manifestOptions: { manifestOptions: {
display: 'standalone',
} }
}, },
configureWebpack: { configureWebpack: {