main.rs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #![cfg_attr(
  2. all(not(debug_assertions), target_os = "windows"),
  3. windows_subsystem = "windows"
  4. )]
  5. mod init;
  6. mod notification;
  7. mod request;
  8. use flowy_notification::{register_notification_sender, unregister_all_notification_sender};
  9. use init::*;
  10. use notification::*;
  11. use request::*;
  12. use tauri::Manager;
  13. fn main() {
  14. let flowy_core = init_flowy_core();
  15. tauri::Builder::default()
  16. .invoke_handler(tauri::generate_handler![invoke_request])
  17. .manage(flowy_core)
  18. .on_window_event(|_window_event| {})
  19. .on_menu_event(|_menu| {})
  20. .on_page_load(|window, _payload| {
  21. let app_handler = window.app_handle();
  22. // Make sure hot reload won't register the notification sender twice
  23. unregister_all_notification_sender();
  24. register_notification_sender(TSNotificationSender::new(app_handler.clone()));
  25. // tauri::async_runtime::spawn(async move {});
  26. window.listen_global(AF_EVENT, move |event| {
  27. on_event(app_handler.clone(), event);
  28. });
  29. })
  30. .setup(|app| {
  31. #[cfg(debug_assertions)]
  32. {
  33. let window = app.get_window("main").unwrap();
  34. window.open_devtools();
  35. }
  36. Ok(())
  37. })
  38. .run(tauri::generate_context!())
  39. .expect("error while running tauri application");
  40. }