Change to open links in default browser
This commit is contained in:
parent
77acfb47b3
commit
d3a11b0e4c
|
@ -40,7 +40,6 @@ protocol.registerStandardSchemes(['app'], { secure: true })
|
|||
async function createWindow(windowName, loadPath, windowOptions, singleton, lastAction, openDevTools) {
|
||||
if (typeof windows[windowName] !== 'undefined') {
|
||||
windows[windowName].show()
|
||||
windows[windowName].focus()
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -60,10 +59,23 @@ async function createWindow(windowName, loadPath, windowOptions, singleton, last
|
|||
windows[windowName] = undefined
|
||||
})
|
||||
|
||||
let openUrl = (event, url) => {
|
||||
if (url === process.env.WEBPACK_DEV_SERVER_URL + loadPath) {
|
||||
return
|
||||
}
|
||||
event.preventDefault()
|
||||
shell.openExternal(url, {
|
||||
activate: false
|
||||
}, (err) => {
|
||||
if (err) console.log(err)
|
||||
})
|
||||
}
|
||||
win.webContents.on('will-navigate', openUrl)
|
||||
win.webContents.on('new-window', openUrl)
|
||||
|
||||
if (process.env.WEBPACK_DEV_SERVER_URL) {
|
||||
// `electron:serve`で起動した時の読み込み
|
||||
win.loadURL(process.env.WEBPACK_DEV_SERVER_URL + loadPath)
|
||||
if (openDevTools) win.webContents.openDevTools()
|
||||
} else {
|
||||
// ビルドしたアプリでの読み込み
|
||||
if (!createdAppProtocol) {
|
||||
|
@ -73,6 +85,8 @@ async function createWindow(windowName, loadPath, windowOptions, singleton, last
|
|||
win.loadURL(`app://./${loadPath}`)
|
||||
}
|
||||
|
||||
if (isDevelopment && openDevTools) win.webContents.openDevTools()
|
||||
|
||||
lastAction(win)
|
||||
|
||||
windows[windowName] = win
|
||||
|
|
Loading…
Reference in New Issue
Block a user