🐛 Fix the request of PWA files without Authentication
Header (#11586)
This commit is contained in:
parent
062275f69a
commit
060a1c500e
3 changed files with 23 additions and 13 deletions
|
@ -6,7 +6,7 @@
|
|||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, viewport-fit=cover, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<link rel="manifest" href="/manifest.webmanifest">
|
||||
<link rel="manifest" href="/manifest.webmanifest" crossorigin="use-credentials">
|
||||
<link rel="apple-touch-icon" href="../../icon.png">
|
||||
<style id="editorAttr" type="text/css"></style>
|
||||
</head>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, height=device-height, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, viewport-fit=cover">
|
||||
<link rel="manifest" href="/manifest.webmanifest">
|
||||
<link rel="manifest" href="/manifest.webmanifest" crossorigin="use-credentials">
|
||||
</head>
|
||||
<body class="fn__flex-column">
|
||||
<div id="loading" class="b3-dialog b3-dialog--open">
|
||||
|
|
|
@ -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}`);
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue