From 2daa49ce3149e4a1ee4059fa2f1b845d58fde9ee Mon Sep 17 00:00:00 2001 From: Momentry Studio Date: Thu, 8 Oct 2026 00:13:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Tauri=20=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E9=94=99=E8=AF=AF=EF=BC=88SystemStatsResponse=20?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题: - SystemStatsResponse 在 bin/proxy.rs 中定义 - 库模块 proxy.rs 和 validate.rs 试图从 super 导入,但路径错误 修复: - 将 SystemStatsResponse 定义移到库模块 proxy.rs - 在 validate.rs 中添加正确的导入 - 移除 bin/proxy.rs 中的重复定义(稍后处理) --- src-tauri/src/proxy.rs | 31 ++++++++++++++++++++++++++++++- src-tauri/src/validate.rs | 4 +++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/proxy.rs b/src-tauri/src/proxy.rs index a0ff37e..ab721b8 100644 --- a/src-tauri/src/proxy.rs +++ b/src-tauri/src/proxy.rs @@ -1244,7 +1244,36 @@ mod macmon_sampler { pub fn get_metrics() -> Option { None } } -pub use super::SystemStatsResponse; +#[derive(serde::Serialize, serde::Deserialize)] +pub struct SystemStatsResponse { + pub cpu_used_percent: f64, + pub memory_used_percent: f64, + pub memory_available_mb: u64, + pub memory_total_mb: u64, + pub swap_used_percent: f64, + pub swap_available_mb: u64, + pub swap_total_mb: u64, + pub gpu_available: bool, + pub gpu_utilization: Option, + pub gpu_memory_used_pct: Option, + pub ane_available: bool, + pub ane_utilization: Option, + pub source: String, + pub chip_name: Option, + pub cpu_power: Option, + pub gpu_power: Option, + pub ane_power: Option, + pub sys_power: Option, + pub ram_power: Option, + pub cpu_temp: Option, + pub gpu_temp: Option, + pub ecpu_freq_mhz: Option, + pub pcpu_freq_mhz: Option, + pub gpu_freq_mhz: Option, + pub ecpu_cores: Option, + pub pcpu_cores: Option, + pub gpu_cores: Option, +} async fn get_system_stats_handler() -> Response { // 1. Try macmon first (Apple Silicon only) diff --git a/src-tauri/src/validate.rs b/src-tauri/src/validate.rs index 8e58227..18454be 100644 --- a/src-tauri/src/validate.rs +++ b/src-tauri/src/validate.rs @@ -5,6 +5,8 @@ use std::path::Path; use std::process::Command; use std::time::{SystemTime, UNIX_EPOCH}; +use super::proxy::SystemStatsResponse; + #[derive(Debug, Clone, Serialize, Deserialize)] pub enum ValidationStatus { Pass, @@ -282,7 +284,7 @@ pub fn validate_thermal_state_via_pmset() -> Option { // ==================== Main Validation Function ==================== -pub fn run_validation(layers: &[u32], macmon_stats: &super::SystemStatsResponse) -> ValidationResult { +pub fn run_validation(layers: &[u32], macmon_stats: &SystemStatsResponse) -> ValidationResult { write_log(&format!("[INFO] Validation started: layers={:?}", layers)); let mut result = ValidationResult {