fix: 全局修复 openclaw --version 解析(取数字开头词而非 last/pop)

- config.rs get_local_version CLI fallback: split_whitespace().last() → find(数字开头)
- dev-api.js getLocalOpenclawVersion: split().pop() → find(/^\d/)
- 同一个 bug 导致版本号被解析为 commit hash,影响版本比较和微信插件兼容检测
This commit is contained in:
晴天
2026-03-26 05:31:17 +08:00
parent 6df7f49190
commit f3d7a478ae
2 changed files with 3 additions and 3 deletions

View File

@@ -515,7 +515,7 @@ function getLocalOpenclawVersion() {
} catch {}
}
if (!current) {
try { current = execSync('openclaw --version 2>&1', { windowsHide: true }).toString().trim().split(/\s+/).pop() } catch {}
try { current = execSync('openclaw --version 2>&1', { windowsHide: true }).toString().trim().split(/\s+/).find(w => /^\d/.test(w)) || null } catch {}
}
return current || null
}

View File

@@ -1276,9 +1276,9 @@ async fn get_local_version() -> Option<String> {
.await
.ok()?;
let raw = String::from_utf8_lossy(&output.stdout).trim().to_string();
// 输出格式: "OpenClaw 2026.3.24 (hash)" → 取第一个数字开头的词(版本号)
raw.split_whitespace()
.last()
.filter(|s| !s.is_empty())
.find(|w| w.chars().next().map_or(false, |c| c.is_ascii_digit()))
.map(String::from)
}