新增: 初始化 DevFlow 项目仓库

Tauri 2 + Vue 3 + Vite 6 桌面应用,Rust workspace 含 13 个 crate
(df-ai / df-storage / df-workflow / df-core / df-execute 等)。
核心能力:AI 聊天 agentic 循环(工具调用+人工审批)、工作流引擎、
任务/想法/项目/阶段管理、可追溯性,及配套前端组件。
This commit is contained in:
2026-06-12 01:31:05 +08:00
commit 98393b4908
178 changed files with 27859 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
//! 项目相关命令
use serde::Deserialize;
use tauri::State;
use df_core::types::new_id;
use df_storage::models::ProjectRecord;
use crate::state::AppState;
use super::now_millis;
/// 创建项目入参
#[derive(Debug, Deserialize)]
pub struct CreateProjectInput {
pub name: String,
#[serde(default)]
pub description: String,
pub idea_id: Option<String>,
}
/// 列出全部项目
#[tauri::command]
pub async fn list_projects(state: State<'_, AppState>) -> Result<Vec<ProjectRecord>, String> {
state.projects.list_all().await.map_err(|e| e.to_string())
}
/// 创建项目,返回完整记录
#[tauri::command]
pub async fn create_project(
state: State<'_, AppState>,
input: CreateProjectInput,
) -> Result<ProjectRecord, String> {
let now = now_millis();
let record = ProjectRecord {
id: new_id(),
name: input.name,
description: input.description,
status: "planning".to_string(),
idea_id: input.idea_id,
created_at: now.clone(),
updated_at: now,
};
state
.projects
.insert(record.clone())
.await
.map_err(|e| e.to_string())?;
Ok(record)
}
/// 按 ID 查询项目
#[tauri::command]
pub async fn get_project(
state: State<'_, AppState>,
id: String,
) -> Result<Option<ProjectRecord>, String> {
state
.projects
.get_by_id(&id)
.await
.map_err(|e| e.to_string())
}
/// 更新项目单个字段(字段名走 df-storage 白名单校验)
#[tauri::command]
pub async fn update_project(
state: State<'_, AppState>,
id: String,
field: String,
value: String,
) -> Result<bool, String> {
state
.projects
.update_field(&id, &field, &value)
.await
.map_err(|e| e.to_string())
}
/// 删除项目
#[tauri::command]
pub async fn delete_project(state: State<'_, AppState>, id: String) -> Result<bool, String> {
state.projects.delete(&id).await.map_err(|e| e.to_string())
}