简体   繁体   English

电子“最小化”

[英]Electron "unminimize"

I'm trying to find a way to make electron go from minimized, back to the last size of the open app - that is, simulating what happens when you click on a minimized app normally.我试图找到一种方法让电子从最小化,回到打开的应用程序的最后一个大小——也就是说,模拟当你正常点击最小化的应用程序时会发生什么。

What I ideally want (but obviously doesn't work as it is not a function):我理想中想要的(但显然不起作用,因为它不是一个函数):

if (mainWindow.isMinimized()) {
    mainWindow.unminimize()
  }

What would also be acceptable, but I haven't been able to get to work:什么也是可以接受的,但我无法上班:

if (mainWindow.isMinimized()) {
    mainWindow.setSize(1100, 950)
  }

What currently works, but doesn't bring me the desired result:目前有效,但没有给我带来想要的结果:

if (mainWindow.isMinimized()) {
    mainWindow.maximize()
  }

If anyone has a cool trick to simulate this function, or atleast a tip on how to go from minimized to a set screen size, you'd make my day!如果有人有一个很酷的技巧来模拟这个功能,或者至少有一个关于如何从最小化到设置屏幕尺寸的提示,你会让我开心! :) :)

AFIAK mainWindow.setSize(width, height[, animate]) doesn't know about the window state (ie maximized or minimzed). AFIAK mainWindow.setSize(width, height[, animate])不知道窗口状态(即最大化或最小化)。 Therefore changing the size parameters with mainWindow.setSize() won't effect the state of the window. 因此,使用mainWindow.setSize()更改大小参数不会影响窗口的状态。

As OliverRadini points out you can use mainWindow.restore() . 正如OliverRadini指出的那样,您可以使用mainWindow.restore() The docs are pretty simple... 文档非常简单...

win.restore() win.restore()

Restores the window from minimized state to its previous state. 将窗口从最小化状态还原到其先前状态。

So, using your code you should be able to do... 因此,使用您的代码,您应该可以...

if (mainWindow.isMinimized()) {
    mainWindow.restore()
}

Hope that helps! 希望有帮助!

For those who are looking to restore the window size using the maximize button after it's been maximized:对于那些希望在最大化后使用最大化按钮恢复窗口大小的人:

onMaximizeWindow() {
    if (this.electronService.window.isMaximized()) this.electronService.window.restore();
    else this.electronService.window.maximize();
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM