PWA 工作箱后台同步队列请求队列对象可访问性

PWA workbox background sync queue requests queue object accessibility

我们可以访问外部服务工作者文件中的 Workbox 后台同步队列对象吗,在我的任何应用程序文件中说 index.php?

我相信你可以使用 BroadcastChannel API,像这样:

// From Service Worker, connect to the channel named "my_bus".
const channel = new BroadcastChannel('my_bus');
// Send a message on "my_bus".
channel.postMessage('This is a test message.');

// From client, listen for messages on "my_bus".
const channel = new BroadcastChannel('my_bus');
channel.onmessage = function(e) {
  console.log('Received', e.data);
};