This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const VER = 6
|
||||
const VER = 7
|
||||
|
||||
self.addEventListener('message', async (event) => {
|
||||
event.waitUntil(debug(event.source, Object.assign({ answer: true }, event.data)))
|
||||
@@ -27,12 +27,18 @@ self.addEventListener('push', (event) => {
|
||||
if (!pushData || !pushData.notification.title) {
|
||||
console.error('Received WebPush with an empty title. Received body: ', pushData)
|
||||
}
|
||||
self.registration
|
||||
.showNotification(pushData.notification.title, pushData.notification.options)
|
||||
.then(function () {
|
||||
// You can save to your analytics fact that push was shown
|
||||
// fetch('https://your_backend_server.com/track_show?message_id=' + pushData.data.message_id);
|
||||
})
|
||||
event.waitUntil(
|
||||
self.registration
|
||||
.showNotification(pushData.notification.title, pushData.notification.options)
|
||||
.then(function () {
|
||||
// You can save to your analytics fact that push was shown
|
||||
// fetch('https://your_backend_server.com/track_show?message_id=' + pushData.data.message_id);
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
self.addEventListener('notificationclick', (event) => {
|
||||
event.waitUntil(handleNotificationClick(event))
|
||||
})
|
||||
|
||||
async function handleNotificationClick(event) {
|
||||
@@ -57,10 +63,6 @@ async function handleNotificationClick(event) {
|
||||
await openURL(event.notification.data.url)
|
||||
}
|
||||
|
||||
self.addEventListener('notificationclick', (event) => {
|
||||
event.waitUntil(handleNotificationClick(event))
|
||||
})
|
||||
|
||||
async function openURL(urlToOpen) {
|
||||
let matchedClients
|
||||
try {
|
||||
|
||||
@@ -127,9 +127,10 @@ export default defineConfig(({ mode }) => {
|
||||
'/manifest.json': {
|
||||
async handler(req, res) {
|
||||
const { default: manifestJSON } = await import('./src/manifest.json')
|
||||
const result = { ...manifestJSON, ...manifest, id: `//${req.headers.host}` }
|
||||
res.statusCode = 200
|
||||
res.setHeader('Content-Type', 'text/html')
|
||||
res.end(JSON.stringify({ ...manifestJSON, ...manifest }, null, 2))
|
||||
res.setHeader('Content-Type', 'application/json;charset=utf-8')
|
||||
res.end(JSON.stringify(result, null, 2))
|
||||
},
|
||||
} satisfies RouteConfig,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user