-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(electron): make apps work on electron 7 #2084
Changes from 3 commits
827b1c7
e12c221
71ecbeb
307503d
ea0654c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,7 @@ class CapacitorSplashScreen { | |
let capConfigJson = JSON.parse(fs.readFileSync(`./capacitor.config.json`, 'utf-8')); | ||
this.splashOptions = Object.assign( | ||
this.splashOptions, | ||
capConfigJson.plugins.SplashScreen | ||
capConfigJson.plugins.SplashScreen || {} | ||
); | ||
} catch (e) { | ||
console.error(e.message); | ||
|
@@ -100,11 +100,17 @@ class CapacitorSplashScreen { | |
frame: false, | ||
show: false, | ||
transparent: this.splashOptions.transparentWindow, | ||
webPreferences: { | ||
// Required to load file:// splash screen | ||
webSecurity: false | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I figure this is safe as long as we're only loading a splash screen. It might make more sense to base this value on whether or not the developer provided customHtml, which cannot be verified. |
||
}); | ||
|
||
let imagePath = path.join(rootPath,'splash_assets', this.splashOptions.imageFileName); | ||
walkingriver marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
let splashHtml = this.splashOptions.customHtml || ` | ||
<html style="width: 100%; height: 100%; margin: 0; overflow: hidden;"> | ||
<body style="background-image: url('./${this.splashOptions.imageFileName}'); background-position: center center; background-repeat: no-repeat; width: 100%; height: 100%; margin: 0; overflow: hidden;"> | ||
<body style="background-image: url('file://${imagePath}'); background-position: center center; background-repeat: no-repeat; width: 100%; height: 100%; margin: 0; overflow: hidden;"> | ||
<div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: ${this.splashOptions.textColor}; position: absolute; top: ${this.splashOptions.textPercentageFromTop}%; text-align: center; font-size: 10vw; width: 100vw;"> | ||
${this.splashOptions.loadingText} | ||
</div> | ||
|
@@ -118,7 +124,7 @@ class CapacitorSplashScreen { | |
} | ||
}); | ||
|
||
this.splashWindow.loadURL(`data:text/html;charset=UTF-8,${splashHtml}`, {baseURLForDataURL: `file://${rootPath}/splash_assets/`}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the response to Electron bug: electron/electron#20700 |
||
this.splashWindow.loadURL(`data:text/html;charset=UTF-8,${splashHtml}`); | ||
|
||
this.splashWindow.webContents.on('dom-ready', async () => { | ||
this.splashWindow.show(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removes the error if the developer has not provided the options in
capacitor.config.json
. This option should be documented better. Very useful.