feat: refine tool UI and result actions
This commit is contained in:
24
src-tauri/src/commands/file.rs
Normal file
24
src-tauri/src/commands/file.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use tauri::{AppHandle, Manager};
|
||||
use tauri_plugin_opener::OpenerExt;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn reveal_path(app: AppHandle, path: String) -> Result<(), String> {
|
||||
app.opener()
|
||||
.reveal_item_in_dir(path)
|
||||
.map_err(|error| error.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn open_generated_dir(app: AppHandle) -> Result<(), String> {
|
||||
let dir = app
|
||||
.path()
|
||||
.app_data_dir()
|
||||
.map_err(|error| error.to_string())?
|
||||
.join("images")
|
||||
.join("generated");
|
||||
|
||||
std::fs::create_dir_all(&dir).map_err(|error| error.to_string())?;
|
||||
app.opener()
|
||||
.open_path(dir.to_string_lossy().to_string(), None::<&str>)
|
||||
.map_err(|error| error.to_string())
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
pub mod dialog;
|
||||
pub mod file;
|
||||
pub mod generation;
|
||||
pub mod provider;
|
||||
|
||||
@@ -54,6 +54,8 @@ pub fn run() {
|
||||
commands::provider::upsert_provider,
|
||||
commands::provider::delete_provider,
|
||||
commands::dialog::pick_material_images,
|
||||
commands::file::reveal_path,
|
||||
commands::file::open_generated_dir,
|
||||
commands::generation::create_generation_task,
|
||||
commands::generation::generate_image,
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user