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
}

View File

@@ -62,10 +62,10 @@ use commands::packycode_nodes::{
};
use commands::filesystem::{
read_directory_tree, search_files_by_name, get_file_info, watch_directory,
read_file, write_file,
read_file, write_file, get_file_tree,
};
use commands::git::{
get_git_status, get_git_history, get_git_branches, get_git_diff,
get_git_status, get_git_history, get_git_branches, get_git_diff, get_git_commits,
};
use process::ProcessRegistryState;
use std::sync::Mutex;
@@ -311,12 +311,14 @@ fn main() {
watch_directory,
read_file,
write_file,
get_file_tree,
// Git
get_git_status,
get_git_history,
get_git_branches,
get_git_diff,
get_git_commits,
])
.run(tauri::generate_context!())
.expect("error while running tauri application");

View File

@@ -19,7 +19,7 @@
test result: ok. 58 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
```
### Implementation Details:
### Implementation Details:q
#### Real Claude Execution:
- `execute_claude_task()` - Executes Claude with specified task and captures output