From c65a89ed6fe43de0c675feecfea36d0da49eb0dc Mon Sep 17 00:00:00 2001 From: root Date: Sat, 13 Dec 2025 14:10:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E7=AD=89=E5=BE=85=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/renderer/main/main.js | 31 +++++++++++--- .../src/renderer/main/resources/loading.html | 40 +++++++++++++++++++ 2 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 frontend/src/renderer/main/resources/loading.html diff --git a/frontend/src/renderer/main/main.js b/frontend/src/renderer/main/main.js index bbc27f24..40af771f 100644 --- a/frontend/src/renderer/main/main.js +++ b/frontend/src/renderer/main/main.js @@ -7,6 +7,7 @@ const { spawn } = require('child_process'); let mainWindow; let localServer; let backendProcess; +let splashWindow; // app.disableHardwareAcceleration(); app.disableDomainBlockingFor3DAPIs(); console.log('Electron version:', process.versions.electron); @@ -187,6 +188,16 @@ function stopBackendService() { } function createWindow() { + splashWindow = new BrowserWindow({ + width: 480, + height: 320, + frame: false, + resizable: false, + alwaysOnTop: true, + backgroundColor: '#000000', + show: true + }); + splashWindow.loadFile(path.join(__dirname, 'resources/loading.html')); mainWindow = new BrowserWindow({ width: 1920, height: 1080, @@ -224,21 +235,25 @@ function createWindow() { }, 2000); } - // 窗口就绪后再显示,避免白屏/闪烁 - mainWindow.once('ready-to-show', () => { - mainWindow.show(); - }); - // 监听页面加载完成事件 mainWindow.webContents.once('did-finish-load', () => { console.log('Page loaded completely'); + if (splashWindow) { + splashWindow.close(); + splashWindow = null; + } + mainWindow.show(); }); - + // 添加加载失败的处理 mainWindow.webContents.on('did-fail-load', (event, errorCode, errorDescription, validatedURL) => { console.log('Failed to load:', errorDescription, 'URL:', validatedURL); + if (splashWindow) { + splashWindow.close(); + splashWindow = null; + } mainWindow.show(); // 即使加载失败也显示窗口 }); @@ -249,6 +264,10 @@ function createWindow() { } // 关闭后端服务 stopBackendService(); + if (splashWindow) { + splashWindow.close(); + splashWindow = null; + } }); } diff --git a/frontend/src/renderer/main/resources/loading.html b/frontend/src/renderer/main/resources/loading.html new file mode 100644 index 00000000..68ec8211 --- /dev/null +++ b/frontend/src/renderer/main/resources/loading.html @@ -0,0 +1,40 @@ + + + + + + + Loading + + + +
+
+
系统启动中...
+
+ +