45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
const { app, BrowserWindow, globalShortcut } = require('electron')
|
|
|
|
if (process.env.ELECTRON_IGNORE_CERT_ERRORS === '1') {
|
|
app.commandLine.appendSwitch('ignore-certificate-errors')
|
|
}
|
|
|
|
function createWindow() {
|
|
const win = new BrowserWindow({
|
|
fullscreen: true,
|
|
autoHideMenuBar: true,
|
|
webPreferences: {
|
|
contextIsolation: true,
|
|
nodeIntegration: false,
|
|
sandbox: true
|
|
}
|
|
})
|
|
const targetUrl = process.env.APP_URL || 'http://localhost:8000'
|
|
win.loadURL(targetUrl)
|
|
}
|
|
|
|
app.whenReady().then(() => {
|
|
createWindow()
|
|
globalShortcut.register('F11', () => {
|
|
const w = BrowserWindow.getFocusedWindow()
|
|
if (w) w.setFullScreen(!w.isFullScreen())
|
|
})
|
|
globalShortcut.register('Escape', () => {
|
|
const w = BrowserWindow.getFocusedWindow()
|
|
if (w) w.setFullScreen(false)
|
|
})
|
|
globalShortcut.register('CommandOrControl+Q', () => {
|
|
app.quit()
|
|
})
|
|
app.on('activate', () => {
|
|
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
|
})
|
|
})
|
|
|
|
app.on('window-all-closed', () => {
|
|
if (process.platform !== 'darwin') app.quit()
|
|
})
|
|
|
|
app.on('will-quit', () => {
|
|
globalShortcut.unregisterAll()
|
|
}) |