新增: Rust 数据模型 + 颜色纯函数 + ts-rs 类型同步(B1)

- model.rs: 全部数据结构(Deck/Slide/Element/Style/Theme/AiCfg/LibItem/PageTemplate/ChatMessage/Op/RichSegment)
  所有结构体 derive Serialize/Deserialize/TS,自动生成 TS 类型到 bindings/types.ts
- color.rs: 颜色解析纯函数(resolve_color/resolve_bg/is_dark_bg/shade/hex_to_rgb)
  对应 store.ts 的颜色逻辑,23 个单元测试全部通过
- lib.rs: 新增 app_info IPC 命令
- ts-rs 自动生成的 bindings/types.ts 与手写 types.ts 类型一致
This commit is contained in:
2026-07-12 18:20:49 +08:00
parent b9a388b570
commit 1430e9e061
6 changed files with 626 additions and 5 deletions

View File

@@ -0,0 +1,33 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type AiCfg = { preset: string, protocol: string, base: string, key: string, model: string, proxy: string, img_base: string | null, img_key: string | null, img_model: string | null, };
export type AnimType = "fade-up" | "fade" | "scale" | "zoom" | "slide-l" | "slide-r" | "pop" | "rotate" | "bounce" | "flip" | "blur";
export type ChartItem = { label: string | null, value: number | null, };
export type ChartType = "bar" | "line" | "pie" | "area" | "doughnut" | "radar" | "hbar" | "progress";
export type ChatMessage = { role: string, content: string, };
export type Deck = { v: number, theme: string, slides: Array<Slide>, chat_id: string | null, };
export type ElementStyle = { font_size: number | null, color: string | null, align: string | null, bold: boolean | null, italic: boolean | null, anim: string | null, label: string | null, label_color: string | null, label_size: number | null, fit: string | null, shape_type: ShapeType | null, fill: string | null, gradient: boolean | null, opacity: number | null, radius: number | null, max: number | null, chart_type: ChartType | null, legend: boolean | null, stack: boolean | null, grid: boolean | null, header: boolean | null, lang: string | null, inline: boolean | null, icon: string | null, accent: string | null, };
export type ElementType = "title" | "text" | "list" | "stat" | "quote" | "image" | "shape" | "chart" | "card" | "table" | "code" | "formula";
export type LibItem = { id: string, name: string, deck: Deck, created_at: number, updated_at: number, };
export type PageTemplate = { id: string, name: string, category: string, background: string, elements: Array<SlideElement>, created_at: number | null, };
export type RichLine = { segments: Array<RichSegment>, };
export type RichSegment = { text: string, bold: boolean | null, italic: boolean | null, underline: boolean | null, strike: boolean | null, color: string | null, highlight: boolean | null, code: boolean | null, sup: boolean | null, sub: boolean | null, font_size: number | null, link: string | null, };
export type ShapeType = "rect" | "circle" | "triangle";
export type Slide = { id: string, background: string, elements: Array<SlideElement>, };
export type SlideElement = { id: string, type: string, x: number, y: number, w: number, h: number, content: string, style: ElementStyle, segments: Array<RichLine> | null, };
export type Theme = { name: string, primary: string, accent: string, bg: string, panel: string, text: string, muted: string, };