main.rs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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;
  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. register_notification_sender(TSNotificationSender::new(app_handler.clone()));
  23. // tauri::async_runtime::spawn(async move {});
  24. window.listen_global(AF_EVENT, move |event| {
  25. on_event(app_handler.clone(), event);
  26. });
  27. })
  28. .setup(|app| {
  29. #[cfg(debug_assertions)]
  30. {
  31. let window = app.get_window("main").unwrap();
  32. window.open_devtools();
  33. }
  34. Ok(())
  35. })
  36. .run(tauri::generate_context!())
  37. .expect("error while running tauri application");
  38. }