fix(folders): add open_folder Tauri command for path-based opens

This commit is contained in:
xintaofei
2026-04-22 10:53:17 +08:00
parent c691fb0c07
commit f0b3ec20a8
2 changed files with 16 additions and 0 deletions

View File

@@ -544,6 +544,21 @@ pub async fn list_all_folder_details(
.map_err(AppCommandError::from) .map_err(AppCommandError::from)
} }
#[cfg(feature = "tauri-runtime")]
#[cfg_attr(feature = "tauri-runtime", tauri::command)]
pub async fn open_folder(
db: tauri::State<'_, AppDatabase>,
path: String,
) -> Result<FolderDetail, AppCommandError> {
let entry = folder_service::add_folder(&db.conn, &path)
.await
.map_err(AppCommandError::from)?;
folder_service::get_folder_by_id(&db.conn, entry.id)
.await
.map_err(AppCommandError::from)?
.ok_or_else(|| AppCommandError::not_found("Folder not found after add"))
}
#[cfg(feature = "tauri-runtime")] #[cfg(feature = "tauri-runtime")]
#[cfg_attr(feature = "tauri-runtime", tauri::command)] #[cfg_attr(feature = "tauri-runtime", tauri::command)]
pub async fn open_folder_by_id( pub async fn open_folder_by_id(

View File

@@ -220,6 +220,7 @@ mod tauri_app {
folders::get_folder, folders::get_folder,
folders::list_open_folder_details, folders::list_open_folder_details,
folders::list_all_folder_details, folders::list_all_folder_details,
folders::open_folder,
folders::open_folder_by_id, folders::open_folder_by_id,
folders::remove_folder_from_workspace, folders::remove_folder_from_workspace,
folders::add_folder_to_history, folders::add_folder_to_history,