心血来潮想做一个PC端应用,就来学学Electron,以下为学习Electron时的踩坑记录。
registry "https://registry.npm.taobao.org"
sass_binary_site "https://npm.taobao.org/mirrors/node-sass/"
phantomjs_cdnurl "http://cnpmjs.org/downloads"
electron_mirror "https://npm.taobao.org/mirrors/electron/"
sqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/"
profiler_binary_host_mirror "https://npm.taobao.org/mirrors/node-inspector/"
chromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver"
手动rebuild
$ npm rebuild --runtime=electron --target=6.0.12 --disturl=https://atom.io/download/atom-shell --abi=72
使用electron-rebuild
yarn add electron-rebuild -D # or npm install electron-rebuild --save-dev
ELECTRON_BUILDER_BINARIES_MIRROR=https://npm.taobao.org/mirrors/electron-builder-binaries/
简单解决
- 在ready-to-show的时候再显示
- 设置窗口底色
win = new BrowerWindow({
width: 600,height: 300,webPreferences: {
nodeIntegration: true
},show: false,background: '#2e2c29',});
win.on('ready-to-show',() => {
win.show();
});
使用占位图