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") } }