git状态以及文化管理器优化

This commit is contained in:
2025-08-09 18:01:59 +08:00
parent 1f13548039
commit 3bf68960a1
8 changed files with 1758 additions and 62 deletions

View File

@@ -261,4 +261,31 @@ pub async fn watch_directory(
}).map_err(|e| e.to_string())?;
Ok(())
}
/// 获取文件树(简化版,供文件浏览器使用)
#[tauri::command]
pub async fn get_file_tree(project_path: String) -> Result<Vec<FileNode>, String> {
let path = Path::new(&project_path);
if !path.exists() {
return Err(format!("Path does not exist: {}", path.display()));
}
let ignore_patterns = vec![
String::from("node_modules"),
String::from(".git"),
String::from("target"),
String::from("dist"),
String::from("build"),
String::from(".idea"),
String::from(".vscode"),
String::from("__pycache__"),
String::from(".DS_Store"),
];
let root_node = read_directory_recursive(path, 0, 3, &ignore_patterns)
.map_err(|e| e.to_string())?;
// Return children of root node if it has any
Ok(root_node.children.unwrap_or_default())
}

View File

@@ -423,4 +423,11 @@ pub async fn get_git_diff(
}
Ok(String::from_utf8_lossy(&diff_output.stdout).to_string())
}
/// 获取 Git 提交列表(简化版)
#[tauri::command]
pub async fn get_git_commits(project_path: String, limit: usize) -> Result<Vec<GitCommit>, String> {
// 使用已有的 get_git_history 函数,直接传递 limit 参数
get_git_history(project_path, Some(limit), None).await
}