feat: 重构更新流程 — 无更新不抛异常、用户决定下载、更新详情展示(md文件中的)
【核心重构】
- getLatestVersion() 不再 throw Error,无更新时返回 { version: APP_VERSION }
- checkForUpdates() 先自行预检 → 无更新直发 IPC,有更新才交 electron-updater
- 移除 NO_UPDATE_MESSAGE 常量及所有字符串匹配拦截代码
- HeiXiuProvider 增加 500ms TTL 缓存,避免预检+electron-updater 重复请求 API
【用户体验】
- 检查到新版本后不再自动下载,展示更新内容供用户决定
- 新增"下载更新"按钮(与"安装更新"分离为两步操作)
- 设置页新增"查看详情"弹窗,Markdown 格式化渲染更新日志
- available / downloading / downloaded 三个状态 UI 独立展示
【Bug 修复】
- 测试服务器版本排序:字符串序 → 语义版本序(_version_key),0.0.10 正确 > 0.0.9
- 版本比较:!= → <(_version_key),防止高版本误判为有更新
- get_best_release fallback 同样改为语义版本排序
- Windows cmd set 命令尾部空格 → Invalid URL(.trim() 修复)
- electron-updater 'error' 事件中拦截 NO_UPDATE_MESSAGE → UPDATE_NOT_AVAILABLE
【文档更新】
- CHANGELOG.md、PROJECT.md、UpdateA.md 同步更新架构图和流程说明
This commit is contained in:
@@ -167,12 +167,14 @@ NavBar / 设置页 → AppProvider.logout()
|
||||
3. `XxxAPI` class — 静态方法,调用方式 `XxxAPI.method()`
|
||||
|
||||
示例:
|
||||
|
||||
```ts
|
||||
// auth.ts
|
||||
const AuthUrlObj = { login: '/api/v1/auth/login', ... } as const;
|
||||
const AuthUrlObj = {login: '/api/v1/auth/login', ...} as const;
|
||||
|
||||
export interface LoginRequestBody { ... }
|
||||
export interface LoginResponseBody { ... }
|
||||
export interface LoginRequestBody {}
|
||||
|
||||
export interface LoginResponseBody {}
|
||||
|
||||
export class AuthAPI {
|
||||
static login(data: LoginRequestBody): Promise<LoginResponseBody> {
|
||||
@@ -185,19 +187,37 @@ export class AuthAPI {
|
||||
|
||||
## 数据存储(localStorage)
|
||||
|
||||
| Key | 类型 | 说明 |
|
||||
|-----|------|------|
|
||||
| `ele-heixiu-token` | `string` | JWT access_token |
|
||||
| `ele-heixiu-refresh-token` | `string` | JWT refresh_token |
|
||||
| `ele-heixiu-device-id` | `string`(UUID v4) | 设备唯一标识,首次自动生成 |
|
||||
| `ele-heixiu-auth` | `{ username, remember, autoLogin }` | 记住账号偏好(**不存密码**) |
|
||||
| Key | 类型 | 说明 |
|
||||
|----------------------------|-------------------------------------|-------------------|
|
||||
| `ele-heixiu-token` | `string` | JWT access_token |
|
||||
| `ele-heixiu-refresh-token` | `string` | JWT refresh_token |
|
||||
| `ele-heixiu-device-id` | `string`(UUID v4) | 设备唯一标识,首次自动生成 |
|
||||
| `ele-heixiu-auth` | `{ username, remember, autoLogin }` | 记住账号偏好(**不存密码**) |
|
||||
|
||||
---
|
||||
|
||||
## 环境变量
|
||||
|
||||
| 变量 | 开发值 | 生产值 |
|
||||
|------|--------|--------|
|
||||
| `VITE_API_BASE_URL` | `http://8.160.179.64:8000` | `https://www.heixiu.net` |
|
||||
| `VITE_EDITION` | `personal` | `personal` / `enterprise` |
|
||||
| `UPDATE_API_URL` | — | `https://www.heixiu.com` |
|
||||
### 主进程加载顺序(由高到低优先级)
|
||||
|
||||
1. **OS 环境变量** — `set KEY=VALUE && .\app.exe`,不覆盖已有值
|
||||
2. **`.env.local`** — 不进 git,个人覆盖(打包后连测试服务器等特殊场景)
|
||||
3. **`.env.{mode}`** — 开发:`.env.development`,构建:`.env.production`
|
||||
4. **代码默认值** — `updater.ts` 内 `getApiBaseUrl()` 的 fallback
|
||||
|
||||
> **安全说明**:`UPDATE_API_URL` 是公开的 API 端点地址,不是密钥。反编译 ASAR 可看到,但这不影响安全——应用本身就要连到这个地址。真正的敏感信息(JWT
|
||||
> token、密码)是运行时获取的,不写死在代码中。
|
||||
|
||||
### 渲染进程(Vite 编译时注入)
|
||||
|
||||
| 变量 | 开发值 | 生产值 |
|
||||
|---------------------|----------------------------|---------------------------|
|
||||
| `VITE_API_BASE_URL` | `http://8.160.179.64:8000` | `https://www.heixiu.net` |
|
||||
| `VITE_EDITION` | `personal` | `personal` / `enterprise` |
|
||||
|
||||
### 主进程(Node.js 运行时读取)
|
||||
|
||||
| 变量 | 开发值(.env.development) | 生产值(.env.production) | 默认值 |
|
||||
|------------------|-------------------------|--------------------------|--------------------------|
|
||||
| `UPDATE_API_URL` | `http://127.0.0.1:8000` | `https://www.heixiu.com` | `https://www.heixiu.com` |
|
||||
| `EDITION` | `personal` | `personal` | `personal` |
|
||||
|
||||
Reference in New Issue
Block a user