diff --git a/app/src/assets/template/desktop/index.tpl b/app/src/assets/template/desktop/index.tpl index cbbe239bc..3a7824d87 100644 --- a/app/src/assets/template/desktop/index.tpl +++ b/app/src/assets/template/desktop/index.tpl @@ -6,7 +6,7 @@ content="width=device-width, initial-scale=1.0, maximum-scale=1.0, viewport-fit=cover, user-scalable=no"> - + diff --git a/app/src/assets/template/mobile/index.tpl b/app/src/assets/template/mobile/index.tpl index 830cbe107..40439b22a 100644 --- a/app/src/assets/template/mobile/index.tpl +++ b/app/src/assets/template/mobile/index.tpl @@ -3,7 +3,7 @@ - +
diff --git a/app/src/util/serviceWorker.ts b/app/src/util/serviceWorker.ts index e437249df..d7e3916bd 100644 --- a/app/src/util/serviceWorker.ts +++ b/app/src/util/serviceWorker.ts @@ -1,17 +1,27 @@ // https://github.com/siyuan-note/siyuan/pull/8012 -export const registerServiceWorker = (scriptURL: string, scope = "/", workerType: WorkerType = "module") => { - if (!("serviceWorker" in navigator) || typeof (navigator.serviceWorker) === "undefined" || - !("caches" in window) || !("fetch" in window)) { +export const registerServiceWorker = ( + scriptURL: string, + options: RegistrationOptions = { + scope: "/", + type: "classic", + updateViaCache: "all", + }, +) => { + + if (!("serviceWorker" in window.navigator) + || !("caches" in window) + || !("fetch" in window) + || navigator.serviceWorker == null + ) { return; } + // REF https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration window.navigator.serviceWorker - .register(scriptURL, { - scope, - type: workerType, - }).then(registration => { - registration.update(); - }).catch(e => { - console.debug(`Registration failed with ${e}`); - }); + .register(scriptURL, options) + .then(registration => { + registration.update(); + }).catch(e => { + console.debug(`Registration failed with ${e}`); + }); };