mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
Improve Service Worker (#8089)
* Update service-worker.js * Update serviceWorker.ts * Update serviceWorker.ts
This commit is contained in:
parent
f9d71002fc
commit
99c4f1f890
2 changed files with 16 additions and 11 deletions
|
|
@ -1,5 +1,5 @@
|
|||
// https://github.com/siyuan-note/siyuan/pull/8012
|
||||
export const registerServiceWorker = (scriptURL: string) => {
|
||||
export const registerServiceWorker = (scriptURL: string, scope: string = "/", workerType: WorkerType = "module") => {
|
||||
if (!("serviceWorker" in navigator) || typeof (navigator.serviceWorker) === "undefined" ||
|
||||
!("caches" in window) || !("fetch" in window)) {
|
||||
return;
|
||||
|
|
@ -7,8 +7,8 @@ export const registerServiceWorker = (scriptURL: string) => {
|
|||
// REF https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration
|
||||
window.navigator.serviceWorker
|
||||
.register(scriptURL, {
|
||||
scope: "./",
|
||||
type: "module",
|
||||
scope,
|
||||
type: workerType,
|
||||
}).then(registration => {
|
||||
registration.update();
|
||||
}).catch(e => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue