Vanessa 2025-01-26 09:38:32 +08:00
parent 25054e137c
commit 5143121ac4
5 changed files with 15 additions and 10 deletions

View file

@ -106,7 +106,7 @@ html {
&--browser { &--browser {
padding-left: env(titlebar-area-x, 0); padding-left: env(titlebar-area-x, 0);
padding-right: calc(100% - env(titlebar-area-width, 100%) - env(titlebar-area-x, 0)); padding-right: calc(100% - env(titlebar-area-width, 100%) - env(titlebar-area-x, 0));
height: env(titlebar-area-height, 32px); height: calc(env(titlebar-area-height, 31px) + 1px);
} }
#windowControls { #windowControls {

View file

@ -37,9 +37,7 @@ export class App {
public appId: string; public appId: string;
constructor() { constructor() {
/// #if BROWSER
registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`); registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`);
/// #endif
addBaseURL(); addBaseURL();
this.appId = Constants.SIYUAN_APPID; this.appId = Constants.SIYUAN_APPID;

View file

@ -34,9 +34,7 @@ class App {
public appId: string; public appId: string;
constructor() { constructor() {
if (!window.webkit?.messageHandlers && !window.JSAndroid && !window.JSHarmony) { registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`);
registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`);
}
addBaseURL(); addBaseURL();
this.appId = Constants.SIYUAN_APPID; this.appId = Constants.SIYUAN_APPID;
window.siyuan = { window.siyuan = {

View file

@ -78,6 +78,13 @@ export const loadAssets = (data: Config.IAppearance) => {
} }
}); });
/// #endif /// #endif
/// #if BROWSER
if (!window.webkit?.messageHandlers && !window.JSAndroid && !window.JSHarmony &&
("serviceWorker" in window.navigator) && ("caches" in window) && ("fetch" in window) && navigator.serviceWorker) {
document.head.insertAdjacentHTML("afterbegin", `<meta name="theme-color" content="${getComputedStyle(document.body).getPropertyValue("--b3-toolbar-background").trim()}">`)
}
/// #endif
setCodeTheme(); setCodeTheme();
const themeScriptElement = document.getElementById("themeScript"); const themeScriptElement = document.getElementById("themeScript");

View file

@ -7,8 +7,9 @@ export const registerServiceWorker = (
updateViaCache: "all", updateViaCache: "all",
}, },
) => { ) => {
/// #if BROWSER
if (!("serviceWorker" in window.navigator) if (window.webkit?.messageHandlers || window.JSAndroid || window.JSHarmony ||
!("serviceWorker" in window.navigator)
|| !("caches" in window) || !("caches" in window)
|| !("fetch" in window) || !("fetch" in window)
|| navigator.serviceWorker == null || navigator.serviceWorker == null
@ -22,6 +23,7 @@ export const registerServiceWorker = (
.then(registration => { .then(registration => {
registration.update(); registration.update();
}).catch(e => { }).catch(e => {
console.debug(`Registration failed with ${e}`); console.debug(`Registration failed with ${e}`);
}); });
/// #endif
}; };