PWA support.

This commit is contained in:
HenriT
2021-04-19 14:45:46 +03:00
parent 2e57464679
commit 92560b0641
27 changed files with 462 additions and 49 deletions

View File

@@ -6,6 +6,7 @@ import App from '@/App.vue';
import router from '@/router';
import store from '@/store/store';
import VueNotifications from 'vue-notification';
import './registerServiceWorker';
Vue.use(BVModalPlugin);
Vue.use(VueNotifications);

View File

@@ -0,0 +1,32 @@
/* eslint-disable no-console */
import { register } from 'register-service-worker';
if (process.env.NODE_ENV === 'production') {
register(`${process.env.BASE_URL}service-worker.js`, {
ready() {
console.log(
'App is being served from cache by a service worker.\n'
+ 'For more details, visit https://goo.gl/AFskqB',
);
},
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);
},
});
}