Feat: Open in File Explorer

This commit is contained in:
Youwes09
2026-04-11 23:04:26 -05:00
parent 4a299f60ac
commit 49562c3f76
2 changed files with 77 additions and 2 deletions
+28
View File
@@ -587,6 +587,33 @@ fn restart_app(app: tauri::AppHandle) {
tauri::process::restart(&app.env());
}
#[tauri::command]
fn open_path(path: String) -> Result<(), String> {
let p = std::path::Path::new(path.trim());
#[cfg(target_os = "windows")]
{
std::process::Command::new("explorer")
.arg(p)
.spawn()
.map_err(|e| e.to_string())?;
}
#[cfg(target_os = "macos")]
{
std::process::Command::new("open")
.arg(p)
.spawn()
.map_err(|e| e.to_string())?;
}
#[cfg(not(any(target_os = "windows", target_os = "macos")))]
{
std::process::Command::new("xdg-open")
.arg(p)
.spawn()
.map_err(|e| e.to_string())?;
}
Ok(())
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
@@ -610,6 +637,7 @@ pub fn run() {
list_releases,
download_and_install_update,
restart_app,
open_path,
])
.setup(|_app| Ok(()))
.on_window_event(|window, event| {