Skip to content

Instantly share code, notes, and snippets.

@fritx
Created November 3, 2016 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fritx/346aba297b4218fd4c3e0a1a6a412885 to your computer and use it in GitHub Desktop.
Save fritx/346aba297b4218fd4c3e0a1a6a412885 to your computer and use it in GitHub Desktop.
// @private
function openWindow (key, opts = {}) {
const dontShow = opts.show === false
opts = Object.assign({
show: false,
resizable: false
}, opts)
opts.webPreferences = Object.assign({
nodeIntegration: false,
preload
}, opts.webPreferences)
const win = new BrowserWindow(opts)
wins[key] = win
win.loadURL(fileURL(key))
// win.webContents.on('did-finish-load', () => {
win.on('ready-to-show', () => { // >= 1.2.3
if (!dontShow) win.show()
})
win.on('closed', () => {
delete wins[key]
})
return win
}
function fileURL (key) {
const path = join(__dirname, `../window/${key}.html`)
return `file://${path}`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment