mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-06-08 00:59:57 +08:00
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:
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user