12345678910111213141516171819202122232425262728293031323334353637383940 |
- // Copyright 2019-2021 Tauri Programme within The Commons Conservancy
- // SPDX-License-Identifier: Apache-2.0
- // SPDX-License-Identifier: MIT
- #![cfg_attr(
- all(not(debug_assertions), target_os = "windows"),
- windows_subsystem = "windows"
- )]
- mod cmd;
- use serde::Serialize;
- #[derive(Serialize)]
- struct Reply {
- data: String,
- }
- fn main() {
- tauri::Builder::default()
- .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".to_string(),
- };
- window_
- .emit("rust-event", Some(reply))
- .expect("failed to emit");
- });
- })
- .invoke_handler(tauri::generate_handler![
- cmd::log_operation,
- cmd::perform_request
- ])
- .run(tauri::generate_context!())
- .expect("error while running tauri application");
- }
|