Skip to content

Commit 0a80367

Browse files
authored
Merge pull request #822 from NickRimmer/features/splash-size
Configurable splash screen size
2 parents 3476145 + 94dc82e commit 0a80367

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

src/ElectronNET.Host/main.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,10 @@ function isSplashScreenEnabled() {
115115

116116
function startSplashScreen() {
117117
let imageFile = path.join(currentBinPath, manifestJsonFile.splashscreen.imageFile);
118-
imageSize(imageFile, (error, dimensions) => {
119-
if (error) {
120-
console.log(`load splashscreen error:`);
121-
console.error(error);
122-
123-
throw new Error(error.message);
124-
}
125-
118+
const startWindow = (width, height) => {
126119
splashScreen = new BrowserWindow({
127-
width: dimensions.width,
128-
height: dimensions.height,
120+
width: width,
121+
height: height,
129122
transparent: true,
130123
center: true,
131124
frame: false,
@@ -143,10 +136,25 @@ function startSplashScreen() {
143136

144137
const loadSplashscreenUrl = path.join(__dirname, 'splashscreen', 'index.html') + '?imgPath=' + imageFile;
145138
splashScreen.loadURL('file://' + loadSplashscreenUrl);
146-
147139
splashScreen.once('closed', () => {
148140
splashScreen = null;
149141
});
142+
}
143+
144+
if (manifestJsonFile.splashscreen.width && manifestJsonFile.splashscreen.height) {
145+
startWindow(manifestJsonFile.splashscreen.width, manifestJsonFile.splashscreen.height);
146+
return;
147+
}
148+
149+
imageSize(imageFile, (error, dimensions) => {
150+
if (error) {
151+
console.log(`load splashscreen error:`);
152+
console.error(error);
153+
154+
throw new Error(error.message);
155+
}
156+
157+
startWindow(dimensions.width, dimensions.height)
150158
});
151159
}
152160

0 commit comments

Comments
 (0)