aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src-tauri/src/main.rs')
-rw-r--r--src-tauri/src/main.rs44
1 files changed, 42 insertions, 2 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 3aa17459..2e4b3370 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -9,6 +9,11 @@ use std::{
time::Duration,
};
+#[cfg(target_os = "windows")]
+use std::ptr::null_mut;
+#[cfg(target_os = "windows")]
+use winapi::um::winuser::{MessageBoxW, MB_ICONERROR, MB_OK, MB_USERICON};
+
use app::{
constants::{APP_USER_AGENT, MASTER_SERVER_URL, REFRESH_DELAY, SERVER_BROWSER_ENDPOINT},
*,
@@ -66,7 +71,7 @@ fn main() {
},
));
- tauri::Builder::default()
+ match tauri::Builder::default()
.plugin(tauri_plugin_store::Builder::default().build())
.setup(|app| {
let app_handle = app.app_handle();
@@ -148,7 +153,42 @@ fn main() {
close_application,
])
.run(tauri::generate_context!())
- .expect("error while running tauri application");
+ {
+ Ok(()) => (),
+ Err(err) => {
+ // Failed to launch system native web view
+
+ // Log error on Linux
+ #[cfg(not(target_os = "windows"))]
+ {
+ log::error!("{err}");
+ }
+
+ // On Windows we can show an error window using Windows API to show how to install WebView2
+ #[cfg(target_os = "windows")]
+ {
+ log::error!("WebView2 not installed: {err}");
+ // Display a message box to the user with a button to open the installation instructions
+ let title = "WebView2 not found"
+ .encode_utf16()
+ .chain(Some(0))
+ .collect::<Vec<_>>();
+ let message = "FlightCore requires WebView2 to run.\n\nClick OK to open installation instructions.".encode_utf16().chain(Some(0)).collect::<Vec<_>>();
+ unsafe {
+ let result = MessageBoxW(
+ null_mut(),
+ message.as_ptr(),
+ title.as_ptr(),
+ MB_OK | MB_ICONERROR | MB_USERICON,
+ );
+ if result == 1 {
+ // Open the installation instructions URL in the user's default web browser
+ open::that("https://github.com/R2NorthstarTools/FlightCore/blob/main/docs/TROUBLESHOOTING.md#flightcore-wont-launch").unwrap();
+ }
+ }
+ }
+ }
+ };
}
#[tauri::command]