From 1ce007622e67c2b3f376959887a8209eb9dacd23 Mon Sep 17 00:00:00 2001 From: farion1231 Date: Wed, 19 Nov 2025 10:06:52 +0800 Subject: [PATCH] fix: resolve winreg API compatibility issue on Windows - Update RegValue.to_string() usage to match current winreg API which returns String directly instead of Result - Add conditional compilation for std::fs import (Unix only) --- src-tauri/src/services/env_checker.rs | 29 ++++++++++++--------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src-tauri/src/services/env_checker.rs b/src-tauri/src/services/env_checker.rs index 842bc3e..da0ad65 100644 --- a/src-tauri/src/services/env_checker.rs +++ b/src-tauri/src/services/env_checker.rs @@ -1,4 +1,5 @@ use serde::{Deserialize, Serialize}; +#[cfg(not(target_os = "windows"))] use std::fs; #[derive(Debug, Clone, Serialize, Deserialize)] @@ -49,14 +50,12 @@ fn check_system_env(keywords: &[&str]) -> Result, String> { if let Ok(hkcu) = RegKey::predef(HKEY_CURRENT_USER).open_subkey("Environment") { for (name, value) in hkcu.enum_values().filter_map(Result::ok) { if keywords.iter().any(|k| name.to_uppercase().contains(k)) { - if let Ok(val) = value.to_string() { - conflicts.push(EnvConflict { - var_name: name.clone(), - var_value: val, - source_type: "system".to_string(), - source_path: "HKEY_CURRENT_USER\\Environment".to_string(), - }); - } + conflicts.push(EnvConflict { + var_name: name.clone(), + var_value: value.to_string(), + source_type: "system".to_string(), + source_path: "HKEY_CURRENT_USER\\Environment".to_string(), + }); } } } @@ -67,14 +66,12 @@ fn check_system_env(keywords: &[&str]) -> Result, String> { { for (name, value) in hklm.enum_values().filter_map(Result::ok) { if keywords.iter().any(|k| name.to_uppercase().contains(k)) { - if let Ok(val) = value.to_string() { - conflicts.push(EnvConflict { - var_name: name.clone(), - var_value: val, - source_type: "system".to_string(), - source_path: "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment".to_string(), - }); - } + conflicts.push(EnvConflict { + var_name: name.clone(), + var_value: value.to_string(), + source_type: "system".to_string(), + source_path: "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment".to_string(), + }); } } }