refactor: upgrade deps, setup tailwind4 and correct ci (#258)
* refresh * e2e test * Change debugger type from 'pwa-chrome' to 'chrome' * ci: align workflows with electron-vite-vue#540 * chore: update test, tsconfig and deps * chore: update deps and debug config * chore: refresh style * docs: update readme * docs: make linter happy * ci: bump versions * chore: refactor update handling and improve UI elements * 1.0.0
This commit is contained in:
39 files changed
+855
-916
No files matched your search
@@ -1,51 +1,55 @@
|
||||
# electron-auto-update
|
||||
# electron-updater
|
||||
|
||||
[English](README.md) | 简体中文
|
||||
|
||||
使用`electron-updater`实现electron程序的更新检测、下载和安装等功能。
|
||||
使用 `electron-updater` 检测、下载并安装 Electron 应用更新。
|
||||
|
||||
```sh
|
||||
npm i electron-updater
|
||||
pnpm add electron-updater
|
||||
```
|
||||
|
||||
### 主要逻辑
|
||||
## 主要流程
|
||||
|
||||
1. ##### 更新地址、更新信息脚本的配置
|
||||
### 1. 配置更新服务
|
||||
|
||||
在`electron-builder.json5`添加`publish`字段,用来配置更新地址和使用哪种策略作为更新服务
|
||||
在 `electron-builder.json` 中添加 `publish` 字段,用来配置更新地址和 provider。
|
||||
|
||||
``` json5
|
||||
{
|
||||
"publish": {
|
||||
"provider": "generic", // 提供者、提供商
|
||||
"channel": "latest", // 生成yml文件的名称
|
||||
"url": "https://foo.com/" //更新地址
|
||||
}
|
||||
}
|
||||
```
|
||||
```json5
|
||||
{
|
||||
publish: {
|
||||
provider: 'generic',
|
||||
channel: 'latest',
|
||||
url: 'https://foo.com/',
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
更多见 : [electron-builder.json5...](xxx)
|
||||
更多详情请见:[electron-builder.json](https://github.com/electron-vite/electron-vite-react/blob/main/electron-builder.json)
|
||||
|
||||
2. ##### Electron更新逻辑
|
||||
### 2. 主进程更新逻辑
|
||||
|
||||
- 检测更新是否可用;
|
||||
本项目保持 `autoDownload` 关闭,因此下载需要由用户手动触发。
|
||||
|
||||
- 检测服务端的软件版本;
|
||||
- `check-update` 会在打包后调用 `autoUpdater.checkForUpdates()`。
|
||||
- 主进程在收到 `update-available` 或 `update-not-available` 时,会向渲染进程发送 `update-can-available`。
|
||||
- `start-download` 会开始下载更新,并把下载进度转发到渲染进程。
|
||||
- `cancel-download` 会取消当前下载,并重置取消令牌。
|
||||
- `quit-and-install` 会安装已下载的更新并重启应用。
|
||||
|
||||
- 检测更新是否可用;
|
||||
更多详情请见:[update.ts](https://github.com/electron-vite/electron-vite-react/blob/main/electron/main/update.ts)
|
||||
|
||||
- 下载服务端新版软件(当更新可用);
|
||||
- 安装方式;
|
||||
### 3. 渲染进程 UI
|
||||
|
||||
更多见 : [update...](https://github.com/electron-vite/electron-vite-react/blob/main/electron/main/update.ts)
|
||||
更新页面是用户触发上述流程的入口,用户通过页面按钮触发 Electron 的更新动作。
|
||||
|
||||
3. ##### Electron更新UI页面
|
||||
- 点击 **Check update** 触发 `check-update`。
|
||||
- 如果发现新版本,页面会允许用户开始或取消下载。
|
||||
- 下载完成后,页面会切换为 **Install now**。
|
||||
|
||||
主要功能是:用户触发上述(2.)更新逻辑的UI页面。用户可以通过点击页面触发electron更新的不同功能。
|
||||
更多见 : [components/update.ts...](https://github.com/electron-vite/electron-vite-react/tree/main/src/components/update/index.tsx)
|
||||
更多详情请见:[components/update/index.tsx](https://github.com/electron-vite/electron-vite-react/blob/main/src/components/update/index.tsx)
|
||||
|
||||
---
|
||||
|
||||
这里建议更新触发以用户操作触发(本项目的以用户点击 **更新检测** 后触发electron更新功能)
|
||||
建议通过用户操作触发更新。在本项目中,流程从用户点击 **Check update** 开始。
|
||||
|
||||
关于更多使用`electron-updater`进行electron更新,见文档:[auto-update](https://www.electron.build/.html)
|
||||
更多使用 `electron-updater` 的信息请参考 [官方文档](https://www.electron.build)
|
||||
Reference in new issue
Block a user