新增: 初始化 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,91 @@
//! 任务相关命令
use serde::Deserialize;
use tauri::State;
use df_core::types::new_id;
use df_storage::models::TaskRecord;
use crate::state::AppState;
use super::now_millis;
/// 创建任务入参
#[derive(Debug, Deserialize)]
pub struct CreateTaskInput {
pub project_id: String,
pub title: String,
#[serde(default)]
pub description: String,
#[serde(default = "default_priority")]
pub priority: i32,
pub branch_name: Option<String>,
pub assignee: Option<String>,
}
fn default_priority() -> i32 {
1
}
/// 列出任务,可按 project_id 过滤
#[tauri::command]
pub async fn list_tasks(
state: State<'_, AppState>,
project_id: Option<String>,
) -> Result<Vec<TaskRecord>, String> {
let result = match project_id {
Some(pid) => state.tasks.query("project_id", &pid).await,
None => state.tasks.list_all().await,
};
result.map_err(|e| e.to_string())
}
/// 创建任务,返回完整记录
#[tauri::command]
pub async fn create_task(
state: State<'_, AppState>,
input: CreateTaskInput,
) -> Result<TaskRecord, String> {
let now = now_millis();
let record = TaskRecord {
id: new_id(),
project_id: input.project_id,
title: input.title,
description: input.description,
status: "todo".to_string(),
priority: input.priority,
branch_name: input.branch_name,
assignee: input.assignee,
workflow_def_id: None,
base_branch: None,
created_at: now.clone(),
updated_at: now,
};
state
.tasks
.insert(record.clone())
.await
.map_err(|e| e.to_string())?;
Ok(record)
}
/// 更新任务单个字段(字段名走 df-storage 白名单校验)
#[tauri::command]
pub async fn update_task(
state: State<'_, AppState>,
id: String,
field: String,
value: String,
) -> Result<bool, String> {
state
.tasks
.update_field(&id, &field, &value)
.await
.map_err(|e| e.to_string())
}
/// 删除任务
#[tauri::command]
pub async fn delete_task(state: State<'_, AppState>, id: String) -> Result<bool, String> {
state.tasks.delete(&id).await.map_err(|e| e.to_string())
}