Merge branch 'notifications-thru-sw' into shigusegubu-vue3
This commit is contained in:
commit
1732a0800c
1 changed files with 3 additions and 0 deletions
|
@ -99,11 +99,13 @@ export async function initServiceWorker (store) {
|
|||
|
||||
export async function showDesktopNotification (content) {
|
||||
const { active: sw } = await window.navigator.serviceWorker.getRegistration()
|
||||
if (!sw) return console.error('No serviceworker found!')
|
||||
sw.postMessage({ type: 'desktopNotification', content })
|
||||
}
|
||||
|
||||
export async function closeDesktopNotification ({ id }) {
|
||||
const { active: sw } = await window.navigator.serviceWorker.getRegistration()
|
||||
if (!sw) return console.error('No serviceworker found!')
|
||||
if (id >= 0) {
|
||||
sw.postMessage({ type: 'desktopNotificationClose', content: { id } })
|
||||
} else {
|
||||
|
@ -113,6 +115,7 @@ export async function closeDesktopNotification ({ id }) {
|
|||
|
||||
export async function updateFocus () {
|
||||
const { active: sw } = await window.navigator.serviceWorker.getRegistration()
|
||||
if (!sw) return console.error('No serviceworker found!')
|
||||
sw.postMessage({ type: 'updateFocus' })
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue