1.Step
mainWindow = new BrowserWindow({
width: 1200,
height: 700,
center: true,
'min-height': 700,
'min-width': 1200,
webPreferences: {nodeIntegration:true}});
mainWindow.loadURL(HOME_URL);
2.Step(某些事件发生,我想暂时隐藏主窗口并显示另一个(createFacebookWindow()fn已经在加载URL))
mainWindow.hide();
facebookWindow = require('./modules/auth/views.js').createFacebookWindow();
FB Window settings ({
width: 1200,
height: 700,
center: true,
'min-height': 700,
'min-width': 1200,
webPreferences: {nodeIntegration:false}})
3.Step(另一个事件发生我破坏fb窗口并显示主窗口)
facebookWindow.close();
facebookWindow.on('closed', function() {
facebookWindow = null;
mainWindow.show();
//I tried below options it doesn't work
//mainWindow.setSize(1200, 700);
//mainWindow.setMinimumSize(1200, 700);
要点:
所以实际上在这些步骤之后,当我显示mainWindow时,它不记得mainWindow设置min-height和min-width不起作用。
当facebookWindow没有打开时,一切都很好,所以在用Windows切换时必须发生一些事情。也许某些事情是按错误的顺序完成的?
答案 0 :(得分:7)
您可以在此处阅读BrowserWindow
文档:https://github.com/electron/electron/blob/master/docs/api/browser-window.md
maxWidth
代替max-width
minWidth
代替min-width
maxHeight
代替max-height
minHeight
代替min-height
答案 1 :(得分:0)
you can add minWidth:500 inside the BrowserWindow while initializing window. like
function createWindow () {
// Create the browser window.
const win = new BrowserWindow({
backgroundColor: '#ffffff',
width: 1024,
height: 768,
minWidth:500,
webPreferences: {
nodeIntegration: true
}
})
注意:函数(createWindow)在main.js文件中,因此您只需在函数内部添加minWidth:value。