This commit is contained in:
freedakgmail
2025-11-24 16:07:24 +08:00
parent 3d075c6076
commit b25f4bea02
426 changed files with 3619 additions and 4468 deletions
+11 -1
View File
@@ -1,6 +1,16 @@
export function registerServiceWorker() {
if (typeof window === "undefined" || !("serviceWorker" in navigator)) {
console.log("Service Worker 不被支持")
// Service Worker 不被支持,静默跳过
return
}
// 只在 HTTPS 或 localhost 环境下注册 Service Worker
const isSecureContext = window.location.protocol === "https:" ||
window.location.hostname === "localhost" ||
window.location.hostname === "127.0.0.1"
if (!isSecureContext) {
// 非安全环境,静默跳过 Service Worker 注册
return
}