Carve out open url action
This commit is contained in:
parent
ee18182915
commit
df9207dfcf
|
@ -1,13 +1,13 @@
|
|||
'use strict'
|
||||
|
||||
import { pick } from 'lodash'
|
||||
|
||||
import {
|
||||
app,
|
||||
ipcMain,
|
||||
protocol,
|
||||
Event,
|
||||
} from 'electron'
|
||||
|
||||
import ContextMenu from 'electron-context-menu'
|
||||
|
||||
import Application from './main/Application'
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import {
|
||||
app,
|
||||
shell,
|
||||
Menu,
|
||||
} from 'electron'
|
||||
import {
|
||||
createProtocol,
|
||||
installVueDevtools,
|
||||
} from 'vue-cli-plugin-electron-builder/lib'
|
||||
|
||||
import Window from './Window'
|
||||
|
||||
const isDevelopment = process.env.NODE_ENV !== 'production'
|
||||
|
@ -52,4 +54,12 @@ export default class Application {
|
|||
Window.Main()
|
||||
}
|
||||
}
|
||||
|
||||
public static openUrl(event: Event, url: string) {
|
||||
shell.openExternal(url, {
|
||||
activate: false
|
||||
}, (err) => {
|
||||
if (err) console.log(err)
|
||||
})
|
||||
}
|
||||
}
|
|
@ -4,7 +4,9 @@ import {
|
|||
Menu,
|
||||
MenuItemConstructorOptions
|
||||
} from 'electron'
|
||||
|
||||
import Window from './Window'
|
||||
|
||||
import { bugs } from '../../package.json'
|
||||
import { documentURL } from '../../info.json'
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import { join } from 'path'
|
||||
|
||||
import {
|
||||
shell,
|
||||
BrowserWindow,
|
||||
BrowserWindowConstructorOptions,
|
||||
Event,
|
||||
Input,
|
||||
app,
|
||||
} from 'electron'
|
||||
import { register as shortcutRegister } from 'electron-localshortcut'
|
||||
|
||||
import Application from './Application'
|
||||
|
||||
declare const __static: string
|
||||
const isDevelopment = process.env.NODE_ENV !== 'production'
|
||||
|
||||
|
@ -91,15 +91,11 @@ export default class Window {
|
|||
})
|
||||
|
||||
let openUrl = (event: Event, url: string) => {
|
||||
if (url === this.ApplicationURL + options.loadPath) {
|
||||
if (url.startsWith(this.ApplicationURL)) {
|
||||
return
|
||||
}
|
||||
event.preventDefault()
|
||||
shell.openExternal(url, {
|
||||
activate: false
|
||||
}, (err) => {
|
||||
if (err) console.log(err)
|
||||
})
|
||||
Application.openUrl(event, url)
|
||||
}
|
||||
win.webContents.on('will-navigate', openUrl)
|
||||
win.webContents.on('new-window', openUrl)
|
||||
|
|
Loading…
Reference in New Issue
Block a user