made sure all windows run with the same web preferences set

This commit is contained in:
2023-08-14 21:26:09 +02:00
parent 239139e674
commit 40d80e0872
4 changed files with 28 additions and 13 deletions

View File

@@ -31,10 +31,14 @@ import { addTray, refreshTray } from "./scripts/tray";
const tidalUrl = "https://listen.tidal.com";
initialize();
let mainWindow: BrowserWindow;
const icon = path.join(__dirname, "../assets/icon.png");
const PROTOCOL_PREFIX = "tidal";
const windowPreferences = {
sandbox: false,
plugins: true,
devTools: true, // I like tinkering, others might too
};
setDefaultFlags(app);
setManagedFlagsFromSettings(app);
@@ -78,10 +82,10 @@ function createWindow(options = { x: 0, y: 0, backgroundColor: "white" }) {
backgroundColor: options.backgroundColor,
autoHideMenuBar: true,
webPreferences: {
sandbox: false,
preload: path.join(__dirname, "preload.js"),
plugins: true,
devTools: true, // I like tinkering, others might too
...windowPreferences,
...{
preload: path.join(__dirname, "preload.js"),
},
},
});
enable(mainWindow.webContents);
@@ -113,6 +117,18 @@ function createWindow(options = { x: 0, y: 0, backgroundColor: "white" }) {
const { width, height } = mainWindow.getBounds();
settingsStore.set(settings.windowBounds.root, { width, height });
});
mainWindow.webContents.setWindowOpenHandler(() => {
return {
action: "allow",
overrideBrowserWindowOptions: {
webPreferences: {
sandbox: false,
plugins: true,
devTools: true, // I like tinkering, others might too
},
},
};
});
}
function registerHttpProtocols() {