Misc bugs 4 (#381)

* bug fixes

* fixed jres being undetected

* cleanup

* prettier

* fixed folders not displaying windows exporting

* fixes, more bugs

* missed function

* clippy, fmt

* prettier
This commit is contained in:
Wyatt Verchere
2023-07-28 19:56:49 -07:00
committed by GitHub
parent 744d11f09e
commit 87449f91c3
22 changed files with 171 additions and 78 deletions

View File

@@ -12,6 +12,7 @@ pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
profile_remove,
profile_get,
profile_get_optimal_jre_key,
profile_get_full_path,
profile_list,
profile_check_installed,
profile_install,
@@ -55,6 +56,14 @@ pub async fn profile_get(
Ok(res)
}
// Get a profile's full path
// invoke('plugin:profile|profile_get_full_path',path)
#[tauri::command]
pub async fn profile_get_full_path(path: ProfilePathId) -> Result<PathBuf> {
let res = profile::get_full_path(&path).await?;
Ok(res)
}
// Get optimal java version from profile
#[tauri::command]
pub async fn profile_get_optimal_jre_key(

View File

@@ -59,7 +59,7 @@ pub fn show_in_folder(path: String) -> Result<()> {
#[cfg(target_os = "windows")]
{
Command::new("explorer")
.args(["/select,", &path]) // The comma after select is not a typo
.args([&path]) // The comma after select is not a typo
.spawn()?;
}
@@ -86,7 +86,7 @@ pub fn show_in_folder(path: String) -> Result<()> {
#[cfg(target_os = "macos")]
{
Command::new("open").args(["-R", &path]).spawn()?;
Command::new("open").args([&path]).spawn()?;
}
Ok::<(), theseus::Error>(())

View File

@@ -26,6 +26,19 @@ fn is_dev() -> bool {
cfg!(debug_assertions)
}
// Toggles decorations
#[tauri::command]
async fn toggle_decorations(b: bool, window: tauri::Window) -> api::Result<()> {
window.set_decorations(b).map_err(|e| {
theseus::Error::from(theseus::ErrorKind::OtherError(format!(
"Failed to toggle decorations: {}",
e
)))
})?;
println!("Toggled decorations!");
Ok(())
}
#[derive(Clone, serde::Serialize)]
struct Payload {
args: Vec<String>,
@@ -84,16 +97,12 @@ fn main() {
}
#[cfg(target_os = "macos")]
{
win.set_decorations(true).unwrap();
use macos::window_ext::WindowExt;
win.set_transparent_titlebar(true);
win.position_traffic_lights(9.0, 16.0);
}
#[cfg(not(target_os = "macos"))]
{
win.set_decorations(false).unwrap();
}
#[cfg(target_os = "macos")]
{
macos::delegate::register_open_file(|filename| {
tauri::async_runtime::spawn(api::utils::handle_command(
filename,
@@ -102,6 +111,9 @@ fn main() {
.unwrap();
}
// Show app now that we are setup
win.show().unwrap();
Ok(())
});
@@ -129,7 +141,11 @@ fn main() {
.plugin(api::settings::init())
.plugin(api::tags::init())
.plugin(api::utils::init())
.invoke_handler(tauri::generate_handler![initialize_state, is_dev]);
.invoke_handler(tauri::generate_handler![
initialize_state,
is_dev,
toggle_decorations
]);
builder
.run(tauri::generate_context!())