electron/default_app/default_app.js
Samuel Attard 0d2a0c7583 feat: add APIs to support mojave dark modes (#14755)
* feat: add APIs to support mojave dark mode

Closes #13387

* docs: fix system-prefs typo
2018-09-27 10:33:31 -05:00

43 lines
951 B
JavaScript

const { app, BrowserWindow, systemPreferences } = require('electron')
const path = require('path')
let mainWindow = null
// Quit when all windows are closed.
app.on('window-all-closed', () => {
app.quit()
})
exports.load = async (appUrl) => {
await app.whenReady()
if (process.platform === 'darwin') {
systemPreferences.startAppLevelAppearanceTrackingOS()
}
const options = {
width: 900,
height: 600,
autoHideMenuBar: true,
backgroundColor: '#FFFFFF',
webPreferences: {
contextIsolation: true,
nodeIntegration: false,
preload: path.resolve(__dirname, 'renderer.js'),
webviewTag: false
},
useContentSize: true,
show: false
}
if (process.platform === 'linux') {
options.icon = path.join(__dirname, 'icon.png')
}
mainWindow = new BrowserWindow(options)
mainWindow.on('ready-to-show', () => mainWindow.show())
mainWindow.loadURL(appUrl)
mainWindow.focus()
}