Created
November 3, 2016 03:01
-
-
Save fritx/346aba297b4218fd4c3e0a1a6a412885 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @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