mirror of
https://github.com/BoostIO/BoostNote-App.git
synced 2024-10-05 00:27:56 +03:00
Implement openNew for electron
This commit is contained in:
parent
0cfd800ddf
commit
799eab51b4
10
index.html
10
index.html
@ -33,5 +33,15 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script>
|
||||
;(function() {
|
||||
const electron = require('electron')
|
||||
function $openExternal(url) {
|
||||
console.log('opening ...', url)
|
||||
electron.shell.openExternal(url)
|
||||
}
|
||||
window.$openExternal = $openExterna
|
||||
})()
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,8 +1,12 @@
|
||||
export const isElectron = () => navigator.userAgent.indexOf('Electron') >= 0
|
||||
import isElectron from 'is-electron'
|
||||
|
||||
declare function $openExternal(url: string): void
|
||||
|
||||
export const openNew = (url: string) => {
|
||||
if (isElectron()) {
|
||||
// electron implementation
|
||||
if (url.length > 0) {
|
||||
$openExternal(url)
|
||||
}
|
||||
} else {
|
||||
window.open(url, '_blank')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user