mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
fix(desktop): blank screen when starting (closes #2103)
This commit is contained in:
parent
5fc8100c5d
commit
1818ae1f72
@ -7,8 +7,11 @@ import tray from "@triliumnext/server/src/services/tray.js";
|
||||
import options from "@triliumnext/server/src/services/options.js";
|
||||
import electronDebug from "electron-debug";
|
||||
import electronDl from "electron-dl";
|
||||
import { deferred } from "@triliumnext/server/src/services/utils.js";
|
||||
|
||||
async function main() {
|
||||
const serverInitializedPromise = deferred<void>();
|
||||
|
||||
// Prevent Trilium starting twice on first install and on uninstall for the Windows installer.
|
||||
if ((require("electron-squirrel-startup")).default) {
|
||||
process.exit(0);
|
||||
@ -37,7 +40,11 @@ async function main() {
|
||||
}
|
||||
});
|
||||
|
||||
electron.app.on("ready", onReady);
|
||||
electron.app.on("ready", async () => {
|
||||
await serverInitializedPromise;
|
||||
console.log("Starting Electron...");
|
||||
await onReady();
|
||||
});
|
||||
|
||||
electron.app.on("will-quit", () => {
|
||||
electron.globalShortcut.unregisterAll();
|
||||
@ -47,7 +54,10 @@ async function main() {
|
||||
process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true";
|
||||
|
||||
await initializeTranslations();
|
||||
await import("@triliumnext/server/src/main.js");
|
||||
const startTriliumServer = (await import("@triliumnext/server/src/www.js")).default;
|
||||
await startTriliumServer();
|
||||
console.log("Server loaded");
|
||||
serverInitializedPromise.resolve();
|
||||
}
|
||||
|
||||
async function onReady() {
|
||||
|
@ -38,7 +38,8 @@ export function startElectron(callback: () => void): DeferredPromise<void> {
|
||||
console.log("Electron is ready!");
|
||||
|
||||
// Start the server.
|
||||
await import("@triliumnext/server/src/main.js");
|
||||
const startTriliumServer = (await import("@triliumnext/server/src/www.js")).default;
|
||||
await startTriliumServer();
|
||||
|
||||
// Create the main window.
|
||||
await windowService.createMainWindow(electron.app);
|
||||
|
@ -7,7 +7,8 @@ import { initializeTranslations } from "./services/i18n.js";
|
||||
|
||||
async function startApplication() {
|
||||
await initializeTranslations();
|
||||
await import("./www.js");
|
||||
const startTriliumServer = (await import("./www.js")).default;
|
||||
await startTriliumServer();
|
||||
}
|
||||
|
||||
startApplication();
|
||||
|
@ -14,37 +14,35 @@ import type { Express } from "express";
|
||||
|
||||
const MINIMUM_NODE_VERSION = "20.0.0";
|
||||
|
||||
// setup basic error handling even before requiring dependencies, since those can produce errors as well
|
||||
|
||||
process.on("unhandledRejection", (error: Error) => {
|
||||
export default async function startTriliumServer() {
|
||||
// setup basic error handling even before requiring dependencies, since those can produce errors as well
|
||||
process.on("unhandledRejection", (error: Error) => {
|
||||
// this makes sure that stacktrace of failed promise is printed out
|
||||
console.log(error);
|
||||
|
||||
// but also try to log it into file
|
||||
log.info(error);
|
||||
});
|
||||
});
|
||||
|
||||
function exit() {
|
||||
function exit() {
|
||||
console.log("Caught interrupt/termination signal. Exiting.");
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
process.on("SIGINT", exit);
|
||||
process.on("SIGTERM", exit);
|
||||
process.on("SIGINT", exit);
|
||||
process.on("SIGTERM", exit);
|
||||
|
||||
if (utils.compareVersions(process.versions.node, MINIMUM_NODE_VERSION) < 0) {
|
||||
if (utils.compareVersions(process.versions.node, MINIMUM_NODE_VERSION) < 0) {
|
||||
console.error();
|
||||
console.error(`The Trilium server requires Node.js ${MINIMUM_NODE_VERSION} and later in order to start.\n`);
|
||||
console.error(`\tCurrent version:\t${process.versions.node}`);
|
||||
console.error(`\tExpected version:\t${MINIMUM_NODE_VERSION}`);
|
||||
console.error();
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
tmp.setGracefulCleanup();
|
||||
startTrilium();
|
||||
tmp.setGracefulCleanup();
|
||||
|
||||
async function startTrilium() {
|
||||
const app = await buildApp();
|
||||
|
||||
/**
|
||||
@ -98,7 +96,7 @@ function startHttpServer(app: Express) {
|
||||
|
||||
log.info(`Trusted reverse proxy: ${app.get("trust proxy")}`);
|
||||
|
||||
let httpServer;
|
||||
let httpServer: http.Server | https.Server;
|
||||
|
||||
if (config["Network"]["https"]) {
|
||||
if (!config["Network"]["keyPath"] || !config["Network"]["keyPath"].trim().length) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user