mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 04:51:31 +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 options from "@triliumnext/server/src/services/options.js"; | ||||||
| import electronDebug from "electron-debug"; | import electronDebug from "electron-debug"; | ||||||
| import electronDl from "electron-dl"; | import electronDl from "electron-dl"; | ||||||
|  | import { deferred } from "@triliumnext/server/src/services/utils.js"; | ||||||
| 
 | 
 | ||||||
| async function main() { | async function main() { | ||||||
|  |     const serverInitializedPromise = deferred<void>(); | ||||||
|  | 
 | ||||||
|     // Prevent Trilium starting twice on first install and on uninstall for the Windows installer.
 |     // Prevent Trilium starting twice on first install and on uninstall for the Windows installer.
 | ||||||
|     if ((require("electron-squirrel-startup")).default) { |     if ((require("electron-squirrel-startup")).default) { | ||||||
|         process.exit(0); |         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.app.on("will-quit", () => { | ||||||
|         electron.globalShortcut.unregisterAll(); |         electron.globalShortcut.unregisterAll(); | ||||||
| @ -47,7 +54,10 @@ async function main() { | |||||||
|     process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true"; |     process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true"; | ||||||
| 
 | 
 | ||||||
|     await initializeTranslations(); |     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() { | async function onReady() { | ||||||
|  | |||||||
| @ -38,7 +38,8 @@ export function startElectron(callback: () => void): DeferredPromise<void> { | |||||||
|         console.log("Electron is ready!"); |         console.log("Electron is ready!"); | ||||||
| 
 | 
 | ||||||
|         // Start the server.
 |         // 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.
 |         // Create the main window.
 | ||||||
|         await windowService.createMainWindow(electron.app); |         await windowService.createMainWindow(electron.app); | ||||||
|  | |||||||
| @ -7,7 +7,8 @@ import { initializeTranslations } from "./services/i18n.js"; | |||||||
| 
 | 
 | ||||||
| async function startApplication() { | async function startApplication() { | ||||||
|     await initializeTranslations(); |     await initializeTranslations(); | ||||||
|     await import("./www.js"); |     const startTriliumServer = (await import("./www.js")).default; | ||||||
|  |     await startTriliumServer(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| startApplication(); | startApplication(); | ||||||
|  | |||||||
| @ -14,8 +14,8 @@ import type { Express } from "express"; | |||||||
| 
 | 
 | ||||||
| const MINIMUM_NODE_VERSION = "20.0.0"; | const MINIMUM_NODE_VERSION = "20.0.0"; | ||||||
| 
 | 
 | ||||||
|  | export default async function startTriliumServer() { | ||||||
|     // setup basic error handling even before requiring dependencies, since those can produce errors as well
 |     // setup basic error handling even before requiring dependencies, since those can produce errors as well
 | ||||||
| 
 |  | ||||||
|     process.on("unhandledRejection", (error: Error) => { |     process.on("unhandledRejection", (error: Error) => { | ||||||
|         // this makes sure that stacktrace of failed promise is printed out
 |         // this makes sure that stacktrace of failed promise is printed out
 | ||||||
|         console.log(error); |         console.log(error); | ||||||
| @ -42,9 +42,7 @@ if (utils.compareVersions(process.versions.node, MINIMUM_NODE_VERSION) < 0) { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     tmp.setGracefulCleanup(); |     tmp.setGracefulCleanup(); | ||||||
| startTrilium(); |  | ||||||
| 
 | 
 | ||||||
| async function startTrilium() { |  | ||||||
|     const app = await buildApp(); |     const app = await buildApp(); | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -98,7 +96,7 @@ function startHttpServer(app: Express) { | |||||||
| 
 | 
 | ||||||
|     log.info(`Trusted reverse proxy: ${app.get("trust proxy")}`); |     log.info(`Trusted reverse proxy: ${app.get("trust proxy")}`); | ||||||
| 
 | 
 | ||||||
|     let httpServer; |     let httpServer: http.Server | https.Server; | ||||||
| 
 | 
 | ||||||
|     if (config["Network"]["https"]) { |     if (config["Network"]["https"]) { | ||||||
|         if (!config["Network"]["keyPath"] || !config["Network"]["keyPath"].trim().length) { |         if (!config["Network"]["keyPath"] || !config["Network"]["keyPath"].trim().length) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran