| 76 | /// 在系统文件管理器中打开文件夹 |
| 77 | #[tauri::command] |
| 78 | pub fn open_folder(path: String) -> Result<(), String> { |
| 79 | #[cfg(target_os = "windows")] |
| 80 | { |
| 81 | let normalized_path = path.replace('/', "\\"); |
| 82 | Command::new("explorer") |
| 83 | .arg(&normalized_path) |
| 84 | .spawn() |
| 85 | .map_err(|e| format!("Failed to open folder: {}", e))?; |
| 86 | } |
| 87 | |
| 88 | #[cfg(target_os = "macos")] |
| 89 | { |
| 90 | Command::new("open") |
| 91 | .arg(&path) |
| 92 | .spawn() |
| 93 | .map_err(|e| format!("Failed to open folder: {}", e))?; |
| 94 | } |
| 95 | |
| 96 | #[cfg(target_os = "linux")] |
| 97 | { |
| 98 | Command::new("xdg-open") |
| 99 | .arg(&path) |
| 100 | .spawn() |
| 101 | .map_err(|e| format!("Failed to open folder: {}", e))?; |
| 102 | } |
| 103 | |
| 104 | Ok(()) |
| 105 | } |
| 106 | |
| 107 | /// Show file in system file explorer |
| 108 | #[tauri::command] |