Files
ele-HeiXiu/shared/types/logging.ts
YoungestSongMo 6204c14b88 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 同步更新架构图和流程说明
2026-06-04 18:31:52 +08:00

53 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// ============================================================
// 日志模块 — 共享类型定义(主进程 + 渲染进程双端使用)
// ============================================================
/** 日志级别 */
export type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
/** 日志分类 */
export type LogCategory =
| 'request' // HTTP 请求相关
| 'auth' // 登录 / Token / 权限
| 'updater' // 自动更新
| 'event' // 事件总线
| 'app' // 应用生命周期
| 'ui' // UI 层错误 / 警告
| 'ipc' // IPC 通信
| 'safe-storage'; // 安全存储safeStorage 加密/解密)
/**
* 结构化错误快照
* Error 对象不可 JSON 序列化,提取关键字段保存
*/
export interface LogErrorSnapshot {
/** 错误名称Error.name 或 constructor name */
name: string;
/** 错误消息 */
message: string;
/** 堆栈信息(可选,按需记录以节省空间) */
stack?: string;
/** 原始错误链cause的消息摘要 */
cause?: string;
}
/**
* 单条日志条目JSON Lines 中的一行)
*/
export interface LogEntry {
/** ISO 8601 时间戳(例如 "2026-06-04T10:30:00.123Z" */
timestamp: string;
/** 日志级别 */
level: LogLevel;
/** 日志分类 */
category: LogCategory;
/** 日志消息(简短描述) */
message: string;
/** 日志来源进程 */
processType: 'main' | 'renderer';
/** 附加上下文(需 JSON 可序列化) */
context?: Record<string, unknown>;
/** 错误快照(仅在 warn / error 级别时填充) */
error?: LogErrorSnapshot;
}