mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
🐛 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">
|
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-capable" content="yes">
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
<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">
|
<link rel="apple-touch-icon" href="../../icon.png">
|
||||||
<style id="editorAttr" type="text/css"></style>
|
<style id="editorAttr" type="text/css"></style>
|
||||||
</head>
|
</head>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<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">
|
<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>
|
</head>
|
||||||
<body class="fn__flex-column">
|
<body class="fn__flex-column">
|
||||||
<div id="loading" class="b3-dialog b3-dialog--open">
|
<div id="loading" class="b3-dialog b3-dialog--open">
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,27 @@
|
||||||
// https://github.com/siyuan-note/siyuan/pull/8012
|
// https://github.com/siyuan-note/siyuan/pull/8012
|
||||||
export const registerServiceWorker = (scriptURL: string, scope = "/", workerType: WorkerType = "module") => {
|
export const registerServiceWorker = (
|
||||||
if (!("serviceWorker" in navigator) || typeof (navigator.serviceWorker) === "undefined" ||
|
scriptURL: string,
|
||||||
!("caches" in window) || !("fetch" in window)) {
|
options: RegistrationOptions = {
|
||||||
|
scope: "/",
|
||||||
|
type: "classic",
|
||||||
|
updateViaCache: "all",
|
||||||
|
},
|
||||||
|
) => {
|
||||||
|
|
||||||
|
if (!("serviceWorker" in window.navigator)
|
||||||
|
|| !("caches" in window)
|
||||||
|
|| !("fetch" in window)
|
||||||
|
|| navigator.serviceWorker == null
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// REF https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration
|
// REF https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration
|
||||||
window.navigator.serviceWorker
|
window.navigator.serviceWorker
|
||||||
.register(scriptURL, {
|
.register(scriptURL, options)
|
||||||
scope,
|
.then(registration => {
|
||||||
type: workerType,
|
registration.update();
|
||||||
}).then(registration => {
|
}).catch(e => {
|
||||||
registration.update();
|
console.debug(`Registration failed with ${e}`);
|
||||||
}).catch(e => {
|
});
|
||||||
console.debug(`Registration failed with ${e}`);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue