Skip to content

Commit 0341d3c

Browse files
authored
🐛 调整 init (#543)
1 parent 4484f01 commit 0341d3c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

packages/message/window_message.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,15 @@ export class ServiceWorkerMessageSend implements MessageSend {
170170

171171
async init() {
172172
if (!this.target && self.clients) {
173-
const list = await self.clients.matchAll({ includeUncontrolled: true, type: "window" });
174-
// 找到offscreen.html窗口
175-
this.target = list.find((client) => client.url == chrome.runtime.getURL("src/offscreen.html")) as PostMessage;
176173
if (!this.listened) {
177174
this.listened = true;
178175
self.addEventListener("message", (e) => {
179176
this.messageHandle(e.data);
180177
});
181178
}
179+
const list = await self.clients.matchAll({ includeUncontrolled: true, type: "window" });
180+
// 找到offscreen.html窗口
181+
this.target = list.find((client) => client.url == chrome.runtime.getURL("src/offscreen.html")) as PostMessage;
182182
}
183183
}
184184

0 commit comments

Comments
 (0)