feat: merge install/uninstall into one interactive entrypoint
This commit is contained in:
@@ -20,6 +20,48 @@ try {
|
||||
|
||||
Write-Header
|
||||
|
||||
Write-Host "请选择操作:" -ForegroundColor White
|
||||
Write-Host " 1) 安装 / 更新 OpenClaw" -ForegroundColor Gray
|
||||
Write-Host " 2) 卸载 OpenClaw" -ForegroundColor Gray
|
||||
$action = Read-Host "请输入选项 [1/2](默认 1)"
|
||||
if ([string]::IsNullOrWhiteSpace($action)) { $action = "1" }
|
||||
|
||||
if ($action -eq "2") {
|
||||
Write-Info "你选择了:卸载 OpenClaw"
|
||||
|
||||
$uninstalled = $false
|
||||
|
||||
if (Get-Command openclaw -ErrorAction SilentlyContinue) {
|
||||
try {
|
||||
openclaw uninstall --all --yes --non-interactive
|
||||
$uninstalled = $true
|
||||
} catch {
|
||||
Write-Warn "openclaw 卸载失败,尝试 npx 方式..."
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $uninstalled -and (Get-Command npx -ErrorAction SilentlyContinue)) {
|
||||
try {
|
||||
npx -y openclaw uninstall --all --yes --non-interactive
|
||||
$uninstalled = $true
|
||||
} catch {
|
||||
Write-Warn "npx 卸载失败。"
|
||||
}
|
||||
}
|
||||
|
||||
if (Get-Command npm -ErrorAction SilentlyContinue) {
|
||||
try { npm uninstall -g openclaw 2>$null | Out-Null } catch {}
|
||||
}
|
||||
|
||||
if ($uninstalled) {
|
||||
Write-Ok "OpenClaw 已卸载。"
|
||||
} else {
|
||||
Write-Err "未能完成 OpenClaw 卸载。请确认 Node.js/npm 可用后重试。"
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# 步骤 1: 检查 / 安装 Node.js 22+
|
||||
# ─────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user