0.0.9.0
This commit is contained in:
+11
-1
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user