Skip to content

nw-chat 最佳实践/常见问题 汇集 #1

@fritx

Description

@fritx

最佳实践

  • win关闭时 其附属变量全部回收 如新开窗口传入callback等 需注意调用位置 否则变为zombie
  • alert等popup由main弹出 避免出现窗口关闭 刚好loaded传值被中断
  • mac上drag/nodrag区域 生效不及时 需触发blur/focus
  • show_in_taskbar:false导致连带dock图标消失 mac上不应使用
  • popup/profile entry拆分
  • login/home 为常驻
  • OSX frameless win title visible v0.13.0 Beta5 - transparency on OSX - win title/name still shows with frames false. nwjs/nw.js#4339 note
  • win.x/y width/height 必须传入整数 否则无作用
  • 记得捕获Cmd-W 关闭窗口 普通keydown事件即可
  • callback/reject new Error() 可以追踪stack
  • 从qq粘贴图片 某些本地URL在decodeURIComponent报错 需要容错 file:///C:\Users\fritz.lin\AppData\Local\Temp\5{0MO)%QR2R67J[G~8NZ1]O.jpg
  • win上的事件绑定在entry启动时 统一清除 解决刷新问题
  • openWindow时直接设定always-on-top 会导致win就绪前自动show 需要转移到就绪时 win.setAlwaysOnTop()
  • display:inline-block 可以优化(精确)选中区域
  • 普通form一定要禁止默认submit行为 否则重复提交会导致 Error: Element already exists 崩溃
  • 关闭窗口 不要直接调.close(true) 只能调.close() 以免错失默认行为
  • react中 零散的文本会被自动包裹为span css中务必不要简单地选择span dom中也尽量用其他标签替换 搜索^\s*span\s*\{
  • mac nodrag不起效的问题 注意nodrag区域必须占位才有效
  • nw窗口关闭时 window及附带变量会提前置为null
  • nw与redux结合使用 关闭窗口时 需要触发一次componentWillUnmount 使react-redux解绑

常见问题

部分笔记

https://github.com/fritx/secret/issues/9
http://blog.fritx.me/?weekly/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions