added splash loading screen
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user