From 66799ee2c42c1a7ca6f324026aa3fbe600da7f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E5=A4=A9?= Date: Wed, 4 Mar 2026 12:49:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20macOS=20=E4=B8=93?= =?UTF-8?q?=E5=B1=9E=20Clippy=20=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - service.rs: macOS 平台两处 manual_strip,改用 strip_prefix - utils.rs: openclaw_command 在 macOS 未被调用,加 #[allow(dead_code)],函数体改用全路径 std::process::Command::new 避免 unused_imports --- src-tauri/src/commands/service.rs | 9 ++++----- src-tauri/src/utils.rs | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src-tauri/src/commands/service.rs b/src-tauri/src/commands/service.rs index acaac25..c7be5ac 100644 --- a/src-tauri/src/commands/service.rs +++ b/src-tauri/src/commands/service.rs @@ -87,14 +87,13 @@ mod platform { continue; } let trimmed = line.trim(); - if trimmed.starts_with("pid = ") { - if let Ok(p) = trimmed["pid = ".len()..].trim().parse::() { + if let Some(rest) = trimmed.strip_prefix("pid = ") { + if let Ok(p) = rest.trim().parse::() { pid = Some(p); } } - if trimmed.starts_with("state = ") { - let state = trimmed["state = ".len()..].trim(); - running = state == "running"; + if let Some(rest) = trimmed.strip_prefix("state = ") { + running = rest.trim() == "running"; } } diff --git a/src-tauri/src/utils.rs b/src-tauri/src/utils.rs index 43aba3e..09e01de 100644 --- a/src-tauri/src/utils.rs +++ b/src-tauri/src/utils.rs @@ -1,21 +1,21 @@ #[cfg(target_os = "windows")] use std::os::windows::process::CommandExt; -use std::process::Command; /// 跨平台获取 openclaw 命令的方法(同步版本) /// 在 Windows 上使用 `cmd /c openclaw` 以兼容全局 npm 路径下的 `.cmd` 脚本 -pub fn openclaw_command() -> Command { +#[allow(dead_code)] +pub fn openclaw_command() -> std::process::Command { #[cfg(target_os = "windows")] { const CREATE_NO_WINDOW: u32 = 0x08000000; - let mut cmd = Command::new("cmd"); + let mut cmd = std::process::Command::new("cmd"); cmd.arg("/c").arg("openclaw"); cmd.creation_flags(CREATE_NO_WINDOW); cmd } #[cfg(not(target_os = "windows"))] { - Command::new("openclaw") + std::process::Command::new("openclaw") } }