mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 02:02:29 +08:00
fix(electron): fix regression when native title bar is on
This commit is contained in:
parent
9e0546da27
commit
28b27f04cd
@ -8,6 +8,7 @@ import macInit from './services/mac_init.js';
|
|||||||
import electronContextMenu from "./menus/electron_context_menu.js";
|
import electronContextMenu from "./menus/electron_context_menu.js";
|
||||||
import glob from "./services/glob.js";
|
import glob from "./services/glob.js";
|
||||||
import { t } from "./services/i18n.js";
|
import { t } from "./services/i18n.js";
|
||||||
|
import options from "./services/options.js";
|
||||||
|
|
||||||
await appContext.earlyInit();
|
await appContext.earlyInit();
|
||||||
|
|
||||||
@ -47,6 +48,21 @@ function initOnElectron() {
|
|||||||
const electron = utils.dynamicRequire('electron');
|
const electron = utils.dynamicRequire('electron');
|
||||||
electron.ipcRenderer.on('globalShortcut', async (event, actionName) => appContext.triggerCommand(actionName));
|
electron.ipcRenderer.on('globalShortcut', async (event, actionName) => appContext.triggerCommand(actionName));
|
||||||
|
|
||||||
|
if (options.get("nativeTitleBarVisible") !== "true") {
|
||||||
|
initTitleBarButtons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function initTitleBarButtons() {
|
||||||
|
function applyTitleBarOverlaySettings() {
|
||||||
|
const electronRemote = utils.dynamicRequire("@electron/remote");
|
||||||
|
const currentWindow = electronRemote.getCurrentWindow();
|
||||||
|
const documentStyle = window.getComputedStyle(document.documentElement);
|
||||||
|
const color = documentStyle.getPropertyValue("--native-titlebar-background");
|
||||||
|
const symbolColor = documentStyle.getPropertyValue("--native-titlebar-foreground");
|
||||||
|
currentWindow.setTitleBarOverlay({ color, symbolColor });
|
||||||
|
}
|
||||||
|
|
||||||
// Update the native title bar buttons.
|
// Update the native title bar buttons.
|
||||||
applyTitleBarOverlaySettings();
|
applyTitleBarOverlaySettings();
|
||||||
|
|
||||||
@ -54,12 +70,3 @@ function initOnElectron() {
|
|||||||
window.matchMedia("(prefers-color-scheme: dark)")
|
window.matchMedia("(prefers-color-scheme: dark)")
|
||||||
.addEventListener("change", applyTitleBarOverlaySettings);
|
.addEventListener("change", applyTitleBarOverlaySettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyTitleBarOverlaySettings() {
|
|
||||||
const electronRemote = utils.dynamicRequire("@electron/remote");
|
|
||||||
const currentWindow = electronRemote.getCurrentWindow();
|
|
||||||
const documentStyle = window.getComputedStyle(document.documentElement);
|
|
||||||
const color = documentStyle.getPropertyValue("--native-titlebar-background");
|
|
||||||
const symbolColor = documentStyle.getPropertyValue("--native-titlebar-foreground");
|
|
||||||
currentWindow.setTitleBarOverlay({ color, symbolColor });
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user