Skip to content

Commit 70c944e

Browse files
committed
chore: Update README.md
1 parent fcde2f7 commit 70c944e

File tree

6 files changed

+766
-728
lines changed

6 files changed

+766
-728
lines changed

README-ZH.md

Lines changed: 365 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,365 @@
1+
# auto_updater
2+
3+
[![pub version][pub-image]][pub-url] [![][discord-image]][discord-url]
4+
5+
[pub-image]: https://img.shields.io/pub/v/auto_updater.svg
6+
[pub-url]: https://pub.dev/packages/auto_updater
7+
[discord-image]: https://img.shields.io/discord/884679008049037342.svg
8+
[discord-url]: https://discord.gg/zPa6EZ2jqb
9+
10+
这个插件允许 Flutter **桌面** 应用自动更新自己 (基于 [sparkle](https://sparkle-project.org/)[winsparkle](https://winsparkle.com))。
11+
12+
<img src="screenshots/sparkle.png" width="732" alt="">
13+
14+
---
15+
16+
[English](./README.md) | 简体中文
17+
18+
---
19+
20+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
21+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
22+
23+
- [平台支持](#%E5%B9%B3%E5%8F%B0%E6%94%AF%E6%8C%81)
24+
- [快速开始](#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B)
25+
- [安装](#%E5%AE%89%E8%A3%85)
26+
- [⚠️ Windows requirements](#-windows-requirements)
27+
- [用法](#%E7%94%A8%E6%B3%95)
28+
- [发布你的应用](#%E5%8F%91%E5%B8%83%E4%BD%A0%E7%9A%84%E5%BA%94%E7%94%A8)
29+
- [生成私钥](#%E7%94%9F%E6%88%90%E7%A7%81%E9%92%A5)
30+
- [macOS](#macos)
31+
- [Windows](#windows)
32+
- [打包应用](#%E6%89%93%E5%8C%85%E5%BA%94%E7%94%A8)
33+
- [macOS](#macos-1)
34+
- [Windows](#windows-1)
35+
- [获取签名](#%E8%8E%B7%E5%8F%96%E7%AD%BE%E5%90%8D)
36+
- [macOS](#macos-2)
37+
- [Windows](#windows-2)
38+
- [分发应用](#%E5%88%86%E5%8F%91%E5%BA%94%E7%94%A8)
39+
- [故障排除](#%E6%95%85%E9%9A%9C%E6%8E%92%E9%99%A4)
40+
- [macOS](#macos-3)
41+
- [谁在用使用它?](#%E8%B0%81%E5%9C%A8%E7%94%A8%E4%BD%BF%E7%94%A8%E5%AE%83)
42+
- [API](#api)
43+
- [AutoUpdater](#autoupdater)
44+
- [Methods](#methods)
45+
- [setFeedURL](#setfeedurl)
46+
- [checkForUpdates](#checkforupdates)
47+
- [setScheduledCheckInterval](#setscheduledcheckinterval)
48+
- [相关链接](#%E7%9B%B8%E5%85%B3%E9%93%BE%E6%8E%A5)
49+
- [许可证](#%E8%AE%B8%E5%8F%AF%E8%AF%81)
50+
51+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
52+
53+
## 平台支持
54+
55+
| Linux | macOS | Windows |
56+
| :---: | :---: | :-----: |
57+
|| ✔️ | ✔️ |
58+
59+
## 快速开始
60+
61+
### 安装
62+
63+
将此添加到你的软件包的 pubspec.yaml 文件:
64+
65+
```yaml
66+
dependencies:
67+
auto_updater: ^0.2.0
68+
```
69+
70+
71+
72+
```yaml
73+
dependencies:
74+
auto_updater:
75+
git:
76+
path: packages/auto_updater
77+
url: https://github.com/leanflutter/auto_updater.git
78+
ref: main
79+
```
80+
81+
#### ⚠️ Windows requirements
82+
83+
- `openssl`
84+
85+
运行以下命令:
86+
87+
> 使用 [Chocolatey](https://chocolatey.org/install)
88+
89+
```
90+
choco install openssl
91+
```
92+
93+
### 用法
94+
95+
```dart
96+
import 'package:auto_updater/auto_updater.dart';
97+
98+
void main() async {
99+
// 必须加上这一行。
100+
WidgetsFlutterBinding.ensureInitialized();
101+
102+
String feedURL = 'http://localhost:5002/appcast.xml';
103+
await autoUpdater.setFeedURL(feedURL);
104+
await autoUpdater.checkForUpdates();
105+
await autoUpdater.setScheduledCheckInterval(3600);
106+
107+
runApp(MyApp());
108+
}
109+
```
110+
111+
> 请看这个插件的示例应用,以了解完整的例子。
112+
113+
### 发布你的应用
114+
115+
#### 生成私钥
116+
117+
运行以下命令:
118+
119+
```bash
120+
dart run auto_updater:generate_keys
121+
```
122+
123+
> 需要分别在 `macOS``Windows` 系统中运行该命令。
124+
125+
##### macOS
126+
127+
准备使用 `EdDSA` 签名算法进行签名:
128+
129+
输出:
130+
131+
```
132+
A key has been generated and saved in your keychain. Add the `SUPublicEDKey` key to
133+
the Info.plist of each app for which you intend to use Sparkle for distributing
134+
updates. It should appear like this:
135+
136+
<key>SUPublicEDKey</key>
137+
<string>pfIShU4dEXqPd5ObYNfDBiQWcXozk7estwzTnF9BamQ=</string>
138+
```
139+
140+
更改文件 `macos/Runner/Info.plist` 如下:
141+
142+
```diff
143+
<?xml version="1.0" encoding="UTF-8"?>
144+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
145+
<plist version="1.0">
146+
<dict>
147+
148+
...
149+
150+
+ <key>SUPublicEDKey</key>
151+
+ <string>bHaXClrRGMmKoKP/3HJnr/jn2ODTRPAM3VZhhkI9ZvY=</string>
152+
</dict>
153+
</plist>
154+
```
155+
156+
##### Windows
157+
158+
准备使用 `DSA` 签名算法进行签名:
159+
160+
输出:
161+
162+
```
163+
Generated two files:
164+
dsa_priv.pem: your private key. Keep it secret and don't share it!
165+
dsa_pub.pem: public counterpart to include in youe app.
166+
BACK UP YOUR PRIVATE KEY AND KEEP IT SAFE!
167+
If you lose it, your users will be unable to upgrade!
168+
```
169+
170+
> 命令将为你生成私钥(`dsa_priv.pem`)及公钥(`dsa_pub.pem`),请备份你的私钥并确保其安全,并将公钥作为 Windows 资源添加到项目中。
171+
172+
更改文件 `windows/runner/Runner.rc` 如下:
173+
174+
```diff
175+
176+
...
177+
178+
+/////////////////////////////////////////////////////////////////////////////
179+
+//
180+
+// WinSparkle
181+
+//
182+
183+
+// And verify signature using DSA public key:
184+
+DSAPub DSAPEM "../../dsa_pub.pem"
185+
```
186+
187+
#### 打包应用
188+
189+
> 为了简化打包的过程,这里使用了 [Flutter Distributor](https://github.com/leanflutter/flutter_distributor) ,一个专门用于打包和发布 Flutter 应用的完整工具。
190+
191+
`distribute_options.yaml` 添加到你的项目根目录。
192+
193+
```yaml
194+
output: dist/
195+
releases:
196+
- name: prod
197+
jobs:
198+
- name: macos-zip
199+
package:
200+
platform: macos
201+
target: zip
202+
build_args:
203+
dart-define:
204+
APP_ENV: dev
205+
# 查看完整文档:https://distributor.leanflutter.org/configuration/makers/exe
206+
- name: windows-exe
207+
package:
208+
platform: windows
209+
target: exe
210+
build_args:
211+
dart-define:
212+
APP_ENV: dev
213+
```
214+
215+
##### macOS
216+
217+
运行以下命令:
218+
219+
```
220+
flutter_distributor release --name prod --jobs macos-zip
221+
```
222+
223+
##### Windows
224+
225+
运行以下命令:
226+
227+
```
228+
flutter_distributor release --name prod --jobs windows-exe
229+
```
230+
231+
#### 获取签名
232+
233+
##### macOS
234+
235+
运行以下命令:
236+
237+
```
238+
dart run auto_updater:sign_update dist/1.1.0+2/auto_updater_example-1.1.0+2-macos.zip
239+
```
240+
241+
输出:
242+
243+
```
244+
sparkle:edSignature="pbdyPt92pnPkzLfQ7BhS9hbjcV9/ndkzSIlWjFQIUMcaCNbAFO2fzl0tISMNJApG2POTkZY0/kJQ2yZYOSVgAA==" length="13400992"
245+
```
246+
247+
将获得的新签名更新到 `appcast.xml` 文件 `enclosure` 节点的 `sparkle:edSignature` 属性值。
248+
249+
##### Windows
250+
251+
运行以下命令:
252+
253+
```
254+
dart run auto_updater:sign_update dist/1.1.0+2/auto_updater_example-1.1.0+2-windows-setup.exe
255+
```
256+
257+
输出:
258+
259+
```
260+
261+
sparkle:dsaSignature="MEUCIQCVbVzVID7H3aUzAY5znpi+ySZKznkukV8whlMFzKh66AIgREUGOmvavlcg6hwAwkb2o4IqVE/D56ipIBshIqCH8rk=" length="13400992"
262+
```
263+
264+
将获得的新签名更新到 `appcast.xml` 文件 `enclosure` 节点的 `sparkle:dsaSignature` 属性值。
265+
266+
#### 分发应用
267+
268+
`appcast.xml` 添加到你的项目 `dist/` 目录。
269+
270+
```xml
271+
<?xml version="1.0" encoding="UTF-8"?>
272+
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">
273+
<channel>
274+
<title>auto_updater_example</title>
275+
<description>Most recent updates to auto_updater_example</description>
276+
<language>en</language>
277+
<item>
278+
<title>Version 1.1.0</title>
279+
<sparkle:releaseNotesLink>
280+
https://your_domain/your_path/release_notes.html
281+
</sparkle:releaseNotesLink>
282+
<pubDate>Sun, 16 Feb 2022 12:00:00 +0800</pubDate>
283+
<enclosure url="1.1.0+2/auto_updater_example-1.1.0+2-macos.zip"
284+
sparkle:edSignature="pbdyPt92pnPkzLfQ7BhS9hbjcV9/ndkzSIlWjFQIUMcaCNbAFO2fzl0tISMNJApG2POTkZY0/kJQ2yZYOSVgAA=="
285+
sparkle:version="1.1.0"
286+
sparkle:os="macos"
287+
length="13400992"
288+
type="application/octet-stream" />
289+
</item>
290+
<item>
291+
<title>Version 1.1.0</title>
292+
<sparkle:releaseNotesLink>
293+
https://your_domain/your_path/release_notes.html
294+
</sparkle:releaseNotesLink>
295+
<pubDate>Sun, 16 Feb 2022 12:00:00 +0800</pubDate>
296+
<enclosure url="1.1.0+2/auto_updater_example-1.1.0+2-windows.exe"
297+
sparkle:dsaSignature="MEUCIQCVbVzVID7H3aUzAY5znpi+ySZKznkukV8whlMFzKh66AIgREUGOmvavlcg6hwAwkb2o4IqVE/D56ipIBshIqCH8rk="
298+
sparkle:version="1.1.0+2"
299+
sparkle:os="windows"
300+
length="0"
301+
type="application/octet-stream" />
302+
</item>
303+
</channel>
304+
</rss>
305+
```
306+
307+
> 本示例中 `macOS``Windows` 使用同一个 `appcast.xml` 文件,你需根据配置 `sparkle:os` 属性的值。
308+
309+
启动测试更新服务器:
310+
311+
```
312+
cd dist/
313+
serve -l 5002
314+
```
315+
316+
## 故障排除
317+
318+
### macOS
319+
320+
- 确保按照 [Sparkle 文档](https://sparkle-project.org/documentation/)中的说明添加了 sparkle pod
321+
- 通过将以下内容添加到您的授权文件以进行调试和发布,确保您已添加并启用应用程序的网络功能并禁用沙箱以进行发布
322+
323+
```
324+
<key>com.apple.security.network.client</key>
325+
<true/>
326+
<key>com.apple.security.network.server</key>
327+
<true/>
328+
<key>com.apple.security.app-sandbox</key>
329+
<false/>
330+
```
331+
332+
## 谁在用使用它?
333+
334+
- [比译](https://biyidev.com/) - 一个便捷的翻译和词典应用程序。
335+
336+
## API
337+
338+
<!-- README_DOC_GEN -->
339+
340+
### AutoUpdater
341+
342+
#### Methods
343+
344+
##### setFeedURL
345+
346+
设置 url 并初始化 auto updater.
347+
348+
##### checkForUpdates
349+
350+
检查更新,在此之前必须先调用 setFeedURL.
351+
352+
##### setScheduledCheckInterval
353+
354+
设置检查时间间隔,默认 86400,最少 3600, 0 不更新
355+
356+
<!-- README_DOC_GEN -->
357+
358+
## 相关链接
359+
360+
- https://sparkle-project.org/
361+
- https://winsparkle.org/
362+
363+
## 许可证
364+
365+
[MIT](./LICENSE)

0 commit comments

Comments
 (0)