1
0

Add minimal PWA (#34)

This commit is contained in:
konrad
2019-10-16 18:25:10 +00:00
committed by Gitea
parent 568de04a87
commit 2a7871cf96
20 changed files with 4405 additions and 89 deletions

4
src/ServiceWorker/sw.js Normal file
View File

@ -0,0 +1,4 @@
/* eslint-disable no-console */
console.log('Hello from the service worker');

View File

@ -87,6 +87,9 @@ Vue.component('icon', FontAwesomeIcon)
import VTooltip from 'v-tooltip'
Vue.use(VTooltip)
// PWA
import './registerServiceWorker'
// Set focus
Vue.directive('focus', {
// When the bound element is inserted into the DOM...

View File

@ -0,0 +1,31 @@
/* eslint-disable no-console */
import { register } from 'register-service-worker'
if (process.env.NODE_ENV === 'production') {
register(`${process.env.BASE_URL}sw.js`, {
ready () {
console.log(
'App is being served from cache by a service worker.'
)
},
registered () {
console.log('Service worker has been registered.')
},
cached () {
console.log('Content has been cached for offline use.')
},
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)
}
})
}