From a1d9ce07151d77eb5c472cf7f09155d6f59de0b7 Mon Sep 17 00:00:00 2001 From: xiaokang Date: Tue, 13 Aug 2024 16:39:05 +0800 Subject: [PATCH] feat: add main window reject log --- src/main/windows/mainWeb/index.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/windows/mainWeb/index.ts b/src/main/windows/mainWeb/index.ts index 91a2c6946..cdc5ce1ca 100644 --- a/src/main/windows/mainWeb/index.ts +++ b/src/main/windows/mainWeb/index.ts @@ -14,8 +14,9 @@ * limitations under the License. */ -import { BrowserWindow } from 'electron'; +import { app, BrowserWindow, dialog } from 'electron'; import { PathnameStore } from '../../store'; +import log from '../../utils/log'; import { downloadEvent, newWindowEvent } from './event'; export function openMainWebWindow(mainWindow: BrowserWindow) { @@ -31,7 +32,14 @@ export function openMainWebWindow(mainWindow: BrowserWindow) { if (process.env.ODC_DEBUG_MODE === 'open' || process.env.NODE_ENV === 'development') { mainWindow!.webContents.openDevTools(); } - mainWindow!.loadURL(PathnameStore.getUrl()); + mainWindow!.loadURL(PathnameStore.getUrl()).catch((e) => { + log.error('loadURL error', e); + dialog.showErrorBox( + `Open ODC Window Failed`, + `Please submit the log to the administrator(${app.getPath('userData')}/logs)`, + ); + app.quit(); + }); PathnameStore.reset(); return mainWindow;