feat(files): 文件管理四项——侧栏拖拽移动、草稿跨窗口认领、未命名默认存根目录、打开所在位置(docs/25)
This commit is contained in:
@@ -427,6 +427,21 @@ pub fn create_dir(path: String) -> Result<(), String> {
|
||||
}
|
||||
|
||||
/// 重命名/移动文件或文件夹;目标已存在时报错。
|
||||
/// 在 Windows 资源管理器中定位路径:打开父目录并选中该文件/文件夹。
|
||||
/// explorer 即使成功也常以退出码 1 结束,因此只 spawn 不等结果。
|
||||
#[tauri::command]
|
||||
pub fn reveal_in_explorer(path: String) -> Result<(), String> {
|
||||
if !Path::new(&path).exists() {
|
||||
return Err("路径不存在".to_string());
|
||||
}
|
||||
std::process::Command::new("explorer")
|
||||
.arg(format!("/select,{path}"))
|
||||
.spawn()
|
||||
.map_err(|e| format!("打开资源管理器失败:{e}"))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[tauri::command]
|
||||
pub fn rename_path(from: String, to: String) -> Result<(), String> {
|
||||
if Path::new(&to).exists() {
|
||||
|
||||
@@ -31,6 +31,7 @@ pub fn run() {
|
||||
commands::create_text_file,
|
||||
commands::create_dir,
|
||||
commands::rename_path,
|
||||
commands::reveal_in_explorer,
|
||||
commands::delete_to_trash,
|
||||
commands::db_recent_list,
|
||||
commands::db_recent_add,
|
||||
|
||||
Reference in New Issue
Block a user