Skip to content

Commit 66799ee

Browse files
committed
fix: 修复 macOS 专属 Clippy 错误
- service.rs: macOS 平台两处 manual_strip,改用 strip_prefix - utils.rs: openclaw_command 在 macOS 未被调用,加 #[allow(dead_code)],函数体改用全路径 std::process::Command::new 避免 unused_imports
1 parent d8084f9 commit 66799ee

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

src-tauri/src/commands/service.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,13 @@ mod platform {
8787
continue;
8888
}
8989
let trimmed = line.trim();
90-
if trimmed.starts_with("pid = ") {
91-
if let Ok(p) = trimmed["pid = ".len()..].trim().parse::<u32>() {
90+
if let Some(rest) = trimmed.strip_prefix("pid = ") {
91+
if let Ok(p) = rest.trim().parse::<u32>() {
9292
pid = Some(p);
9393
}
9494
}
95-
if trimmed.starts_with("state = ") {
96-
let state = trimmed["state = ".len()..].trim();
97-
running = state == "running";
95+
if let Some(rest) = trimmed.strip_prefix("state = ") {
96+
running = rest.trim() == "running";
9897
}
9998
}
10099

src-tauri/src/utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
#[cfg(target_os = "windows")]
22
use std::os::windows::process::CommandExt;
3-
use std::process::Command;
43

54
/// 跨平台获取 openclaw 命令的方法(同步版本)
65
/// 在 Windows 上使用 `cmd /c openclaw` 以兼容全局 npm 路径下的 `.cmd` 脚本
7-
pub fn openclaw_command() -> Command {
6+
#[allow(dead_code)]
7+
pub fn openclaw_command() -> std::process::Command {
88
#[cfg(target_os = "windows")]
99
{
1010
const CREATE_NO_WINDOW: u32 = 0x08000000;
11-
let mut cmd = Command::new("cmd");
11+
let mut cmd = std::process::Command::new("cmd");
1212
cmd.arg("/c").arg("openclaw");
1313
cmd.creation_flags(CREATE_NO_WINDOW);
1414
cmd
1515
}
1616
#[cfg(not(target_os = "windows"))]
1717
{
18-
Command::new("openclaw")
18+
std::process::Command::new("openclaw")
1919
}
2020
}
2121

0 commit comments

Comments
 (0)