chore(monorepo/electron): add extra dependencies

This commit is contained in:
Elian Doran
2025-04-18 23:54:05 +03:00
parent dd07663183
commit acc7729891
5 changed files with 241 additions and 4 deletions

View File

@@ -20,5 +20,10 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"electron-debug": "4.1.0",
"electron-dl": "4.0.0",
"electron-squirrel-startup": "1.0.1"
}
}

View File

@@ -0,0 +1,4 @@
import { initializeTranslations } from "./src/services/i18n.js";
await initializeTranslations();
await import("./electron.js");

View File

@@ -0,0 +1,67 @@
"use strict";
import electron from "electron";
import electronDebug from "electron-debug";
import electronDl from "electron-dl";
import sqlInit from "./src/services/sql_init.js";
import windowService from "./src/services/window.js";
import tray from "./src/services/tray.js";
import options from "./src/services/options.js";
// Prevent Trilium starting twice on first install and on uninstall for the Windows installer.
if ((await import("electron-squirrel-startup")).default) {
process.exit(0);
}
// Adds debug features like hotkeys for triggering dev tools and reload
electronDebug();
electronDl({ saveAs: true });
// needed for excalidraw export https://github.com/zadam/trilium/issues/4271
electron.app.commandLine.appendSwitch("enable-experimental-web-platform-features");
electron.app.commandLine.appendSwitch("lang", options.getOptionOrNull("formattingLocale") ?? "en");
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
electron.app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
electron.app.quit();
}
});
electron.app.on("ready", async () => {
// electron.app.setAppUserModelId('com.github.zadam.trilium');
// if db is not initialized -> setup process
// if db is initialized, then we need to wait until the migration process is finished
if (sqlInit.isDbInitialized()) {
await sqlInit.dbReady;
await windowService.createMainWindow(electron.app);
if (process.platform === "darwin") {
electron.app.on("activate", async () => {
if (electron.BrowserWindow.getAllWindows().length === 0) {
await windowService.createMainWindow(electron.app);
}
});
}
tray.createTray();
} else {
await windowService.createSetupWindow();
}
await windowService.registerGlobalShortcuts();
});
electron.app.on("will-quit", () => {
electron.globalShortcut.unregisterAll();
});
// this is to disable electron warning spam in the dev console (local development only)
process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true";
await import("./src/main.js");