-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(proxy): Fixed the issue that the TCP connection was interrupted w…
…hen setting a proxy siyuan-note/siyuan#9708
- Loading branch information
1 parent
081530a
commit cb68e91
Showing
11 changed files
with
114 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
// 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)) { | ||
return; | ||
export const registerServiceWorker = async (scriptURL: string, scope = "/", workerType: WorkerType = "module") => { | ||
if (("serviceWorker" in window.navigator) && ("caches" in window) && ("fetch" in window)) { | ||
try { | ||
// REF https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration | ||
const registration = await window.navigator.serviceWorker.register(scriptURL, { | ||
scope, | ||
type: workerType, | ||
}); | ||
await registration.update(); | ||
return true; | ||
} catch (error) { | ||
console.debug(`Registration failed with ${error}`); | ||
return false; | ||
} | ||
} | ||
// 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}`); | ||
}); | ||
return false; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters