This commit is contained in:
@@ -104,43 +104,50 @@ self.addEventListener('notificationclick', (event) => {
|
|||||||
console.log('focus')
|
console.log('focus')
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
|
client.focus(),
|
||||||
client.postMessage({
|
client.postMessage({
|
||||||
type: 'notificationClick',
|
type: 'notificationClick',
|
||||||
tag: event.notification.tag,
|
tag: event.notification.tag,
|
||||||
payload: event.notification.payload,
|
payload: event.notification.payload,
|
||||||
matchUrl: true,
|
matchUrl: true,
|
||||||
}),
|
}),
|
||||||
client.focus(),
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Promise.resolve()
|
if (clients.openWindow) {
|
||||||
.then(() => {
|
console.log('open new window', urlToOpen)
|
||||||
if (!clients.openWindow) {
|
|
||||||
throw new Error('clients.openWindow not available')
|
return clients.openWindow(urlToOpen).then((client) => {
|
||||||
}
|
if (!client) {
|
||||||
return clients.openWindow(urlToOpen).then((newClient) => {
|
console.log('new window not opened')
|
||||||
if (!newClient) {
|
for (const client of clientList) {
|
||||||
throw new Error('new window not opened')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.debug('Error', error)
|
|
||||||
for (const client of clientList) {
|
|
||||||
return Promise.all([
|
|
||||||
client.postMessage({
|
client.postMessage({
|
||||||
type: 'notificationClick',
|
type: 'notificationClick',
|
||||||
url: urlToOpen,
|
url: urlToOpen,
|
||||||
tag: event.notification.tag,
|
tag: event.notification.tag,
|
||||||
payload: event.notification.payload,
|
payload: event.notification.payload,
|
||||||
matchUrl: false,
|
matchUrl: false,
|
||||||
msg: 'clients.openWindow not available',
|
msg: 'new window not opened',
|
||||||
}),
|
})
|
||||||
client.focus(),
|
break
|
||||||
])
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
console.log('clients.openWindow not available')
|
||||||
|
|
||||||
|
for (const client of clientList) {
|
||||||
|
client.postMessage({
|
||||||
|
type: 'notificationClick',
|
||||||
|
url: urlToOpen,
|
||||||
|
tag: event.notification.tag,
|
||||||
|
payload: event.notification.payload,
|
||||||
|
matchUrl: false,
|
||||||
|
msg: 'clients.openWindow not available',
|
||||||
|
})
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ app.use(PrimeVue, {
|
|||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|
||||||
registerServiceWorker()
|
registerServiceWorker()
|
||||||
.then((registration) => {
|
.then(() => {
|
||||||
console.log('Service Worker успешно зарегистрирован')
|
console.log('Service Worker успешно зарегистрирован')
|
||||||
navigator.serviceWorker.addEventListener('message', (event) => {
|
navigator.serviceWorker.addEventListener('message', (event) => {
|
||||||
console.debug('serviceWorker message', event.data)
|
console.debug('serviceWorker message', event.data)
|
||||||
|
|||||||
Reference in New Issue
Block a user