feat(sysinfo): Add diagnostic information enhancements (#2880)

Enhanced the PlatformSpecification struct with additional diagnostic information including:
- Added Verge version information to diagnostic output
- Added running mode information (Service/Sidecar/Not Running)
- Improved Debug implementation to display all diagnostic fields
- Implemented asynchronous detection of core running mode

This change helps users provide more complete system information when reporting issues.
This commit is contained in:
Tunglies 2025-03-04 11:52:22 +08:00 committed by GitHub
parent 44ca513241
commit 1ee8786ab7
4 changed files with 43 additions and 24 deletions

View File

@ -1,5 +1,6 @@
use super::CmdResult; 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 tauri_plugin_clipboard_manager::ClipboardExt;
use crate::{core::{self, CoreManager, service}, wrap_err}; use crate::{core::{self, CoreManager, service}, wrap_err};

View File

@ -1,2 +1 @@
pub mod api; pub mod api;
pub mod sysinfo;

View File

@ -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
)
}
}

View File

@ -1,7 +1,26 @@
use crate::model::sysinfo::PlatformSpecification; use crate::core::{handle, CoreManager};
use std::fmt::{self, Debug, Formatter};
use sysinfo::System; 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 { impl PlatformSpecification {
pub fn new() -> Self { pub fn new() -> Self {
let system_name = System::name().unwrap_or("Null".into()); 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_kernel_version = System::kernel_version().unwrap_or("Null".into());
let system_arch = std::env::consts::ARCH.to_string(); 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 { Self {
system_name, system_name,
system_version, system_version,
system_kernel_version, system_kernel_version,
system_arch system_arch,
verge_version,
running_mode,
} }
} }
} }