aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src-tauri/src/util.rs')
-rw-r--r--src-tauri/src/util.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/src-tauri/src/util.rs b/src-tauri/src/util.rs
index b21b2208..274cf488 100644
--- a/src-tauri/src/util.rs
+++ b/src-tauri/src/util.rs
@@ -26,6 +26,49 @@ pub async fn is_debug_mode() -> bool {
cfg!(debug_assertions)
}
+/// Returns the current version number as a string
+#[tauri::command]
+pub async fn get_flightcore_version_number() -> String {
+ let version = env!("CARGO_PKG_VERSION");
+ if cfg!(debug_assertions) {
+ // Debugging enabled
+ format!("v{} (debug mode)", version)
+ } else {
+ // Debugging disabled
+ format!("v{}", version)
+ }
+}
+
+/// Spawns repair window
+#[tauri::command]
+pub async fn open_repair_window(handle: tauri::AppHandle) -> Result<(), String> {
+ // Spawn new window
+ let repair_window = match tauri::WindowBuilder::new(
+ &handle,
+ "RepairWindow",
+ tauri::WindowUrl::App("/#/repair".into()),
+ )
+ .build()
+ {
+ Ok(res) => res,
+ Err(err) => return Err(err.to_string()),
+ };
+
+ // Set window title
+ match repair_window.set_title("FlightCore Repair Window") {
+ Ok(()) => (),
+ Err(err) => return Err(err.to_string()),
+ };
+ Ok(())
+}
+
+/// Closes all windows and exits application
+#[tauri::command]
+pub async fn close_application<R: tauri::Runtime>(app: tauri::AppHandle<R>) -> Result<(), String> {
+ app.exit(0); // Close application
+ Ok(())
+}
+
/// Fetches `/client/servers` endpoint from master server
async fn fetch_server_list() -> Result<String, anyhow::Error> {
let url = format!("{MASTER_SERVER_URL}{SERVER_BROWSER_ENDPOINT}");