Make sure links open externally

This commit is contained in:
49lf
2024-07-31 15:08:18 -04:00
parent 4c2b807890
commit 871cc4df35
8 changed files with 33 additions and 12 deletions

View File

@ -1,10 +1,18 @@
import { isDesktop } from 'lib/isDesktop'
import { open as tauriOpen } from '@tauri-apps/plugin-shell'
export const openExternalBrowserIfDesktop = (to) => function(e) {
if (isDesktop()) {
window.electron.openExternal(to || e.currentTarget.href)
e.preventDefault()
e.stopPropagation()
return false
}
}
// Open a new browser window tauri style or browser style.
export default async function openWindow(url: string) {
if (isDesktop()) {
await tauriOpen(url)
await window.electron.openExternal(url)
} else {
window.open(url, '_blank')
}