[1128] nw18 解决locale判断失效
nwutils/nw-builder#357
12升18 应用打包后 navigator.language(s)始终返回en
(1) 可以确保nw Resources/下的*.lproj
语言文件 cp到打包后的app内
language(s)重新生效 像nw12一样
nw.build()
.then(() => {
// mac
;['en', 'zh_CN', 'zh_TW'].forEach(k => {
const d = `../regt-app/Genius/osx64/Genius.app/Contents/Resources/${k}.lproj`
fs.outputFileSync(d, '')
})
})
(2) 也可以考虑引入os-locale这个库
sindresorhus/os-locale#23
但它在win上调用的wmic有可能是未加入path 甚至是不存在
需要注意 并且调用耗时
if (IS_WIN) {
const winPath = process.env.windir || process.env.WINDIR
const wmicPath = winPath + '\\system32\\webm'
process.env.PATH = [wmicPath, process.env.PATH].join(';')
}
try {
return require('os-locale').sync()
} catch (e) {
return 'en'
}
[1125] 修复mac 目录或文件名带有反斜杠\
裂图 需转义为%5C
在Chrome54都报"找不到文件" 但nw12/Chromium41却可以
http://stackoverflow.com/questions/10438008/different-behaviours-of-treating-backslash-in-the-url-by-firefox-and-chrome
handleDrop(files, e) {
// ...
let encodedPath = path
if (IS_MAC && /\\/.test(path)) {
encodedPath = path.replace(/\\/g, '%5C')
}
global.editor.insertImage(`file://${encodedPath}`)
}
(更新: nw18/Chromium54又不可以了)
[1122] git merge --ff 误操作
一般我们都 merge --noff 今天误操作变成了ff
多个提交出现了重复 干扰了追踪
所以我想办法通过reset和cherry-pick 成功纠正回去
(before)
a1 - a2 - a3 - a4 - a5 [dev]
\
b1 - b2 - b3 [nw14]
(expected with --no-ff)
a1 - a2 - a3 - a4 - a5 [dev]
\ \
b1 - b2 - b3 - m1 [nw14]
(actual --ff)
a1 - a2 - a3 - a4 - a5 [dev]
\
b1 - a3' - b2 - a4' - b3 - a5' [nw14]
解决方案:
git checkout -b nw14-bak
git checkout nw14
git reset --hard b1
git cherry-pick b2 b3
git merge --no-ff dev
[1121] nw18升级日记
http://docs.nwjs.io/en/latest/For%20Users/Migration/From%200.12%20to%200.13/
we-demo/nw-chat#1
- (未完待续..)
- nwsaveas不能传入绝对路径 并配合nwworkingdir使用 nwjs/nw.js#3372 (comment)
- 采用native桌面通知需加
--enable-native-notification
nwjs/nw.js#4560 (comment) - navigator.language判断失效 nwutils/nw-builder#357
- mac shortcut开始区分cmd/ctrl 可以取消cmd=>ctrl强行替换 nwjs/nw.js#3656
- win.focus/blur等事件 重复侦听 handler会被覆盖 nwjs/nw.js#4731 (comment)
- form.enter自动触发[submit]click 影响已有逻辑
- sdk自带默认右键菜单 可屏蔽
- windows(未开启视觉样式)
menu.popup
崩溃 nwjs/nw.js#4697 - windows devtools和应用在taskbar分为两个tab
- macos默认字体样式变了 一些相应的边距可能需要调整
<img src="file://${path}">
本地路径需要加上file协议 否则裂图win.isTransparent
改为方法Window.open
回调 影响global._winsWindow.open
改为callback返回winWindow.open
部分属性不支持 并且传入自定义属性会报错 nwjs/nw.js#4970
[1104] electron renderer进程出现 paths为空 修复
在github上搜索到相关线索: electron-starter/injectModulesPath.js
Electron module paths get confused when loading a page over HTTP
import { remote } from 'electron'
import { join } from 'path'
const appPath = remote.app.getAppPath()
// module.paths = [join(appPath, 'node_modules')]
// require('module').globalPaths = [join(appPath, 'node_modules')]
process.mainModule.paths = [join(appPath, 'node_modules')]
[1103] nw跨平台 编辑器粘贴 用例大全
fritx/react-editor#2
https://zh.wikipedia.org/wiki/RTF
https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer
Paste from | MacOS 10.11 | Windows 7 |
---|---|---|
web纯文 | html?+text | html?+text |
web单图 | text+image (text为url) | html+image |
web单图base64 | text+image (text为data-url) | html+image |
web图文 | html+text | html+text |
qq纯文 | text | html?+text |
qq单图 | file | html+image (image:result为空 |
qq图文 | text+image (image为其中一张图片 |
html+text |
excel表格 | html+text+rtf+image | html+text+rtf+image |
email图文 | html+text+rtf | html+text+rtf |
桌面图标 | text+image (文件名+图标) | - |