|
|
@ -162,11 +162,23 @@ function createWindow () { |
|
|
|
|
|
|
|
|
|
|
|
// Open links in default browser
|
|
|
|
// Open links in default browser
|
|
|
|
mainWindow.webContents.on('new-window', function(e, url, frameName, disposition, options) { |
|
|
|
mainWindow.webContents.on('new-window', function(e, url, frameName, disposition, options) { |
|
|
|
if ( disposition !== 'foreground-tab' ) return; |
|
|
|
|
|
|
|
const protocol = require('url').parse(url).protocol; |
|
|
|
const protocol = require('url').parse(url).protocol; |
|
|
|
if (protocol === 'http:' || protocol === 'https:' || protocol === 'mailto:') { |
|
|
|
switch ( disposition ) { |
|
|
|
e.preventDefault(); |
|
|
|
case 'new-window': |
|
|
|
shell.openExternal(url); |
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
const win = new BrowserWindow(options); |
|
|
|
|
|
|
|
win.once('ready-to-show', () => win.show()); |
|
|
|
|
|
|
|
win.loadURL(url); |
|
|
|
|
|
|
|
e.newGuest = win; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'foreground-tab': |
|
|
|
|
|
|
|
if (protocol === 'http:' || protocol === 'https:' || protocol === 'mailto:') { |
|
|
|
|
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
shell.openExternal(url); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|