aa
Some checks failed
test / Run tests (push) Failing after 11s
build / Build (push) Failing after 16s
Some checks failed
test / Run tests (push) Failing after 11s
build / Build (push) Failing after 16s
This commit is contained in:
@ -87,12 +87,11 @@ export default class GMApi {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function sendMessageToOffscreen(action: string, data?: any) {
|
||||
// service_worker和offscreen同时监听消息,会导致消息被两边同时接收,但是返回结果时会产生问题,导致报错
|
||||
// 不进行监听的话又无法从service_worker主动发送消息
|
||||
// 所以这里通过clients.matchAll()获取到所有的client,然后通过postMessage发送消息
|
||||
const list = await clients.matchAll();
|
||||
const list = await clients.matchAll({ includeUncontrolled: true, type: "window" });
|
||||
list[0].postMessage({
|
||||
type: "sendMessage",
|
||||
data: { action, data },
|
||||
|
Reference in New Issue
Block a user