mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-25 21:22:20 +08:00
* refactor: improve code quality with clippy fixes and standardized logging
- Replace dangerous unwrap()/expect() calls with proper error handling
- Standardize logging from log:: to logging\! macro with Type:: classifications
- Fix app handle panics with graceful fallback patterns
- Improve error resilience across 35+ modules without breaking functionality
- Reduce clippy warnings from 300+ to 0 in main library code
* chore: update Cargo.toml configuration
* refactor: resolve all clippy warnings
- Fix Arc clone warnings using explicit Arc::clone syntax across 9 files
- Add #[allow(clippy::expect_used)] to test functions for appropriate expect usage
- Remove no-effect statements from debug code cleanup
- Apply clippy auto-fixes for dbg\! macro removals and path statements
- Achieve zero clippy warnings on all targets with -D warnings flag
* chore: update Cargo.toml clippy configuration
* refactor: simplify macOS job configuration and improve caching
* refactor: remove unnecessary async/await from service and proxy functions
* refactor: streamline pnpm installation in CI configuration
* refactor: simplify error handling and remove unnecessary else statements
* refactor: replace async/await with synchronous locks for core management
* refactor: add workflow_dispatch trigger to clippy job
* refactor: convert async functions to synchronous for service management
* refactor: convert async functions to synchronous for UWP tool invocation
* fix: change wrong logging
* refactor: convert proxy restoration functions to async
* Revert "refactor: convert proxy restoration functions to async"
This reverts commit b82f5d250b.
* refactor: update proxy restoration functions to return Result types
* fix: handle errors during proxy restoration and update async function signatures
* fix: handle errors during proxy restoration and update async function signatures
* refactor: update restore_pac_proxy and restore_sys_proxy functions to async
* fix: convert restore_pac_proxy and restore_sys_proxy functions to async
* fix: await restore_sys_proxy calls in proxy restoration logic
* fix: suppress clippy warnings for unused async functions in proxy restoration
* fix: suppress clippy warnings for unused async functions in proxy restoration
74 lines
2.2 KiB
Rust
74 lines
2.2 KiB
Rust
use crate::{
|
|
cmd::system,
|
|
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,
|
|
is_admin: bool,
|
|
}
|
|
|
|
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: {}\nIs Admin: {}",
|
|
self.system_name, self.system_version, self.system_kernel_version, self.system_arch, self.verge_version, self.running_mode, self.is_admin
|
|
)
|
|
}
|
|
}
|
|
|
|
impl PlatformSpecification {
|
|
pub fn new() -> Self {
|
|
let system_name = System::name().unwrap_or("Null".into());
|
|
let system_version = System::long_os_version().unwrap_or("Null".into());
|
|
let system_kernel_version = System::kernel_version().unwrap_or("Null".into());
|
|
let system_arch = System::cpu_arch();
|
|
|
|
let Some(handler) = handle::Handle::global().app_handle() else {
|
|
return Self {
|
|
system_name,
|
|
system_version,
|
|
system_kernel_version,
|
|
system_arch,
|
|
verge_version: "unknown".into(),
|
|
running_mode: "NotRunning".to_string(),
|
|
is_admin: false,
|
|
};
|
|
};
|
|
let verge_version = handler.package_info().version.to_string();
|
|
|
|
// 使用默认值避免在同步上下文中执行异步操作
|
|
let running_mode = "NotRunning".to_string();
|
|
|
|
let is_admin = system::is_admin().unwrap_or_default();
|
|
|
|
Self {
|
|
system_name,
|
|
system_version,
|
|
system_kernel_version,
|
|
system_arch,
|
|
verge_version,
|
|
running_mode,
|
|
is_admin,
|
|
}
|
|
}
|
|
|
|
// 异步方法来获取完整的系统信息
|
|
pub fn new_sync() -> Self {
|
|
let mut info = Self::new();
|
|
|
|
let running_mode = CoreManager::global().get_running_mode();
|
|
info.running_mode = running_mode.to_string();
|
|
|
|
info
|
|
}
|
|
}
|