I'm pretty new here, I have a project in Electron, and I want to do my own minimize/maximize, close buttons.(我在这里很新,我在Electron中有一个项目,我想做自己的最小化/最大化,关闭按钮。)
And my minimize/maximize buttons don't work that well.(而且我的“最小化/最大化”按钮效果不佳。) I've been through several topics asking the question, but it still won't work.(我已经遍历几个主题问了这个问题,但是仍然无法解决。) When I first click, it maximize the window, but when I click again, it won't minimize, and so it stay in the state "window is maximized" in the if/else.(当我第一次单击时,它将最大化窗口,但是当我再次单击时,它不会最小化,因此它在if / else中保持“窗口最大化”状态。)
Even when I start to make my own boolean to force the function, it understand when it goes maximized.(即使当我开始使用自己的布尔值强制执行该功能时,它也知道何时将其最大化。) But it won't go to the other state.(但是它不会进入另一个状态。)
Here's a sample of the code(这是代码示例)
const remote = require('electron').remote;
let screenExit = document.getElementById("close-btn")
let screenSize = document.getElementById("size-btn")
//Close Windows
screenExit.addEventListener( "click", e => {
let window = remote.getCurrentWindow()
window.close()
} )
//Minimize & Maximize
$('#size-btn').click(function() {
let window = remote.getCurrentWindow()
if(window.isMaximized()){
window.restore();
console.log("AAAAAAAAAAAAH")
}else{
window.maximize();
console.log("This sh** gone work ._.")
}
});
In the console, it keeps loging me "AAAAAAAAAAAAH" since it won't go to the other case.(在控制台中,它不会继续记录“ AAAAAAAAAAAAH”,因为在其他情况下不会显示。) Even if I do my own boolean.(即使我自己做布尔值。)
Thanks a lot in advance !(在此先多谢!)
ask by Muramash translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…