Knowledge-Base
Knowledge-Base copied to clipboard
nw.js 开发笔记
设置任务栏图标及标题栏左侧图标
在 package.json 中,添加如下配置即可:
"window": {
"icon": "app/img/book.png"
}
注意,该设置与下面的“设置文件图标”互不影响,各自负责设置不同地方的图标,没有交集。
参考:
设置文件图标
用 Resource Hacker 打开 exe 文件,修改图标后保存即可。Total Commander 需要重启一下才能看到新图标,Windows 资源管理器就不用。
参考:
- How to Change the Default Icon of an Exe using Resource Editor / Resource Hacker?
- 上一条参考资料的来源:Change application icon
启动后让窗口最大化
var gui = require('nw.gui')
var win = gui.Window.get()
win.maximize()
参考:
打开新窗口并设置其尺寸
var path = require('path')
var ebookPath = path.join(process.cwd(), 'app/ebook/index.html')
var win = gui.Window.get()
var width = win.width
var height = win.height
var config = {
'width': width,
'height': height
}
nw.Window.open(ebookPath, config)
参考: