Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
355 views
in Technique[技术] by (71.8m points)

javascript - 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()
  }
})

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It should work, (can you show your new BrowserWindow config...) I tested on a working app by modifying the config:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...