Files
DevFlow/docs/01-技术文档/Tauri-IPC模式-2026-06-12.md
绝尘 f3c0967f41 修复: AR-3 审批 reason 查项目名拼对象名(用户再反馈 P0)
build_approval_reason 改 async + 接收 db,对 delete/restore/purge/update/bind/create_task 的 id/project_id 查 ProjectRepo.get_by_id 拼「项目名」(id=x)(原只拼裸 id,用户反馈'只返回 ID 不知道是什么数据')
新增 resolve_project_label helper;process_tool_calls 调用改 await
来源 aichat审查报告 第二章 + 用户 2026-06-14 再反馈;cargo 0 err
2026-06-14 17:16:28 +08:00

1.2 KiB

Tauri IPC 模式

创建: 2026-06-10 | 状态: 初稿


概述

Tauri v2 的 IPC 机制是 DevFlow 前后端通信的核心桥梁。本文档描述 DevFlow 中 Tauri IPC 的设计模式。

当前状态

  • Tauri Commands: 仅 greet 示例命令
  • 业务 IPC: 待实施

设计要点

待实施内容

  1. Command 定义 — 在 src-tauri/src/commands/ 下按模块组织
  2. 序列化约定 — Rust 结构体 derive Serialize/Deserialize
  3. 错误传递Result<T, String> 返回给前端
  4. 流式支持 — AI 输出、Shell 输出的流式推送
  5. 状态注入 — 通过 tauri::State 共享 Rust 运行时状态

IPC 层次

Vue Component
  → Pinia Store (Action)
    → @tauri-apps/api (invoke)
      → Tauri Command (Rust)
        → Crate 业务逻辑
          → df-storage (SQLite)

命名约定

  • Rust command: #[tauri::command] fn get_projects(...)
  • 前端调用: invoke("get_projects", { ... })
  • Store action: async fetchProjects()

相关文件

  • src-tauri/src/main.rs — Tauri 入口
  • src-tauri/src/commands/ — IPC 命令目录
  • frontend/src/stores/ — Pinia Store