From 08185fbfb1e850fe1cb9d7f6c2b345c78d105083 Mon Sep 17 00:00:00 2001 From: KoriIku <86508666+KoriIku@users.noreply.github.com> Date: Thu, 10 Oct 2024 12:55:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E7=A7=BB=E9=99=A4=20service?= =?UTF-8?q?=20worker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/main.js b/src/main.js index 325d65b..5ae0a79 100644 --- a/src/main.js +++ b/src/main.js @@ -8,19 +8,21 @@ const app = createApp(App) app.use(router) -// 注册 Service Worker -if ('serviceWorker' in navigator) { - window.addEventListener('load', () => { - navigator.serviceWorker.register('/service-worker.js').then((registration) => { - console.log('Service Worker 注册成功,作用域为: ', registration.scope); - return registration.update(); // 立即更新 Service Worker - }).then(() => { - app.mount('#app'); // 确保在 Service Worker 注册后再挂载 Vue 实例 - }).catch((err) => { - console.error('Service Worker 注册失败: ', err); - app.mount('#app'); // 即使注册失败,也要确保 Vue 挂载 - }); - }); -} else { - app.mount('#app'); // 如果浏览器不支持 Service Worker,继续正常挂载 -} +app.mount('#app'); + +// // 注册 Service Worker +// if ('serviceWorker' in navigator) { +// window.addEventListener('load', () => { +// navigator.serviceWorker.register('/service-worker.js').then((registration) => { +// console.log('Service Worker 注册成功,作用域为: ', registration.scope); +// return registration.update(); // 立即更新 Service Worker +// }).then(() => { +// app.mount('#app'); // 确保在 Service Worker 注册后再挂载 Vue 实例 +// }).catch((err) => { +// console.error('Service Worker 注册失败: ', err); +// app.mount('#app'); // 即使注册失败,也要确保 Vue 挂载 +// }); +// }); +// } else { +// app.mount('#app'); // 如果浏览器不支持 Service Worker,继续正常挂载 +// }