diff --git a/src-tauri/src/cmd/system.rs b/src-tauri/src/cmd/system.rs index 2c875e77..2ec266e0 100644 --- a/src-tauri/src/cmd/system.rs +++ b/src-tauri/src/cmd/system.rs @@ -1,5 +1,6 @@ use super::CmdResult; -use crate::{core::handle, model::sysinfo::PlatformSpecification}; +use crate::core::handle; +use crate::module::sysinfo::PlatformSpecification; use tauri_plugin_clipboard_manager::ClipboardExt; use crate::{core::{self, CoreManager, service}, wrap_err}; diff --git a/src-tauri/src/model/mod.rs b/src-tauri/src/model/mod.rs index e11af71e..c78317c1 100644 --- a/src-tauri/src/model/mod.rs +++ b/src-tauri/src/model/mod.rs @@ -1,2 +1 @@ -pub mod api; -pub mod sysinfo; +pub mod api; \ No newline at end of file diff --git a/src-tauri/src/model/sysinfo.rs b/src-tauri/src/model/sysinfo.rs deleted file mode 100644 index b626181d..00000000 --- a/src-tauri/src/model/sysinfo.rs +++ /dev/null @@ -1,18 +0,0 @@ -use std::fmt::{self, Debug, Formatter}; - -pub struct PlatformSpecification { - pub system_name: String, - pub system_version: String, - pub system_kernel_version: String, - pub system_arch: String, -} - -impl Debug for PlatformSpecification { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - write!( - f, - "System Name: {}\nSystem Version: {}\nSystem kernel Version: {}\nSystem Arch: {}", - self.system_name, self.system_version, self.system_kernel_version, self.system_arch - ) - } -} \ No newline at end of file diff --git a/src-tauri/src/module/sysinfo.rs b/src-tauri/src/module/sysinfo.rs index 9908f6cc..54e0b5bc 100644 --- a/src-tauri/src/module/sysinfo.rs +++ b/src-tauri/src/module/sysinfo.rs @@ -1,7 +1,26 @@ -use crate::model::sysinfo::PlatformSpecification; - +use crate::core::{handle, CoreManager}; +use std::fmt::{self, Debug, Formatter}; use sysinfo::System; +pub struct PlatformSpecification { + system_name: String, + system_version: String, + system_kernel_version: String, + system_arch: String, + verge_version: String, + running_mode: String, +} + +impl Debug for PlatformSpecification { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + write!( + f, + "System Name: {}\nSystem Version: {}\nSystem kernel Version: {}\nSystem Arch: {}\nVerge Version: {}\nRunning Mode: {}", + self.system_name, self.system_version, self.system_kernel_version, self.system_arch, self.verge_version, self.running_mode + ) + } +} + impl PlatformSpecification { pub fn new() -> Self { let system_name = System::name().unwrap_or("Null".into()); @@ -9,11 +28,29 @@ impl PlatformSpecification { let system_kernel_version = System::kernel_version().unwrap_or("Null".into()); let system_arch = std::env::consts::ARCH.to_string(); + let handler = handle::Handle::global().app_handle().unwrap(); + let config = handler.config(); + let verge_version = config.version.clone().unwrap_or("Null".into()); + + // Get running mode asynchronously + let running_mode = tokio::task::block_in_place(|| { + tokio::runtime::Handle::current().block_on(async { + match CoreManager::global().get_running_mode().await { + crate::core::RunningMode::Service => "Service".to_string(), + crate::core::RunningMode::Sidecar => "Sidecar".to_string(), + crate::core::RunningMode::NotRunning => "Not Running".to_string(), + } + }) + }); + + Self { system_name, system_version, system_kernel_version, - system_arch + system_arch, + verge_version, + running_mode, } } }