Drag and drop to install #12

This commit is contained in:
Kr4ight
2026-04-05 17:05:51 +02:00
parent c0141eed35
commit 167bb33144
3 changed files with 64 additions and 7 deletions
+27 -2
View File
@@ -1,7 +1,8 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use saturn_launcher_lib::load_state;
use saturn_launcher_lib::{SharedState, install_paths, load_state};
use tauri::{Manager, WindowEvent};
#[cfg_attr(mobile, tauri::mobile_entry_point)]
fn main() {
@@ -28,7 +29,31 @@ fn main() {
saturn_launcher_lib::launcher::auth::auth_remove,
saturn_launcher_lib::launcher::auth::auth_validate,
saturn_launcher_lib::launcher::auth::auth_get_valid
])
]).setup(|app| {
match app.get_webview_window("main") {
Some(window) => {
let state = app.state::<SharedState>().inner().clone();
window.on_window_event(move |event| {
if let WindowEvent::DragDrop(file_event) = event {
match file_event {
tauri::DragDropEvent::Drop{paths, ..} => {
println!("Installing files: {:?}", paths);
install_paths(&state, paths);
}
_ => {}
}
}
});
}
None => {
println!("WARN: Drag and drop feature will not work");
}
}
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}