From 5edab0ba1d42b6f45e36c65263d46951c472f18f Mon Sep 17 00:00:00 2001 From: imbytecat Date: Mon, 16 Feb 2026 04:28:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(desktop):=20=E6=81=A2=E5=A4=8D=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=8A=A0=E8=BD=BD=E9=A1=B5=E5=B9=B6=E5=9C=A8=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=B0=B1=E7=BB=AA=E5=90=8E=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/desktop/src/main/index.ts | 35 ++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.ts index c975b79..19da3f6 100644 --- a/apps/desktop/src/main/index.ts +++ b/apps/desktop/src/main/index.ts @@ -40,14 +40,18 @@ const canOpenExternally = (url: string): boolean => { } } -const createWindow = async () => { - if (mainWindow && !mainWindow.isDestroyed()) { - mainWindow.focus() +const loadSplash = async (windowRef: BrowserWindow) => { + if (process.env.ELECTRON_RENDERER_URL) { + await windowRef.loadURL(process.env.ELECTRON_RENDERER_URL) return } - const targetUrl = await sidecar.resolveUrl() - if (isQuitting) { + await windowRef.loadFile(join(__dirname, '../renderer/index.html')) +} + +const createWindow = async () => { + if (mainWindow && !mainWindow.isDestroyed()) { + mainWindow.focus() return } @@ -82,7 +86,7 @@ const createWindow = async () => { }) try { - await windowRef.loadURL(targetUrl) + await loadSplash(windowRef) } catch (error) { if (mainWindow === windowRef) { mainWindow = null @@ -98,6 +102,25 @@ const createWindow = async () => { if (!windowRef.isDestroyed()) { windowRef.show() } + + const targetUrl = await sidecar.resolveUrl() + if (isQuitting || windowRef.isDestroyed()) { + return + } + + try { + await windowRef.loadURL(targetUrl) + } catch (error) { + if (mainWindow === windowRef) { + mainWindow = null + } + + if (!windowRef.isDestroyed()) { + windowRef.destroy() + } + + throw error + } } const ensureWindow = async () => {