24 lines
651 B
JavaScript
24 lines
651 B
JavaScript
|
const { remote } = require('electron')
|
||
|
|
||
|
window.addEventListener('DOMContentLoaded', () => {
|
||
|
// 利用 remote 获取当前窗口对象
|
||
|
let mainWin = remote.getCurrentWindow()
|
||
|
|
||
|
// 获取元素添加点击操作的监听
|
||
|
let aBtns = document.getElementsByClassName('function')
|
||
|
|
||
|
aBtns[0].addEventListener('click', () => {
|
||
|
// 最小化
|
||
|
mainWin.minimize()
|
||
|
})
|
||
|
|
||
|
aBtns[1].addEventListener('click', () => {
|
||
|
// 最大化
|
||
|
mainWin.isMaximized() ? mainWin.restore() : mainWin.maximize()
|
||
|
})
|
||
|
|
||
|
aBtns[2].addEventListener('click', () => {
|
||
|
// 关闭窗口操作
|
||
|
mainWin.close()
|
||
|
})
|
||
|
})
|