docs: Added Window Management Fiddle example (#20535)

This commit is contained in:
Yaser 2020-01-13 17:34:13 +11:00 committed by Cheng Zhao
parent 2e1531ad90
commit b31084493e
9 changed files with 474 additions and 0 deletions

View file

@ -0,0 +1,25 @@
const { BrowserWindow } = require('electron').remote
const shell = require('electron').shell
const framelessWindowBtn = document.getElementById('frameless-window')
const links = document.querySelectorAll('a[href]')
framelessWindowBtn.addEventListener('click', (event) => {
const modalPath = 'https://electronjs.org'
let win = new BrowserWindow({ frame: false })
win.on('close', () => { win = null })
win.loadURL(modalPath)
win.show()
})
Array.prototype.forEach.call(links, (link) => {
const url = link.getAttribute('href')
if (url.indexOf('http') === 0) {
link.addEventListener('click', (e) => {
e.preventDefault()
shell.openExternal(url)
})
}
})