Compare commits

...

2 commits

Author SHA1 Message Date
TheThomaas 465ea168ad add type to mainWindow 2026-01-26 13:13:43 +01:00
TheThomaas 646aeddae8 Add splashscreen on app launch 2026-01-26 13:13:34 +01:00
2 changed files with 61 additions and 2 deletions

View file

@ -7,7 +7,23 @@ import { autoUpdater } from 'electron-updater'
autoUpdater.autoDownload = false; autoUpdater.autoDownload = false;
autoUpdater.autoInstallOnAppQuit = true; autoUpdater.autoInstallOnAppQuit = true;
let mainWindow; let mainWindow: BrowserWindow;
let splashWindow: BrowserWindow;
function createSplashWindow(): void {
splashWindow = new BrowserWindow({
width: 350,
height: 350,
transparent: true,
frame: false,
alwaysOnTop: true
});
splashWindow.loadFile('src/renderer/splash.html');
splashWindow.center();
splashWindow.setSkipTaskbar(true);
splashWindow.show();
}
function createWindow(): void { function createWindow(): void {
// Create the browser window. // Create the browser window.
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({
@ -22,8 +38,18 @@ function createWindow(): void {
} }
}) })
createSplashWindow();
mainWindow.on('ready-to-show', () => { mainWindow.on('ready-to-show', () => {
mainWindow.show() if (is.dev) {
setTimeout((): void => {
splashWindow.close();
mainWindow.show();
}, 2000);
} else {
splashWindow.close();
mainWindow.show();
}
}) })
mainWindow.webContents.setWindowOpenHandler((details) => { mainWindow.webContents.setWindowOpenHandler((details) => {

33
src/renderer/splash.html Normal file
View file

@ -0,0 +1,33 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>Splash</title>
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta
http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:"
/>
</head>
<body id="root">
<img alt="logo" class="logo" src='./src/assets/electron.svg' height="256px" width="256px" />
<style>
#root {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
margin: 0;
height: 350px;
width: 350px;
}
.logo {
-webkit-user-drag: none;
filter: drop-shadow(0 0 1.6em #6988e6aa);
}
</style>
</body>
</html>