Skip to content

Commit

Permalink
versions in settings & bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KAJdev committed Jul 21, 2023
1 parent d710f32 commit 69d381a
Show file tree
Hide file tree
Showing 9 changed files with 242 additions and 103 deletions.
120 changes: 106 additions & 14 deletions packages/stablestudio-ui/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/stablestudio-ui/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tauri-build = { version = "1.4.0", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.4.1", features = [ "fs-all", "path-all", "process-command-api", "devtools"] }
tauri = { version = "1.4.1", features = [ "os-all", "fs-all", "path-all", "process-command-api", "devtools"] }
tauri-plugin-upload = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
zip = "0.6.6"
zip-extensions = "0.6.1"
Expand Down
7 changes: 6 additions & 1 deletion packages/stablestudio-ui/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use tauri::{RunEvent, Window, WindowBuilder, WindowUrl};
use tauri_plugin_upload;

mod server;
mod show_path;

static WINDOW: OnceLock<Window> = OnceLock::new();

Expand Down Expand Up @@ -58,7 +59,11 @@ fn main() {
Ok(())
})
.plugin(tauri_plugin_upload::init())
.invoke_handler(tauri::generate_handler![extract_comfy, launch_comfy])
.invoke_handler(tauri::generate_handler![
extract_comfy,
launch_comfy,
show_path::show_in_folder
])
.build(context)
.expect("error while building tauri application")
.run(move |_app_handle, event| match event {
Expand Down
2 changes: 1 addition & 1 deletion packages/stablestudio-ui/src-tauri/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl Builder {
Some("text/html".to_string()),
None,
),
["api" | "prompt" | "object_info" | "view" | "history" | "queue" | "extensions", ..] => (
["api" | "prompt" | "object_info" | "view" | "history" | "queue" | "interrupt" | "extensions", ..] => (
None,
None,
Some(
Expand Down
52 changes: 52 additions & 0 deletions packages/stablestudio-ui/src-tauri/src/show_path.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#[cfg(target_os = "linux")]
use fork::{daemon, Fork};
use std::process::Command;
#[cfg(target_os = "linux")]
use std::{fs::metadata, path::PathBuf}; // dep: fork = "0.1"

#[tauri::command]
pub fn show_in_folder(path: String) {
#[cfg(target_os = "windows")]
{
Command::new("explorer")
.args(["/select,", &path]) // The comma after select is not a typo
.spawn()
.unwrap();
}

#[cfg(target_os = "linux")]
{
if path.contains(",") {
// see https://gitlab.freedesktop.org/dbus/dbus/-/issues/76
let new_path = match metadata(&path).unwrap().is_dir() {
true => path,
false => {
let mut path2 = PathBuf::from(path);
path2.pop();
path2.into_os_string().into_string().unwrap()
}
};
Command::new("xdg-open").arg(&new_path).spawn().unwrap();
} else {
if let Ok(Fork::Child) = daemon(false, false) {
Command::new("dbus-send")
.args([
"--session",
"--dest=org.freedesktop.FileManager1",
"--type=method_call",
"/org/freedesktop/FileManager1",
"org.freedesktop.FileManager1.ShowItems",
format!("array:string:\"file://{path}\"").as_str(),
"string:\"\"",
])
.spawn()
.unwrap();
}
}
}

#[cfg(target_os = "macos")]
{
Command::new("open").args(["-R", &path]).spawn().unwrap();
}
}
3 changes: 3 additions & 0 deletions packages/stablestudio-ui/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
},
"path": {
"all": true
},
"os": {
"all": true
}
},
"bundle": {
Expand Down
Loading

0 comments on commit 69d381a

Please sign in to comment.