fix: 修复 macOS 专属 Clippy 错误

- service.rs: macOS 平台两处 manual_strip,改用 strip_prefix
- utils.rs: openclaw_command 在 macOS 未被调用,加 #[allow(dead_code)],函数体改用全路径 std::process::Command::new 避免 unused_imports
This commit is contained in:
晴天
2026-03-04 12:49:56 +08:00
parent d8084f9213
commit 66799ee2c4
2 changed files with 8 additions and 9 deletions

View File

@@ -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::<u32>() {
if let Some(rest) = trimmed.strip_prefix("pid = ") {
if let Ok(p) = rest.trim().parse::<u32>() {
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";
}
}

View File

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