open url by send message to page
Deploy frontend / frontend (push) Successful in 1m8s

This commit is contained in:
2024-12-02 18:57:07 +02:00
parent 4f0a013014
commit de8496395b
2 changed files with 66 additions and 37 deletions
+11 -1
View File
@@ -65,7 +65,17 @@ app.use(PrimeVue, {
app.mount('#app')
registerServiceWorker()
.then(() => console.log('Service Worker успешно зарегистрирован'))
.then((registration) => {
console.log('Service Worker успешно зарегистрирован')
navigator.serviceWorker.addEventListener('message', (event) => {
console.debug('serviceWorker message', event.data)
if (event.data.type === 'notificationClick' && !event.data.matchUrl) {
const url = new URL(event.data.url, location.origin)
console.debug('go to', `${url.pathname}${url.search}${url.hash}`)
router.push(`${url.pathname}${url.search}${url.hash}`)
}
})
})
.catch(console.error)
window.PouchDB = PouchDB // it for debug in console only