首页 > 解决方案 > Unable to disable fullscreen and block size of the windows in Electron JS

问题描述

I'm new to Electron Js and i've tried all the snippets that i could find, but i'm still unable to disable the possibilities to enlarge the window to a full screen size. I'm running the last version of Electron Js and Windows 10.

Here is the source code :

const { app, BrowserWindow } = require('electron')

try {
    require('electron-reloader')(module)
  } catch (_) {} //For dev purposes only

function createWindow () {
  const win = new BrowserWindow({
    width: 700,
    height: 700,
    webPreferences: {
      frame:false,
      maximizable: false,
      fullscreen: false,
      nodeIntegration: true
    }
  })
  win.setMenuBarVisibility(false)
  win.loadFile('src/index.html')
}

app.whenReady().then(createWindow)

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

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

标签: javascriptelectron

解决方案


它应该可以工作,(你能显示你的新 BrowserWindow 配置...)我通过修改配置在工作应用程序上进行了测试:

 mainWindow = new BrowserWindow({
      width: 850,   //1200,
      maxWidth:850,
      minWidth:550,    //1024,
      height: 820,
      webPreferences: webPref,
      title: "MesRestau",
      icon: __dirname + "/assets/images/favicon.ico"
    });  

推荐阅读