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({
        width: 1080,
        minWidth: 760,
        height: 720,
        minHeight: 480,
        webPreferences: {
            preload: path.join(__dirname, 'preload.js')
        },
    })

    mainWindow.loadFile('html/index.html')
    // mainWindow.fullScreen = true;
    //配置ESC键退出全屏
    globalShortcut.register('ESC', () => {
        mainWindow.setFullScreen(false);
    })

    // mainWindow.webContents.openDevTools()
}

app.whenReady().then(() => {
    createWindow()

    app.on('activate', () => {
        if (BrowserWindow.getAllWindows().length === 0) createWindow()
    })
})

app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') app.quit()
})
