gpt4 book ai didi

javascript - Chrome 应用无法最大化

转载 作者:行者123 更新时间:2023-12-03 09:51:55 24 4
gpt4 key购买 nike

我知道有一个最大化功能,但我的老板希望能够单击他的 yosemite mac 上的绿色小按钮。

这曾一度有效,但现在绿色小按钮被禁用。

enter image description here

我正在使用这样的窗口大小:

service.setChromeToMinSize = function(){
var monitorWidth = window.screen.availWidth;
var monitorHeight = window.screen.availHeight;
var top = Math.round((monitorHeight / 2) - (568 / 2));
var left = Math.round((monitorWidth / 2) - (400 / 2));

chrome.app.window.current().innerBounds.maxWidth = 400;
chrome.app.window.current().innerBounds.maxHeight = 568;
chrome.app.window.current().innerBounds.minWidth = 400;
chrome.app.window.current().innerBounds.minHeight = 568;
chrome.app.window.current().innerBounds.top = top;
chrome.app.window.current().innerBounds.left = left;
chrome.app.window.current().innerBounds.width = 400;
chrome.app.window.current().innerBounds.height = 568;
};

service.setChromeToVideoSize = function(){

var monitorWidth = window.screen.availWidth;
var monitorHeight = window.screen.availHeight;
var videoWidth = Math.round(monitorWidth/2);
var videoHeight = Math.round(videoWidth * 9 / 16);
var top = Math.round((monitorHeight / 2) - (videoHeight / 2));
var left = Math.round((monitorWidth / 2) - (videoWidth / 2));

chrome.app.window.current().innerBounds.maxWidth = 10000;
chrome.app.window.current().innerBounds.maxHeight = 10000;
chrome.app.window.current().innerBounds.minWidth = 1;
chrome.app.window.current().innerBounds.minHeight = 1;
chrome.app.window.current().innerBounds.top = top;
chrome.app.window.current().innerBounds.left = left;
chrome.app.window.current().innerBounds.width = videoWidth;
chrome.app.window.current().innerBounds.height = videoHeight;
};

但即使有这么多评论,我也遇到了同样的问题。

我像这样启动应用程序:

chrome.app.runtime.onLaunched.addListener(function(launchData) {
chrome.app.window.create(
'index.html',
{
id: 'mainWindow',
bounds: {width: 400, height: 568},
minWidth: 400,
minHeight: 568,
maxWidth: 400,
maxHeight: 568
}
);
});

问题:如何启用绿色小按钮?

最佳答案

正如评论中所指出的,您必须将innerBounds maxWidthmaxHeight设置为null,而不是一个很大的数字。

来自the bounds type documentation :

A value of null indicates 'unspecified'.

虽然没有提到对全屏模式的限制,但在设置 maxWidth/Height 的情况下禁用全屏模式在某种程度上是有意义的。

关于javascript - Chrome 应用无法最大化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30866497/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com