1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee
epp/client-entrance-guard/main.js

52 lines
1.2 KiB
JavaScript
Raw Normal View History

const { app, BrowserWindow, ipcMain, Menu, globalShortcut } = require('electron')
2022-11-28 15:22:56 +08:00
const { platform } = require('node:process')
const path = require('path')
console.log(`This platform is ${platform}`);
const createWindow = () => {
// 创建窗口
2022-11-28 15:22:56 +08:00
const mainWindow = new BrowserWindow({
width: 1080,
minWidth: 760,
height: 720,
minHeight: 480,
2022-11-28 15:22:56 +08:00
webPreferences: {
preload: path.join(__dirname, 'preload.js')
},
})
// 加载 HTML
2022-11-28 15:22:56 +08:00
mainWindow.loadFile('html/index.html')
// 隐藏菜单栏
// let menu = Menu.getApplicationMenu()
Menu.setApplicationMenu(null)
// 全屏逻辑
// mainWindow.fullScreen = true;
ipcMain.on('toggle-fullscreen', () => {
mainWindow.setFullScreen(!mainWindow.isFullScreen())
})
// 配置ESC键退出全屏
globalShortcut.register('ESC', () => {
mainWindow.setFullScreen(false);
})
2022-11-28 15:22:56 +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()
})