diff --git a/claude/setup-claude-deepseek.ps1 b/claude/setup-claude-deepseek.ps1 new file mode 100644 index 0000000..e7fd631 --- /dev/null +++ b/claude/setup-claude-deepseek.ps1 @@ -0,0 +1,89 @@ +#Requires -Version 7 +# ============================================================= +# Claude Code + DeepSeek 一键配置脚本 +# 用法:在 pwsh (PowerShell 7) 中执行此脚本 +# ============================================================= + +$DEEPSEEK_API_KEY = "sk-a7e8782b1d5547a692ef2efec55b44f2" +$DEEPSEEK_BASE_URL = "https://api.deepseek.com/anthropic" +$DEEPSEEK_MODEL = "deepseek-v3-0324" + +Write-Host "=== Claude Code + DeepSeek 配置开始 ===" -ForegroundColor Cyan + +# ── 1. 检查 Node.js ────────────────────────────────────────── +Write-Host "`n[1/4] 检查 Node.js..." -ForegroundColor Yellow +if (-not (Get-Command node -ErrorAction SilentlyContinue)) { + Write-Host "未找到 Node.js,请先安装:https://nodejs.org/" -ForegroundColor Red + exit 1 +} +Write-Host "Node.js $(node --version) 已安装" -ForegroundColor Green + +# ── 2. 安装 Claude Code ─────────────────────────────────────── +Write-Host "`n[2/4] 安装 Claude Code..." -ForegroundColor Yellow +if (Get-Command claude -ErrorAction SilentlyContinue) { + Write-Host "Claude Code 已安装:$(claude --version 2>&1)" -ForegroundColor Green +} else { + npm install -g @anthropic-ai/claude-code + if ($LASTEXITCODE -ne 0) { Write-Host "安装失败,请检查 npm 网络" -ForegroundColor Red; exit 1 } + Write-Host "Claude Code 安装成功" -ForegroundColor Green +} + +# ── 3. 写入 ~/.claude/settings.json(仅保留 model) ────────── +Write-Host "`n[3/4] 配置 ~/.claude/settings.json..." -ForegroundColor Yellow +$claudeDir = "$env:USERPROFILE\.claude" +if (-not (Test-Path $claudeDir)) { New-Item -ItemType Directory -Path $claudeDir | Out-Null } +@{ model = $DEEPSEEK_MODEL } | ConvertTo-Json | Set-Content -Path "$claudeDir\settings.json" -Encoding UTF8 +Write-Host "已写入 $claudeDir\settings.json" -ForegroundColor Green + +# ── 4. 设置用户级环境变量 + pwsh profile ────────────────────── +Write-Host "`n[4/4] 设置环境变量与 PowerShell profile..." -ForegroundColor Yellow + +[System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", $DEEPSEEK_BASE_URL, "User") +[System.Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", $DEEPSEEK_API_KEY, "User") +[System.Environment]::SetEnvironmentVariable("CLAUDE_MODEL", $DEEPSEEK_MODEL, "User") +Write-Host "用户级环境变量已设置" -ForegroundColor Green + +# 仅写入 pwsh (PowerShell 7) profile +$pwshProfile = "$env:USERPROFILE\Documents\PowerShell\Microsoft.PowerShell_profile.ps1" +$profileDir = Split-Path $pwshProfile +if (-not (Test-Path $profileDir)) { New-Item -ItemType Directory -Path $profileDir | Out-Null } + +$profileContent = @" +`$env:ANTHROPIC_BASE_URL = "$DEEPSEEK_BASE_URL" +`$env:ANTHROPIC_API_KEY = "$DEEPSEEK_API_KEY" +`$env:CLAUDE_MODEL = "$DEEPSEEK_MODEL" +"@ + +if (Test-Path $pwshProfile) { + $existing = Get-Content $pwshProfile -Raw + if ($existing -match "deepseek\.com") { + Set-Content -Path $pwshProfile -Value $profileContent -Encoding UTF8 + Write-Host "已更新:$pwshProfile" -ForegroundColor Green + } else { + Add-Content -Path $pwshProfile -Value "`n$profileContent" + Write-Host "已追加到:$pwshProfile" -ForegroundColor Green + } +} else { + Set-Content -Path $pwshProfile -Value $profileContent -Encoding UTF8 + Write-Host "已创建:$pwshProfile" -ForegroundColor Green +} + +# ── 确保执行策略允许 profile 运行 ───────────────────────────── +$policy = Get-ExecutionPolicy -Scope CurrentUser +if ($policy -eq "Restricted" -or $policy -eq "Undefined") { + Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned -Force + Write-Host "已设置执行策略:RemoteSigned" -ForegroundColor Green +} + +# ── 验证连接 ────────────────────────────────────────────────── +Write-Host "`n=== 验证连接 ===" -ForegroundColor Cyan +$env:ANTHROPIC_BASE_URL = $DEEPSEEK_BASE_URL +$env:ANTHROPIC_API_KEY = $DEEPSEEK_API_KEY +$result = claude -p "say hi" 2>&1 +if ($LASTEXITCODE -eq 0) { + Write-Host "连接成功:$result" -ForegroundColor Green +} else { + Write-Host "连接失败:$result" -ForegroundColor Red +} + +Write-Host "`n=== 配置完成!新开终端直接运行 claude 即可 ===" -ForegroundColor Cyan diff --git a/vps-xray/client-macos.md b/vps-xray/client-macos.md index bc972a5..ac4ce42 100644 --- a/vps-xray/client-macos.md +++ b/vps-xray/client-macos.md @@ -96,6 +96,67 @@ V2BOX 在 macOS 上通过系统 **VPN 扩展**(Network Extension)工作, > 若连接后在主界面找不到模式切换,可进入 **Settings(设置)** 查找 **Proxy Mode** 或 **Route Mode** 选项。 +### 只加速国外网站(国内直连) + +这是日常最推荐的使用方式:国内网站走本地网络(速度快、不占用 VPS 流量),国外网站自动走代理。 + +#### 第一步:导入分流规则 + +复制以下完整链接(包含 `v2box://` 开头): + +``` +v2box://routes?multi=W3sicmVtYXJrIjoi55u06L+eIiwibGlzdElQIjpbImdlb2lwOkNOIiwiZ2VvaXA6cHJpdmF0ZSJdLCJtYXRjaE1vZGUiOiJrZXl3b3JkIiwidGFnIjoiZGlyZWN0IiwidHlwZSI6IklQIiwiaXNFbmFibGUiOnRydWUsImxpc3QiOlsiZ2Vvc2l0ZTpjbiIsImdlb3NpdGU6cHJpdmF0ZSJdLCJuYW1lIjoicm91dGUuMzE4QTk2OEMtMEE0MC00OEY0LUJCNzgtOEEzRTE5RjAwOUYxIn0seyJyZW1hcmsiOiI5R0YiLCJsaXN0SVAiOlsiZ2VvaXA6OTFGIl0sIm1hdGNoTW9kZSI6ImtleXdvcmQiLCJ0YWciOiJwcm94eSIsInR5cGUiOiJJUCIsImlzRW5hYmxlIjp0cnVlLCJsaXN0IjpbImdlb3NpdGU6OTFGIl0sIm5hbWUiOiJyb3V0ZS4wQzU5QTQwOC0xNkY1LTRFMDAtQkYwMC0wRTk1QzQwQzUxRTIifSx7InJlbWFyayI6IuW3peWFtS6j+W3peWFtSIsImxpc3RJUCI6W10sIm1hdGNoTW9kZSI6ImtleXdvcmQiLCJ0YWciOiJibG9jayIsInR5cGUiOiJkb21haW4iLCJpc0VuYWJsZSI6dHJ1ZSwibGlzdCI6WyJjbiIsImNvbS5jbiIsIm5ldC5jbiIsIm5ldCIsImNvbSIsIm5ldCIsImNvbS5jbiJdLCJuYW1lIjoicm91dGUuQzY5RjE4OTAtQ0UxOC00Q0I4LWEwOTAtQjU5QkI4QzQ2QzJkIn1d +``` + +然后在 V2BOX 中导入: + +1. 打开 V2BOX → 底部导航点 **Home** +2. 进入 **Routing(路由)** 页面 +3. 点右上角**导入图标**(⍗ 箭头朝下) +4. 在弹出框中粘贴上方链接 → 点 **Import** + +导入成功后会出现三条规则: + +| 规则名 | 说明 | +|--------|------| +| 直连(国内) | geoip:CN + geosite:cn,国内流量直连 | +| 代理(国外) | 其余流量走 VPS 代理 | +| 阻止(广告) | 屏蔽常见广告域名 | + +#### 第二步:设置域名策略(关键) + +在 **Routing** 页面找到 **Domain Strategy(域名策略)**,下拉选择: + +> ✅ **IPIfNonMatch** —— 国内直连最准确,白名单专用 + +| 选项 | 是否推荐 | 说明 | +|------|---------|------| +| **IPIfNonMatch** | ✅ 推荐 | 域名无法判断时解析 IP 再匹配,准确率最高 | +| AsIs | ❌ 不选 | 仅匹配域名字符串,国内网站可能误走代理 | +| IPOnDemand | ❌ 不选 | 每次都解析 IP,耗电且无必要 | + +同时确认开启: + +- ✅ **Enable Routing**(路由总开关) +- ✅ **Apple on direct**(App Store / iCloud 直连,避免更新走代理) + +#### 第三步:连接并验证 + +1. 回到 **Home**,选择节点后开启连接 +2. 验证分流是否正常: + - 访问百度 / 淘宝 / B 站 → IP 应为本地运营商 IP(直连) + - 访问 [https://www.ip.sb](https://www.ip.sb) → IP 应为 VPS IP(走代理) + - 访问 Google / YouTube → 能正常打开 + +**流量消耗提示:** + +Rule 模式下,只有境外流量计入 VPS 月流量,国内视频、音乐、购物等不消耗 VPS 带宽,可大幅节省流量配额。 + +**常见问题:** + +- **导入没反应**:确认链接完整(开头 `v2box://` 不能丢),并更新 V2BOX 至最新版 +- **国内网站仍走代理**:确认 Domain Strategy 已选 **IPIfNonMatch**,修改后重启连接 + ### 验证连接 连接后访问 [https://www.ip.sb](https://www.ip.sb),显示的 IP 应为 VPS 的 IP,说明代理成功。