You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

NW.js在Raspberry Pi 5上无法全屏的问题求助

解决方案

一、NW.js 端调整(避免崩溃的全屏适配)

1. 修正 package.json 配置

确保窗口配置优先使用原生全屏参数,避免冲突:

{
  "name": "your-app",
  "main": "index.html",
  "window": {
    "width": 854,
    "height": 480,
    "fullscreen": true,
    "kiosk": true,
    "frame": false,
    "resizable": false,
    "show": false
  }
}

在页面初始化时用NW.js原生API适配全屏,避免内容裁剪:

document.addEventListener('DOMContentLoaded', () => {
  const win = nw.Window.get();
  win.hide();
  const screen = nw.Screen.Init().screens[0];
  const screenWidth = screen.bounds.width;
  const screenHeight = screen.bounds.height;
  
  win.resizeTo(screenWidth, screenHeight);
  win.moveTo(0, 0);
  win.setFullscreen(true);
  win.show();
});

2. 禁用硬件加速(树莓派兼容性优化)

在 package.json 中添加启动参数,解决硬件加速导致的分辨率锁定问题:

{
  "chromium-args": "--disable-gpu --disable-accelerated-compositing --disable-hardware-overlays"
}

二、树莓派系统层面设置(强制分辨率拉伸)

1. 修改系统显示配置文件

编辑 /boot/firmware/config.txt(树莓派5专属路径):

sudo nano /boot/firmware/config.txt

添加或修改以下参数,强制输出854x480分辨率并拉伸显示:

hdmi_group=2
hdmi_mode=87
hdmi_cvt=854 480 60 1 0 0 0
hdmi_force_hotplug=1
disable_overscan=1
hdmi_drive=2

2. 重启生效

sudo reboot

额外验证

若仍有问题,以管理员权限启动NW.js,确保获取系统级显示权限:

sudo ./nwjs

内容的提问来源于stack exchange,提问作者BargmyGames

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 11:05:56