Files
ele-HeiXiu/shared/types/index.ts
YoungestSongMo ae733016bb feat: 日志模块 + netRequest 封装 + PROJECT.md 更新
日志模块(文件持久化 + 事件总线联动 + 脱敏)
    新增:
      - shared/types/logging.ts         — LogLevel / LogCategory / LogEntry 类型
      - electron/main/logger.ts         — 主进程日志核心(JSON Lines / 每日轮转 / 7天清理)
      - electron/main/log-ipc.ts        — 渲染进程日志 IPC 通道接收
      - src/utils/logger.ts             — 渲染进程日志器(IPC 转发 / DEV 控制台 / 事件总线钩子)
      - shared/utils/sanitize.ts        — 脱敏工具(ID哈希 / 邮箱 / 手机 / 名称 / Token)
    修改:
      - electron/main.ts                — initLogger + flushLogger + uncaughtException
      - src/main.tsx                    — renderer 全局错误捕获
      - src/utils/event-bus.ts          — setEventLogListener 钩子,emit 自动审计
      - src/services/request.ts         — 拦截器结构化错误分级记录
      - electron/main/updater.ts        — 14处 console → logger 迁移
      - src/components/AppProvider.tsx   — 登录/登出/自动登录 auth 事件日志
      - shared/constants/ipc-channels.ts — 新增 LOG_MESSAGE 通道

  netRequest 封装(Electron net.request 的 axios 风格 API)
    新增:
      - electron/main/net-request.ts     — netRequest.get/post/put/del 命名空间
    修改:
      - electron/main/updater.ts         — fetchUpdateInfo 改用 netRequest(22→12行)

  文档更新
    - PROJECT.md                       — 目录结构 / 状态管理 / 日志系统 / IPC 章节同步现状
    - TODO.md                          — 增量更新改造 + 日志模块待办
    - UpdateA.md                       — API blockmap 字段 / 数据库字段说明
2026-06-04 11:03:25 +08:00

78 lines
2.1 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 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;
}