initial commit

This commit is contained in:
Jonas Kruckenberg 2022-11-01 15:19:25 +01:00
commit c3e5b84282
54 changed files with 2009 additions and 0 deletions

View file

@ -0,0 +1,38 @@
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
use serde::Deserialize;
use shared::{Reply, RequestBody};
#[tauri::command]
fn log_operation(event: String, payload: Option<String>) {
println!("{} {:?}", event, payload);
}
#[tauri::command]
fn perform_request(endpoint: String, body: RequestBody) -> String {
println!("{} {:?}", endpoint, body);
"message response".into()
}
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![log_operation, perform_request])
.on_page_load(|window, _| {
let window_ = window.clone();
window.listen("js-event", move |event| {
println!("got js-event with message '{:?}'", event.payload());
let reply = Reply {
data: "something else",
};
window_
.emit("rust-event", Some(reply))
.expect("failed to emit");
});
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}