diff --git a/src-tauri/src/commands/misc.rs b/src-tauri/src/commands/misc.rs index b4dd12d93..3d78534f1 100644 --- a/src-tauri/src/commands/misc.rs +++ b/src-tauri/src/commands/misc.rs @@ -133,27 +133,40 @@ pub async fn get_tool_versions( tools: Option>, wsl_shell_by_tool: Option>, ) -> Result, String> { - let requested: Vec<&str> = if let Some(tools) = tools.as_ref() { - let set: std::collections::HashSet<&str> = tools.iter().map(|s| s.as_str()).collect(); - VALID_TOOLS - .iter() - .copied() - .filter(|t| set.contains(t)) - .collect() - } else { - VALID_TOOLS.to_vec() - }; - let mut results = Vec::new(); - - for tool in requested { - let pref = wsl_shell_by_tool.as_ref().and_then(|m| m.get(tool)); - let tool_wsl_shell = pref.and_then(|p| p.wsl_shell.as_deref()); - let tool_wsl_shell_flag = pref.and_then(|p| p.wsl_shell_flag.as_deref()); - - results.push(get_single_tool_version_impl(tool, tool_wsl_shell, tool_wsl_shell_flag).await); + // Windows: completely disable tool version detection to prevent + // accidentally launching apps (e.g. Claude Code) via protocol handlers. + #[cfg(target_os = "windows")] + { + let _ = (tools, wsl_shell_by_tool); + return Ok(Vec::new()); } - Ok(results) + #[cfg(not(target_os = "windows"))] + { + let requested: Vec<&str> = if let Some(tools) = tools.as_ref() { + let set: std::collections::HashSet<&str> = tools.iter().map(|s| s.as_str()).collect(); + VALID_TOOLS + .iter() + .copied() + .filter(|t| set.contains(t)) + .collect() + } else { + VALID_TOOLS.to_vec() + }; + let mut results = Vec::new(); + + for tool in requested { + let pref = wsl_shell_by_tool.as_ref().and_then(|m| m.get(tool)); + let tool_wsl_shell = pref.and_then(|p| p.wsl_shell.as_deref()); + let tool_wsl_shell_flag = pref.and_then(|p| p.wsl_shell_flag.as_deref()); + + results.push( + get_single_tool_version_impl(tool, tool_wsl_shell, tool_wsl_shell_flag).await, + ); + } + + Ok(results) + } } /// 获取单个工具的版本信息(内部实现) diff --git a/src/components/settings/AboutSection.tsx b/src/components/settings/AboutSection.tsx index 343ba52e6..ac0c9ffb2 100644 --- a/src/components/settings/AboutSection.tsx +++ b/src/components/settings/AboutSection.tsx @@ -27,6 +27,7 @@ import { relaunchApp } from "@/lib/updater"; import { Badge } from "@/components/ui/badge"; import { motion } from "framer-motion"; import appIcon from "@/assets/icons/app-icon.png"; +import { isWindows } from "@/lib/platform"; interface AboutSectionProps { isPortable: boolean; @@ -199,7 +200,7 @@ export function AboutSection({ isPortable }: AboutSectionProps) { try { const [appVersion] = await Promise.all([ getVersion(), - loadAllToolVersions(), + ...(isWindows() ? [] : [loadAllToolVersions()]), ]); if (active) { @@ -423,165 +424,173 @@ export function AboutSection({ isPortable }: AboutSectionProps) { )} -
-
-

{t("settings.localEnvCheck")}

- -
- -
- {TOOL_NAMES.map((toolName, index) => { - const tool = toolVersions.find((item) => item.name === toolName); - // Special case for OpenCode (capital C), others use capitalize - const displayName = - toolName === "opencode" - ? "OpenCode" - : toolName.charAt(0).toUpperCase() + toolName.slice(1); - const title = tool?.version || tool?.error || t("common.unknown"); - - return ( - -
-
- - {displayName} - {/* Environment Badge */} - {tool?.env_type && ENV_BADGE_CONFIG[tool.env_type] && ( - - {t(ENV_BADGE_CONFIG[tool.env_type].labelKey)} - - )} - {/* WSL Shell Selector */} - {tool?.env_type === "wsl" && ( - - )} - {/* WSL Shell Flag Selector */} - {tool?.env_type === "wsl" && ( - - )} -
- {isLoadingTools || loadingTools[toolName] ? ( - - ) : tool?.version ? ( - tool.latest_version && - tool.version !== tool.latest_version ? ( - - {tool.latest_version} - - ) : ( - - ) - ) : ( - - )} -
-
- {isLoadingTools - ? t("common.loading") - : tool?.version - ? tool.version - : tool?.error || t("common.notInstalled")} -
-
- ); - })} -
-
- - -

- {t("settings.oneClickInstall")} -

-
-
-

- {t("settings.oneClickInstallHint")} -

+ {!isWindows() && ( +
+
+

+ {t("settings.localEnvCheck")} +

-
-            {ONE_CLICK_INSTALL_COMMANDS}
-          
+ +
+ {TOOL_NAMES.map((toolName, index) => { + const tool = toolVersions.find((item) => item.name === toolName); + // Special case for OpenCode (capital C), others use capitalize + const displayName = + toolName === "opencode" + ? "OpenCode" + : toolName.charAt(0).toUpperCase() + toolName.slice(1); + const title = tool?.version || tool?.error || t("common.unknown"); + + return ( + +
+
+ + {displayName} + {/* Environment Badge */} + {tool?.env_type && ENV_BADGE_CONFIG[tool.env_type] && ( + + {t(ENV_BADGE_CONFIG[tool.env_type].labelKey)} + + )} + {/* WSL Shell Selector */} + {tool?.env_type === "wsl" && ( + + )} + {/* WSL Shell Flag Selector */} + {tool?.env_type === "wsl" && ( + + )} +
+ {isLoadingTools || loadingTools[toolName] ? ( + + ) : tool?.version ? ( + tool.latest_version && + tool.version !== tool.latest_version ? ( + + {tool.latest_version} + + ) : ( + + ) + ) : ( + + )} +
+
+ {isLoadingTools + ? t("common.loading") + : tool?.version + ? tool.version + : tool?.error || t("common.notInstalled")} +
+
+ ); + })} +
- + )} + + {!isWindows() && ( + +

+ {t("settings.oneClickInstall")} +

+
+
+

+ {t("settings.oneClickInstallHint")} +

+ +
+
+              {ONE_CLICK_INSTALL_COMMANDS}
+            
+
+
+ )} ); }