目前只在win10环境下测试过,成功全屏,无任务栏
const {app, BrowserWindow, globalShortcut} = require('electron')
let mainWindow
function createWindow() {
mainWindow = new BrowserWindow({
webPreferences: {
webSecurity: false
}
})
//配置ESC键退出全屏
globalShortcut.register('ESC', () => {
mainWindow.setFullScreen(false);
})
mainWindow.loadFile('index.html')
//进入软件即开启全屏
mainWindow.setFullScreen(true);
mainWindow.on('closed', function () {
mainWindow = null
})
}
app.on('ready', createWindow)
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow()
}
})