mirror of
https://github.com/aljazceru/meshcore-web.git
synced 2025-12-18 08:34:21 +01:00
auto update service worker and push new vue route when clicking message notification
This commit is contained in:
16
src/main.js
16
src/main.js
@@ -52,6 +52,22 @@ for(const route of routes){
|
||||
}
|
||||
}
|
||||
|
||||
// listen for postMessage events from service worker
|
||||
navigator.serviceWorker.addEventListener("message", async (event) => {
|
||||
if(event.data.type === "notificationclick"){
|
||||
|
||||
// get notification data
|
||||
const notificationData = event.data.data;
|
||||
|
||||
// if notification data includes vue-route-push, push the route to vue
|
||||
const vueRoutePush = notificationData["vue-route-push"];
|
||||
if(vueRoutePush){
|
||||
await router.push(vueRoutePush);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
createApp(App)
|
||||
.use(router)
|
||||
.use(vClickOutside)
|
||||
|
||||
Reference in New Issue
Block a user