2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-11-11 07:41:04 +00:00

Support setting background color (fixes #795) (PR #819)

Adds a `--background-color` flag for the background of the window when the app isn't loaded.
This commit is contained in:
Umair Ahmed 2019-08-22 20:25:58 +01:00 committed by Ronan Jouchet
parent 5433569921
commit 81c422d4e0
5 changed files with 17 additions and 0 deletions

View File

@ -125,6 +125,7 @@ function createMainWindow(inpOptions, onAppQuit, setDockBadge) {
alwaysOnTop: options.alwaysOnTop, alwaysOnTop: options.alwaysOnTop,
titleBarStyle: options.titleBarStyle, titleBarStyle: options.titleBarStyle,
show: options.tray !== 'start-in-tray', show: options.tray !== 'start-in-tray',
backgroundColor: options.backgroundColor,
}, },
DEFAULT_WINDOW_OPTIONS, DEFAULT_WINDOW_OPTIONS,
), ),

View File

@ -65,6 +65,7 @@
- [[always-on-top]](#always-on-top) - [[always-on-top]](#always-on-top)
- [[global-shortcuts]](#global-shortcuts) - [[global-shortcuts]](#global-shortcuts)
- [[darwin-dark-mode-support]](#darwin-dark-mode-support) - [[darwin-dark-mode-support]](#darwin-dark-mode-support)
- [[background-color]](#background-color)
- [Programmatic API](#programmatic-api) - [Programmatic API](#programmatic-api)
- [Addition packaging options for Windows](#addition-packaging-options-for-windows) - [Addition packaging options for Windows](#addition-packaging-options-for-windows)
- [[version-string]](#version-string) - [[version-string]](#version-string)
@ -703,6 +704,14 @@ Example `shortcuts.json` for `https://deezer.com` & `https://soundcloud.com` to
Enables Dark Mode support on macOS 10.4+. Enables Dark Mode support on macOS 10.4+.
#### [background-color]
```
--background-color
```
See https://electronjs.org/docs/api/browser-window#setting-backgroundcolor
## Programmatic API ## Programmatic API
You can use the Nativefier programmatic API as well. You can use the Nativefier programmatic API as well.

View File

@ -58,6 +58,7 @@ function selectAppArgs(options) {
alwaysOnTop: options.alwaysOnTop, alwaysOnTop: options.alwaysOnTop,
titleBarStyle: options.titleBarStyle, titleBarStyle: options.titleBarStyle,
globalShortcuts: options.globalShortcuts, globalShortcuts: options.globalShortcuts,
backgroundColor: options.backgroundColor,
darwinDarkModeSupport: options.darwinDarkModeSupport, darwinDarkModeSupport: options.darwinDarkModeSupport,
}; };
} }
@ -134,6 +135,7 @@ function changeAppPackageJsonName(appPath, name, url) {
*/ */
function buildApp(src, dest, options, callback) { function buildApp(src, dest, options, callback) {
const appArgs = selectAppArgs(options); const appArgs = selectAppArgs(options);
copy(src, dest, (error) => { copy(src, dest, (error) => {
if (error) { if (error) {
callback(`Error Copying temporary directory: ${error}`); callback(`Error Copying temporary directory: ${error}`);

View File

@ -238,6 +238,10 @@ if (require.main === module) {
'--global-shortcuts <value>', '--global-shortcuts <value>',
'JSON file with global shortcut configuration. See https://github.com/jiahaog/nativefier/blob/master/docs/api.md#global-shortcuts', 'JSON file with global shortcut configuration. See https://github.com/jiahaog/nativefier/blob/master/docs/api.md#global-shortcuts',
) )
.option(
'--background-color <value>',
"Sets the background color (for seamless experience while the app is loading). Example value: '#2e2c29'",
)
.option( .option(
'--darwin-dark-mode-support', '--darwin-dark-mode-support',
'(macOS only) enable Dark Mode support on macOS 10.14+', '(macOS only) enable Dark Mode support on macOS 10.14+',

View File

@ -77,6 +77,7 @@ export default function(inpOptions) {
alwaysOnTop: inpOptions.alwaysOnTop || false, alwaysOnTop: inpOptions.alwaysOnTop || false,
titleBarStyle: inpOptions.titleBarStyle || null, titleBarStyle: inpOptions.titleBarStyle || null,
globalShortcuts: inpOptions.globalShortcuts || null, globalShortcuts: inpOptions.globalShortcuts || null,
backgroundColor: inpOptions.backgroundColor || null,
darwinDarkModeSupport: inpOptions.darwinDarkModeSupport || false, darwinDarkModeSupport: inpOptions.darwinDarkModeSupport || false,
}; };