main.rs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Prevents additional console window on Windows in release, DO NOT REMOVE!!
  2. #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
  3. #[cfg(target_os = "macos")]
  4. #[macro_use]
  5. extern crate cocoa;
  6. #[cfg(target_os = "macos")]
  7. #[macro_use]
  8. extern crate objc;
  9. #[cfg(target_os = "macos")]
  10. mod mac;
  11. #[cfg(target_os = "windows")]
  12. mod win;
  13. mod interceptor;
  14. mod interop;
  15. use tauri::Manager;
  16. fn main() {
  17. tauri_plugin_deep_link::prepare("io.hoppscotch.desktop");
  18. tauri::Builder::default()
  19. .invoke_handler(tauri::generate_handler![
  20. interop::startup::init::interop_startup_init
  21. ])
  22. .plugin(
  23. tauri_plugin_window_state::Builder::default()
  24. .with_state_flags(
  25. // NOTE:
  26. // The app (window labeled "main") manages its visible state via `interop_startup_init`.
  27. // See `tauri.conf.json`:
  28. // ```json
  29. // {
  30. // "label": "main",
  31. // "title": "Hoppscotch",
  32. // ...
  33. // ...
  34. // "visible": false, // This is the important part.
  35. // ...
  36. // ...
  37. // }
  38. // ```
  39. tauri_plugin_window_state::StateFlags::all()
  40. & !tauri_plugin_window_state::StateFlags::VISIBLE,
  41. )
  42. .build(),
  43. )
  44. .plugin(tauri_plugin_store::Builder::default().build())
  45. .plugin(interceptor::init())
  46. .setup(|app| {
  47. if cfg!(target_os = "macos") {
  48. #[cfg(target_os = "macos")]
  49. use mac::window::setup_mac_window;
  50. #[cfg(target_os = "macos")]
  51. setup_mac_window(app);
  52. } else if cfg!(target_os = "windows") {
  53. #[cfg(target_os = "windows")]
  54. use win::window::setup_win_window;
  55. #[cfg(target_os = "windows")]
  56. setup_win_window(app);
  57. }
  58. let handle = app.handle();
  59. tauri_plugin_deep_link::register("hoppscotch", move |request| {
  60. println!("{:?}", request);
  61. handle.emit_all("scheme-request-received", request).unwrap();
  62. })
  63. .unwrap();
  64. Ok(())
  65. })
  66. .run(tauri::generate_context!())
  67. .expect("error while running tauri application");
  68. }