1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use tauri::{api::os::locale, webview_version};

#[cfg(target_os = "linux")]
static ENGINE_NAME: &str = "WebKitGTK";

#[cfg(target_os = "macos")]
static ENGINE_NAME: &str = "WebKit";

#[cfg(target_os = "windows")]
static ENGINE_NAME: &str = "WebView2";


#[cfg(debug_assertions)]
static IS_DEBUG: bool = true;

#[cfg(not(debug_assertions))]
static IS_DEBUG: bool = false;

pub struct SystemProperties {
    pub is_debug: bool,
    pub os_name: String,
    pub os_version: String,
    pub locale: String,
    pub engine_name: String,
    pub engine_version: String,
}

pub fn get_info() -> SystemProperties {
    let info = os_info::get();
    let locale = locale().unwrap_or_default();
    let engine_version = webview_version().unwrap_or_default();

    let os_name = match info.os_type() {
        os_info::Type::Macos => "macOS".to_string(),
        os_info::Type::Windows => "Windows".to_string(),
        _ => info.os_type().to_string(),
    };

    SystemProperties {
        is_debug: IS_DEBUG,
        os_name,
        os_version: info.version().to_string(),
        locale,
        engine_name: ENGINE_NAME.to_string(),
        engine_version,
    }
}