Chrome 应用无法最大化

Chrome app can't be maximized

我知道有一个最大化功能,但我的老板希望能够点击他 yosemite mac.

上的绿色小按钮

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

我正在玩这样的 window 尺寸:

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 的情况下禁用全屏模式在某种程度上是有意义的。