2022-11-28 15:22:56 +08:00
|
|
|
const { app, BrowserWindow } = require('electron')
|
|
|
|
const { platform } = require('node:process')
|
|
|
|
const path = require('path')
|
|
|
|
|
|
|
|
console.log(`This platform is ${platform}`);
|
|
|
|
|
|
|
|
const createWindow = () => {
|
|
|
|
const mainWindow = new BrowserWindow({
|
2022-11-28 18:36:52 +08:00
|
|
|
width: 1080,
|
|
|
|
minWidth: 760,
|
|
|
|
height: 720,
|
|
|
|
minHeight: 480,
|
2022-11-28 15:22:56 +08:00
|
|
|
webPreferences: {
|
|
|
|
preload: path.join(__dirname, 'preload.js')
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
mainWindow.loadFile('html/index.html')
|
2022-11-28 18:36:52 +08:00
|
|
|
// mainWindow.fullScreen = true;
|
|
|
|
//配置ESC键退出全屏
|
|
|
|
globalShortcut.register('ESC', () => {
|
|
|
|
mainWindow.setFullScreen(false);
|
|
|
|
})
|
2022-11-28 15:22:56 +08:00
|
|
|
|
2022-11-28 18:36:52 +08:00
|
|
|
// mainWindow.webContents.openDevTools()
|
2022-11-28 15:22:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
app.whenReady().then(() => {
|
|
|
|
createWindow()
|
|
|
|
|
|
|
|
app.on('activate', () => {
|
|
|
|
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
app.on('window-all-closed', () => {
|
|
|
|
if (process.platform !== 'darwin') app.quit()
|
|
|
|
})
|