Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

javascript - 电子,最小化屏幕(Electron, minimizing the screen)

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

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

1 Reply

0 votes
by (71.8m points)

Try using window.unmaximize() or window.minimize() to actually minimize it, instead of window.restore()(尝试使用window.unmaximize()window.minimize()实际最小化它,而不是window.restore())

The restore method used to return the previous state, before minimization(最小化之前用于返回先前状态的还原方法)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...