如何让我的 NW.js 应用程序*启动*全屏?

How do I make my NW.js application *start* in fullscreen?

我知道如何进入全屏,一旦它已经加载到 window。这会导致丑陋的效果,当我单击其图标时,会短暂闪烁 windowed window 并立即全屏显示。我讨厌那种效果。

我如何让它立即以全屏模式真正启动,而无需进入 windowed 模式,哪怕是一瞬间?

我不是 JS 专业人士,但我在 python 中编写代码,我认为如果您制作了这样的函数,它仍然可以正常工作


function onstart(){
 if (boolean == true): 
// Fullscreen code 
}
// Your code here 
onstart()

如果您想了解更多信息,请转至 https://www.w3schools.com/howto/howto_js_fullscreen.asp#:~:text=To%20open%20an%20element%20in%20fullscreen%2C%20we%20use,fullscreen%20mode%20%28a%20video%20in%20this%20example%29%3A%20%2A%2F 如果你正在制作一个网站,这会起作用

function openFullscreen() {
  if (elem.requestFullscreen) {
    elem.requestFullscreen();
  } else if (elem.webkitRequestFullscreen) { /* Safari */
    elem.webkitRequestFullscreen();
  } else if (elem.msRequestFullscreen) { /* IE11 */
    elem.msRequestFullscreen();
  }
}

/* Close fullscreen */
function closeFullscreen() {
  if (document.exitFullscreen) {
    document.exitFullscreen();
  } else if (document.webkitExitFullscreen) { /* Safari */
    document.webkitExitFullscreen();
  } else if (document.msExitFullscreen) { /* IE11 */
    document.msExitFullscreen();
  }
}

您只需将 fullscreen: true 放入您的清单中:https://docs.nwjs.io/en/latest/References/Manifest%20Format/#fullscreen.