feat: china-first openclaw install (npmmirror fallback to npmjs)

This commit is contained in:
2026-03-09 22:18:52 +08:00
parent ff9383f597
commit 4dcf1d6b3c
4 changed files with 57 additions and 9 deletions

View File

@@ -187,12 +187,27 @@ if (Get-Command git -ErrorAction SilentlyContinue) {
# ─────────────────────────────────────────────
# 步骤 3: 安装 / 更新 OpenClaw
# 国内网络优先npmmirror → npmjs必要时
# ─────────────────────────────────────────────
Write-Info "正在安装 / 更新 OpenClaw..."
npm install -g openclaw@latest 2>&1 | Write-Host
if ($LASTEXITCODE -ne 0) {
Write-Err "OpenClaw 安装失败。请手动运行npm install -g openclaw@latest"
function Install-OpenClawByRegistry($registry) {
Write-Info "尝试通过 npm 安装 OpenClaw$registry..."
npm install -g openclaw@latest --registry=$registry 2>&1 | Write-Host
return ($LASTEXITCODE -eq 0)
}
$installedOpenClaw = $false
if (Install-OpenClawByRegistry "https://registry.npmmirror.com") {
Write-Ok "已通过 npmmirror 安装 / 更新 OpenClaw。"
$installedOpenClaw = $true
} elseif (Install-OpenClawByRegistry "https://registry.npmjs.org") {
Write-Ok "已通过 npm 官方源安装 / 更新 OpenClaw。"
$installedOpenClaw = $true
}
if (-not $installedOpenClaw) {
Write-Err "OpenClaw 安装失败npmmirror 与 npm 官方源均不可用。"
}
# 刷新 PATH