-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Electron 实践之自动更新 #26
Comments
能加个qq/微信 交流么? |
用相同的方法在 Windows 下做了实践,与 MacOX 的不同主要有两个部分 update.jsonupdate.json 格式参考如下: {
"win32-x64-prod": {
"readme": "Second Release",
"update": "http://xxx/releases/download/1.2.0",
"install": "http://xxx/releases/download/1.2.0/xxx.Setup.1.2.0.exe",
"version": "1.2.0"
}
}
build 配置
"build": {
...
"win": {
"target": "squirrel"
},
"squirrelWindows": {
"iconUrl": "https://raw.githubusercontent.com/megahertz/electron-simple-updater/master/example/build/icon.ico"
}
}, |
另外,@sorrycc 示例中是在 renderer 端对更新操作进行控制,个人认为更新功能作为独立的小模块,放在 main 端更加符合一般的通用场景。 main 端自动更新的代码可以参考 autoUpdate |
log: https://lionsec.b0.upaiyun.com/desktop/updates.json 查了json文件都是正常的,晕! |
@alcat2008 windows 需要证书签名后才生效吗? |
electron 官方的 auto update 文档并不完善,多番 google 后,找到一种使用简单、跨平台、无特殊服务器要求的方案。
效果图:
生成证书
出于安全考虑,自动更新必须搭配证书和 https 服务器使用。证书的生成可以用苹果开发者证书或者 StartSSL 等生成证书,而只有苹果开发者证书可以过掉 GateKeeper 。
打包时通过环境变量
CSC_LINK
和CSC_KEY_PASSWORD
指定证书,另外在 Mac 下可不手动指定,electron-builder 会自动寻找合适的证书。详见: Code Signing · electron-userland/electron-builder Wiki · GitHub
找一台服务器存放
update.json
格式参考以下例子:
使用 electron-simple-updater
先安装依赖,在
./app
目录执行:在
app/package.json
中配置update.json
的地址:main 端配置 updater :
renderer 端绑定时间并启动更新检测:
打包
基于 electron-builder 。
部署资源文件到 https 服务器
mac 下要有
release.json
和{ProductName}-{version}-mac.zip
,需部署到 https 服务器。release.json 格式如下:
参考 Release 1.2.0 · sorrycc/test-release · GitHub 。
更新 update.json
参考前面的例子更新
update.json
。参考
(完)
The text was updated successfully, but these errors were encountered: