修改了启动项目
This commit is contained in:
parent
45829e85cf
commit
1bf0b3e078
21
main.js
21
main.js
@ -1,4 +1,4 @@
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow, globalShortcut } = require('electron')
|
||||
|
||||
if (process.env.ELECTRON_IGNORE_CERT_ERRORS === '1') {
|
||||
app.commandLine.appendSwitch('ignore-certificate-errors')
|
||||
@ -6,7 +6,7 @@ if (process.env.ELECTRON_IGNORE_CERT_ERRORS === '1') {
|
||||
|
||||
function createWindow() {
|
||||
const win = new BrowserWindow({
|
||||
fullscreen: false,
|
||||
fullscreen: true,
|
||||
autoHideMenuBar: true,
|
||||
webPreferences: {
|
||||
contextIsolation: true,
|
||||
@ -14,12 +14,23 @@ function createWindow() {
|
||||
sandbox: true
|
||||
}
|
||||
})
|
||||
const targetUrl = process.env.APP_URL || 'https://www.baidu.com'
|
||||
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()
|
||||
})
|
||||
@ -28,3 +39,7 @@ app.whenReady().then(() => {
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') app.quit()
|
||||
})
|
||||
|
||||
app.on('will-quit', () => {
|
||||
globalShortcut.unregisterAll()
|
||||
})
|
||||
Loading…
Reference in New Issue
Block a user