diff --git a/README.md b/README.md index fab5093..86e8be1 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,8 @@ iwr -useb https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branc ## 卸载 +> 已对齐当前安装方式:Windows 卸载脚本会按“原生 Windows 安装”路径执行卸载。 + ### macOS ```bash diff --git a/install-macos.sh b/install-macos.sh index 0625848..374bc46 100755 --- a/install-macos.sh +++ b/install-macos.sh @@ -102,6 +102,6 @@ echo -e "${GREEN}${BOLD}========================================${NC}" echo "" echo -e " ${BOLD}接下来:${NC}" echo -e " 1. 开始使用 OpenClaw:${BLUE}openclaw${NC}" -echo -e " 2. 添加技能(可选):${BLUE}openclaw configure --section skills${NC}" -echo -e " 3. 浏览可用技能:${BLUE}openclaw skills${NC}" +echo -e " 2. 查看网关状态:${BLUE}openclaw gateway status${NC}" +echo -e " 3. 如需卸载:${BLUE}curl -fsSL https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branch/main/uninstall-macos.sh | bash${NC}" echo "" diff --git a/install-windows-en.ps1 b/install-windows-en.ps1 index 7e5996f..983e55a 100644 --- a/install-windows-en.ps1 +++ b/install-windows-en.ps1 @@ -186,10 +186,9 @@ Write-Host " Setup complete!" -ForegroundColor Green Write-Host "========================================" -ForegroundColor Green Write-Host "" Write-Host " Next steps:" -ForegroundColor White -Write-Host " 1. Navigate to your project: cd your-project-path" -ForegroundColor Gray -Write-Host " 2. Start OpenClaw: openclaw" -ForegroundColor Gray -Write-Host " 3. Add skills (optional): openclaw configure --section skills" -ForegroundColor Gray -Write-Host " 4. Browse available skills: openclaw skills" -ForegroundColor Gray +Write-Host " 1. Start OpenClaw: openclaw" -ForegroundColor Gray +Write-Host " 2. Check gateway status: openclaw gateway status" -ForegroundColor Gray +Write-Host " 3. Uninstall (if needed): iwr -useb https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branch/main/uninstall-windows.ps1 | iex" -ForegroundColor Gray Write-Host "" } catch { diff --git a/install-windows.ps1 b/install-windows.ps1 index 94cf836..2a9dc99 100644 --- a/install-windows.ps1 +++ b/install-windows.ps1 @@ -187,10 +187,9 @@ Write-Host " 配置完成!" -ForegroundColor Green Write-Host "========================================" -ForegroundColor Green Write-Host "" Write-Host " 接下来:" -ForegroundColor White -Write-Host " 1. 进入项目目录:cd 你的项目路径" -ForegroundColor Gray -Write-Host " 2. 开始使用 OpenClaw:openclaw" -ForegroundColor Gray -Write-Host " 3. 添加技能(可选):openclaw configure --section skills" -ForegroundColor Gray -Write-Host " 4. 浏览可用技能:openclaw skills" -ForegroundColor Gray +Write-Host " 1. 开始使用 OpenClaw:openclaw" -ForegroundColor Gray +Write-Host " 2. 查看网关状态:openclaw gateway status" -ForegroundColor Gray +Write-Host " 3. 如需卸载:iwr -useb https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branch/main/uninstall-windows.ps1 | iex" -ForegroundColor Gray Write-Host "" } catch { diff --git a/uninstall-windows.ps1 b/uninstall-windows.ps1 index 82dc771..14ecab3 100644 --- a/uninstall-windows.ps1 +++ b/uninstall-windows.ps1 @@ -1,5 +1,6 @@ # ───────────────────────────────────────────── -# OpenClaw 卸载脚本 (Windows / WSL) +# OpenClaw 卸载脚本 (Windows) +# 与当前“原生 Windows 安装”流程对齐 # ───────────────────────────────────────────── $ErrorActionPreference = "Stop" @@ -7,6 +8,7 @@ $ErrorActionPreference = "Stop" function Write-Info($msg) { Write-Host "[信息] $msg" -ForegroundColor Cyan } function Write-Ok($msg) { Write-Host "[完成] $msg" -ForegroundColor Green } function Write-Warn($msg) { Write-Host "[警告] $msg" -ForegroundColor Yellow } +function Write-Err($msg) { Write-Host "[错误] $msg" -ForegroundColor Red; throw $msg } Write-Host "" Write-Host "========================================" -ForegroundColor White @@ -14,20 +16,51 @@ Write-Host " OpenClaw 卸载器 (Windows)" -ForegroundColor White Write-Host "========================================" -ForegroundColor White Write-Host "" -$uninstallScript = @' -set -e -export PATH="$HOME/.openclaw/bin:$PATH" -if command -v openclaw &>/dev/null; then - echo "[信息] 已找到 openclaw,正在运行卸载..." - openclaw uninstall --all --yes --non-interactive -else - echo "[警告] 在 PATH 中未找到 openclaw,使用 npx..." - npx -y openclaw uninstall --all --yes --non-interactive -fi -'@ +$uninstalled = $false -Write-Info "正在卸载 WSL 中的 OpenClaw..." -wsl -d Ubuntu-24.04 -- bash -c $uninstallScript +# 1) 优先使用已安装的 openclaw 命令 +if (Get-Command openclaw -ErrorAction SilentlyContinue) { + try { + Write-Info "已找到 openclaw,正在卸载(--all)..." + openclaw uninstall --all --yes --non-interactive + $uninstalled = $true + Write-Ok "OpenClaw 卸载命令执行完成。" + } catch { + Write-Warn "openclaw 卸载失败,尝试 npx 方式..." + } +} +# 2) 回退:npx 直接调用 +if (-not $uninstalled) { + if (Get-Command npx -ErrorAction SilentlyContinue) { + try { + Write-Info "使用 npx 执行卸载..." + npx -y openclaw uninstall --all --yes --non-interactive + $uninstalled = $true + Write-Ok "OpenClaw 卸载命令执行完成(npx)。" + } catch { + Write-Warn "npx 卸载失败。" + } + } else { + Write-Warn "未找到 npx,跳过 npx 卸载。" + } +} + +# 3) 清理全局 npm 包(幂等,失败不终止) +if (Get-Command npm -ErrorAction SilentlyContinue) { + try { + Write-Info "尝试移除全局 npm 包 openclaw(如存在)..." + npm uninstall -g openclaw 2>$null | Out-Null + Write-Ok "全局 npm 包清理完成。" + } catch { + Write-Warn "全局 npm 包清理跳过:$_" + } +} + +if (-not $uninstalled) { + Write-Err "未能完成 OpenClaw 卸载。请确认 Node.js/npm 可用后重试。" +} + +Write-Host "" Write-Ok "OpenClaw 已卸载。" Write-Host ""