mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 11:42:14 -08:00
Open anchor hrefs in the default browser. (#111)
This commit is contained in:
parent
9793c4072d
commit
e86992a7ee
@ -2,20 +2,21 @@ import * as React from 'react'
|
|||||||
import * as ReactDOM from 'react-dom'
|
import * as ReactDOM from 'react-dom'
|
||||||
import { AppContainer } from 'react-hot-loader'
|
import { AppContainer } from 'react-hot-loader'
|
||||||
import { Provider } from 'react-redux'
|
import { Provider } from 'react-redux'
|
||||||
// import { shell } from 'electron'
|
import { shell } from 'electron'
|
||||||
import store from './redux/store'
|
import store from './redux/store'
|
||||||
|
|
||||||
import Application from './components/Application'
|
import Application from './components/Application'
|
||||||
|
|
||||||
import './index.css'
|
import './index.css'
|
||||||
|
|
||||||
|
// Open anchor hrefs in the default browser.
|
||||||
// document.addEventListener('click', (event: MouseEvent) => {
|
document.addEventListener('click', (event: MouseEvent) => {
|
||||||
// if ((event.target as HTMLElement)?.tagName === 'A' && (event.target as HTMLAnchorElement)?.href.startsWith('http')) {
|
const anchor: HTMLAnchorElement | null = (event.target as HTMLElement).closest('a')
|
||||||
// event.preventDefault()
|
if(anchor != null && anchor.hasAttribute('href') && anchor.getAttribute('href')!.toLowerCase().startsWith('http')) {
|
||||||
// shell.openExternal((event.target as HTMLAnchorElement).href)
|
event.preventDefault()
|
||||||
// }
|
shell.openExternal(anchor.href)
|
||||||
// })
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Create main element
|
// Create main element
|
||||||
const mainElement = document.createElement('div')
|
const mainElement = document.createElement('div')
|
||||||
|
Loading…
Reference in New Issue
Block a user