✨ (notification) notify when a new service worker is available.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
import { register } from 'register-service-worker'
|
import { register } from 'register-service-worker'
|
||||||
import { setNotificationInstance } from './utils/notification'
|
import { setNotificationInstance, notify } from './utils/notification'
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'production') {
|
if (process.env.NODE_ENV === 'production') {
|
||||||
register(`${process.env.BASE_URL}service-worker.js`, {
|
register(`${process.env.BASE_URL}service-worker.js`, {
|
||||||
@@ -20,8 +20,14 @@ if (process.env.NODE_ENV === 'production') {
|
|||||||
updatefound() {
|
updatefound() {
|
||||||
console.log('New content is downloading.')
|
console.log('New content is downloading.')
|
||||||
},
|
},
|
||||||
updated() {
|
updated(sw) {
|
||||||
console.log('New content is available; please refresh.')
|
console.log('New content is available; please refresh.')
|
||||||
|
setNotificationInstance((title, options?) =>
|
||||||
|
sw.showNotification(title, options)
|
||||||
|
)
|
||||||
|
notify('Une nouvelle version est disponible.', {
|
||||||
|
body: 'Rafraichissez la page pour mettre à jour.'
|
||||||
|
})
|
||||||
},
|
},
|
||||||
offline() {
|
offline() {
|
||||||
console.log(
|
console.log(
|
||||||
|
|||||||
Reference in New Issue
Block a user