- Added AutoUpdater class to manage update checks and downloads. - Integrated auto-updater in the main process after the main window is created. - Enhanced preload script to expose update-related IPC channels. - Created UpdateDialog component to handle user interactions for updates. - Implemented state management for update status using Pinia store. - Added localization support for update messages in multiple languages. - Documented auto-update configuration steps for private GitHub repositories. - Created .env.example for GitHub token configuration.
61 lines
1.4 KiB
Markdown
61 lines
1.4 KiB
Markdown
# 自动更新配置
|
||
|
||
本项目使用 `electron-updater` 库实现自动更新功能,支持从私有 GitHub 仓库获取更新。
|
||
|
||
## 私有仓库配置
|
||
|
||
要启用私有仓库的自动更新功能,请按以下步骤操作:
|
||
|
||
### 1. 创建 GitHub Personal Access Token
|
||
|
||
1. 访问 GitHub 设置页面 (https://github.com/settings/tokens)
|
||
2. 点击 "Generate new token" (Classic tokens)
|
||
3. 选择适当的权限(至少需要 `repo` 权限来访问私有仓库)
|
||
4. 生成并复制 token
|
||
|
||
### 2. 配置环境变量
|
||
|
||
在项目根目录创建 `.env` 文件:
|
||
|
||
```bash
|
||
cp .env.example .env
|
||
```
|
||
|
||
编辑 `.env` 文件,添加你的 GitHub token:
|
||
|
||
```env
|
||
GH_TOKEN=your_github_personal_access_token
|
||
```
|
||
|
||
### 3. 构建配置
|
||
|
||
构建配置文件 `buildAssets/builder/config.js` 已经配置为使用环境变量中的 token:
|
||
|
||
```javascript
|
||
publish: [
|
||
{
|
||
provider: 'github',
|
||
owner: 'your_username',
|
||
repo: 'your_repository',
|
||
releaseType: 'release',
|
||
token: process.env.GH_TOKEN || '' // 从环境变量获取
|
||
}
|
||
]
|
||
```
|
||
|
||
## 发布更新
|
||
|
||
1. 更新 `package.json` 中的版本号
|
||
2. 提交更改并推送至 GitHub
|
||
3. 创建新的 GitHub Release
|
||
4. 运行构建命令:
|
||
|
||
```bash
|
||
pnpm build:all
|
||
```
|
||
|
||
## 注意事项
|
||
|
||
- 请确保 GitHub token 权限最小化,仅授予必要的访问权限
|
||
- 对于分发给公众的私有应用,用户需要有访问仓库的权限才能下载更新
|
||
- 在 CI/CD 环境中,确保在环境变量中配置了相应的 token |