【核心重构】
- 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 同步更新架构图和流程说明
82 lines
2.3 KiB
TypeScript
82 lines
2.3 KiB
TypeScript
// ============================================================
|
||
// 共享类型定义 —— 主进程 & 渲染进程通用
|
||
// ============================================================
|
||
|
||
/** 平台类型 */
|
||
export type Platform = 'win32' | 'darwin' | 'linux';
|
||
|
||
/** 窗口标识 */
|
||
export interface WindowIdentity {
|
||
/** 窗口唯一 ID */
|
||
id: number;
|
||
/** 窗口类型标识 */
|
||
type: 'main' | 'settings' | 'preview' | 'custom';
|
||
/** 窗口标题 */
|
||
title: string;
|
||
}
|
||
|
||
/** IPC 响应包装 */
|
||
export interface IpcResponse<T = unknown> {
|
||
success: boolean;
|
||
data?: T;
|
||
error?: string;
|
||
}
|
||
|
||
/** 主题模式 */
|
||
export type ThemeMode = 'light' | 'dark' | 'system';
|
||
|
||
/** 版本类型 */
|
||
export type Edition = 'enterprise' | 'personal';
|
||
|
||
/** 应用配置 */
|
||
export interface AppConfig {
|
||
themeMode: ThemeMode;
|
||
language: string;
|
||
autoLaunch: boolean;
|
||
minimizeToTray: boolean;
|
||
}
|
||
|
||
// ============================================================
|
||
// 更新相关类型
|
||
// ============================================================
|
||
|
||
// ============================================================
|
||
// 日志类型(从 logging.ts 重导出)
|
||
// ============================================================
|
||
|
||
export type { LogLevel, LogCategory, LogErrorSnapshot, LogEntry } from './logging';
|
||
|
||
/** 更新检查请求参数 */
|
||
export interface UpdateCheckParams {
|
||
platform: Platform;
|
||
version: string;
|
||
edition: Edition;
|
||
channel?: 'stable' | 'beta' | 'alpha';
|
||
}
|
||
|
||
/** 更新检查响应(API 返回的 data 字段) */
|
||
export interface UpdateCheckResult {
|
||
/** 是否有可用更新 */
|
||
hasUpdate: boolean;
|
||
/** 最新版本号 */
|
||
latestVersion: string;
|
||
/** 安装包下载地址 */
|
||
downloadUrl: string;
|
||
/** 安装包大小(字节) */
|
||
fileSize: number;
|
||
/** SHA512 校验值 */
|
||
sha512: string;
|
||
/** 更新日志(支持 Markdown) */
|
||
changelog: string;
|
||
/** 发布日期 */
|
||
releaseDate: string;
|
||
/** 是否强制更新 */
|
||
forceUpdate: boolean;
|
||
/** 最低兼容版本(低于此版本必须强制更新) */
|
||
minimumVersion: string;
|
||
/** Blockmap 文件下载地址(可选,用于增量更新) */
|
||
blockMapUrl?: string;
|
||
/** Blockmap 文件大小(可选,>0 时客户端启用差分下载) */
|
||
blockMapSize?: number;
|
||
}
|