diff --git a/desktop/loading.html b/desktop/loading.html new file mode 100644 index 0000000..87967c9 --- /dev/null +++ b/desktop/loading.html @@ -0,0 +1,229 @@ + + + + + + Waifuboard + + + + +
+
+
+
+ +
+
+ Waifuboard Logo +

Waifuboard

+
+ +
+
+ Loading +
+
+ + + \ No newline at end of file diff --git a/desktop/main.js b/desktop/main.js index 12accf0..1f8ff1e 100644 --- a/desktop/main.js +++ b/desktop/main.js @@ -3,6 +3,9 @@ const { fork } = require('child_process'); const path = require('path'); const log = require('electron-log'); +const sessionId = new Date().toISOString().replace(/[:.]/g, '-'); +log.transports.file.resolvePath = () => path.join(app.getPath('userData'), 'logs', `${sessionId}.log`); + log.transports.file.level = 'info'; log.format = '[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}] {text}'; @@ -61,6 +64,23 @@ function startBackend() { }); } +let splash; + +function createSplash() { + splash = new BrowserWindow({ + width: 400, + height: 300, + frame: false, + transparent: false, + alwaysOnTop: true, + resizable: false, + hasShadow: false, + backgroundColor: '#00000000' + }); + + splash.loadFile('loading.html'); +} + function createWindow() { win = new BrowserWindow({ width: 1200, @@ -75,6 +95,7 @@ function createWindow() { }); win.setMenu(null); + win.maximize(); win.loadURL('http://localhost:54322'); @@ -98,15 +119,17 @@ process.on('uncaughtException', (err) => { }); app.whenReady().then(async () => { - log.info('--- Application Started ---'); - console.log("Logs location:", log.transports.file.getFile().path); startBackend(); - await waitForServer(54322); - createWindow(); - - app.on('activate', () => { - if (BrowserWindow.getAllWindows().length === 0) createWindow(); - }); + createSplash(); + try { + await waitForServer(54322); + createWindow(); + splash.close(); + } catch (e) { + splash.close(); + log.error(e); + app.quit(); + } }); app.on('window-all-closed', () => {