示例代码
页面端
const channel = await ServiceWorkerChannel
.createFromPage()
const response = await channel.publish(
'getData',
{ id: 42 }
)
console.log(response.data)
channel.subscribe('push', ({ data }) => {
console.log('SW 推送:', data)
return { received: true }
})