我有Electron BrowserWindow的問題,因爲當我調用函數:win.maximize()時,應用程序與Window的任務欄重疊,就好像它處於全屏模式一樣,但我設置了fullScreen:false 。電子:最大化瀏覽器窗口重疊窗口任務欄
下面是截圖的鏈接! https://www.dropbox.com/s/a7b8h8ukaz4pf26/default%20window%20size.png?dl=0 https://www.dropbox.com/s/8wf0jcv5kp04c25/maximized%20window.png?dl=0
這裏是我的代碼:
main.js(默認電子窗口設置):
const {app, BrowserWindow} = require('electron');
const path = require('path');
let mainWindow;
app.on('window-all-closed', function(){
// Notice on OS X the application don't close when you quit window
// Darwin is the platform name when OS X in loaded
if(process.platform != 'darwin') {
app.quit();
}
});
app.on('ready', function() {
mainWindow = new BrowserWindow({
width: 700,
height: 450,
frame: false,
resizable: false,
backgroundColor: '#333333',
'node-integration': true
});
mainWindow.loadURL(path.join(__dirname, '/index.html'));
mainWindow.on('closed', function() {
mainWindow = null;
});
});
default.js(它處理窗口按鈕:最小化,最大化和關閉):
const remote = require('electron').remote;
(function(){
function init(){
document.getElementById('minimize-btn').addEventListener('click', function(){
var window = remote.getCurrentWindow();
window.minimize();
});
document.getElementById('maximize-btn').addEventListener('click', function(){
var window = remote.getCurrentWindow();
if (!window.isMaximized()) {
window.maximize();
} else {
window.unmaximize();
}
});
document.getElementById('close-btn').addEventListener('click', function(){
var window = remote.getCurrentWindow();
window.close();
});
}
init();
})();
謝謝你的幫忙!
嗨史蒂文森! 我重用了你的代碼並實現了窗口狀態包,但它不起作用。 我在Window 7和8上測試過,它是同樣的問題。 –