feat: Service Worker 注册失败修复方案
1. 使用了 window.location.origin,但 Service Worker 环境中没有 window 对象 2. 注册逻辑缺少详细的错误处理和状态检查
This commit is contained in:
@@ -35,7 +35,7 @@ self.addEventListener('notificationclick', (event) => {
|
||||
.then((windowClients) => {
|
||||
// 查找是否已有打开的窗口
|
||||
for (let client of windowClients) {
|
||||
if (client.url.includes(window.location.origin) && 'focus' in client) {
|
||||
if (client.url.includes(self.location.origin) && 'focus' in client) {
|
||||
// 聚焦现有窗口并导航到目标页面
|
||||
return client.focus().then(client => {
|
||||
return client.navigate(urlToOpen);
|
||||
|
||||
Reference in New Issue
Block a user