From 2fc312870c4b8918633259304dcf766e5fa40de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7?= <308487730@qq.com> Date: Wed, 15 Mar 2023 09:20:30 +0800 Subject: [PATCH] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 78748a44d4c75da489517fd6ce09397530b37fdb Author: 草鞋没号 <308487730@qq.com> Date: Wed Mar 15 09:16:10 2023 +0800 chore: cleanup commit dd5ff0674d83de9e5d97d661c10924bdc795a412 Author: Jimmy Date: Tue Mar 14 21:12:33 2023 +0800 docs : add `electron-auto-update` docs --- README.md | 5 +++ README.zh-CN.md | 7 +++- electron-builder.json5 | 10 +++--- src/components/update/README.md | 49 +++++++++++++++++++++++++ src/components/update/README.zh-CN.md | 51 +++++++++++++++++++++++++++ 5 files changed, 116 insertions(+), 6 deletions(-) create mode 100644 src/components/update/README.md create mode 100644 src/components/update/README.zh-CN.md diff --git a/README.md b/README.md index f118b9a..0ccecac 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,11 @@ export default { } ``` +## 🔧 Additional features + +1. electron-updater 👉 [see docs](src/components/update/README.md) +1. playwright + ## ❔ FAQ - [dependencies vs devDependencies](https://github.com/electron-vite/vite-plugin-electron-renderer#dependencies-vs-devdependencies) diff --git a/README.zh-CN.md b/README.zh-CN.md index f7784fe..2cdd50f 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -67,7 +67,12 @@ export default { } ``` -## FAQ +## 🔧 额外的功能 + +1. Electron 自动更新 👉 [阅读文档](src/components/update/README.zh-CN.md) +2. Playwright 测试 + +## ❔ FAQ - [dependencies vs devDependencies](https://github.com/electron-vite/vite-plugin-electron-renderer#dependencies-vs-devdependencies) - [C/C++ addons, Node.js modules - Pre-Bundling](https://github.com/electron-vite/vite-plugin-electron-renderer#dependency-pre-bundling) diff --git a/electron-builder.json5 b/electron-builder.json5 index e568aa9..6c82482 100644 --- a/electron-builder.json5 +++ b/electron-builder.json5 @@ -35,9 +35,9 @@ "allowToChangeInstallationDirectory": true, "deleteAppDataOnUninstall": false }, - publish:{ - provider: 'generic', - channel: 'latest', - url: 'https://github.com/electron-vite/electron-vite-react/releases/download/v0.9.9/', + "publish": { + "provider": "generic", + "channel": "latest", + "url": "https://github.com/electron-vite/electron-vite-react/releases/download/v0.9.9/" } -} \ No newline at end of file +} diff --git a/src/components/update/README.md b/src/components/update/README.md new file mode 100644 index 0000000..d119a11 --- /dev/null +++ b/src/components/update/README.md @@ -0,0 +1,49 @@ +# electron-updater + +English | [简体中文](README.zh-CN.md) + +> Use `electron-updater` to realize the update detection, download and installation of the electric program. + +```sh +npm i electron-updater +``` + +### Main logic + +1. ##### Configuration of the update the service address and update information script: + + Add a `publish` field to `electron-builder.json5` for configuring the update address and which strategy to use as the update service. + + ``` json5 + { + "publish": { + "provider": "generic", + "channel": "latest", + "url": "https://foo.com/" + } + } + ``` + + For more information, please refer to : [electron-builder.json5...](https://github.com/electron-vite/electron-vite-react/blob/2f2880a9f19de50ff14a0785b32a4d5427477e55/electron-builder.json5#L38) + +2. ##### The update logic of Electron: + + - Checking if an update is available; + - Checking the version of the software on the server; + - Checking if an update is available; + - Downloading the new version of the software from the server (when an update is available); + - Installation method; + + For more information, please refer to : [update...](https://github.com/electron-vite/electron-vite-react/blob/main/electron/main/update.ts) + +3. ##### Updating UI pages in Electron: + + The main function is to provide a UI page for users to trigger the update logic mentioned in (2.) above. Users can click on the page to trigger different update functions in Electron. + + For more information, please refer to : [components/update...](https://github.com/electron-vite/electron-vite-react/blob/main/src/components/update/index.tsx) + +--- + +Here it is recommended to trigger updates through user actions (in this project, Electron update function is triggered after the user clicks on the "Check for updates" button). + +For more information on using `electron-updater` for Electron updates, please refer to the documentation : [auto-update](https://www.electron.build/.html) diff --git a/src/components/update/README.zh-CN.md b/src/components/update/README.zh-CN.md new file mode 100644 index 0000000..b556c0e --- /dev/null +++ b/src/components/update/README.zh-CN.md @@ -0,0 +1,51 @@ +# electron-auto-update + +[English](README.md) | 简体中文 + +使用`electron-updater`实现electron程序的更新检测、下载和安装等功能。 + +```sh +npm i electron-updater +``` + +### 主要逻辑 + +1. ##### 更新地址、更新信息脚本的配置 + + 在`electron-builder.json5`添加`publish`字段,用来配置更新地址和使用哪种策略作为更新服务 + +``` json5 +{ + "publish": { + "provider": "generic", // 提供者、提供商 + "channel": "latest", // 生成yml文件的名称 + "url": "https://foo.com/" //更新地址 + } +} +``` + +更多见 : [electron-builder.json5...](xxx) + +2. ##### Electron更新逻辑 + + - 检测更新是否可用; + + - 检测服务端的软件版本; + + - 检测更新是否可用; + + - 下载服务端新版软件(当更新可用); + - 安装方式; + + 更多见 : [update...](https://github.com/electron-vite/electron-vite-react/blob/main/electron/main/update.ts) + +3. ##### Electron更新UI页面 + + 主要功能是:用户触发上述(2.)更新逻辑的UI页面。用户可以通过点击页面触发electron更新的不同功能。 + 更多见 : [components/update.ts...](https://github.com/electron-vite/electron-vite-react/tree/main/src/components/update/index.tsx) + +--- + +这里建议更新触发以用户操作触发(本项目的以用户点击 **更新检测** 后触发electron更新功能) + +关于更多使用`electron-updater`进行electron更新,见文档:[auto-update](https://www.electron.build/.html)