import{_ as u}from"./index-BiA3oVDJ.js";import{r as y,c as v,x,z as t,L as w,O as a,Q as f,ac as h,aY as d,P as s,y as n,C as p}from"./vue-vendor-CKToUHZx.js";import"./element-plus-B8Fs_0jW.js";import"./vendor-BDiMbLwQ.js";const C={class:"card p-3 sm:p-6"},O={class:"mb-4 sm:mb-8"},A={class:"flex flex-wrap gap-1 sm:gap-2 p-1 sm:p-2 bg-gray-100 rounded-xl"},E=["onClick"],S={key:0,class:"tutorial-content"},T={class:"mb-6 sm:mb-10"},I={class:"bg-gradient-to-r from-orange-50 to-yellow-50 rounded-xl p-4 sm:p-6 border border-orange-100 mb-4 sm:mb-6"},N={class:"space-y-4"},G={class:"bg-white rounded-lg p-3 sm:p-4 border border-orange-200"},P={class:"bg-gray-900 text-green-400 p-2 sm:p-3 rounded font-mono text-xs sm:text-sm overflow-x-auto"},_={class:"text-gray-300 whitespace-nowrap"},L={class:"bg-white rounded-lg p-3 sm:p-4 border border-orange-200"},U={class:"mt-3 space-y-2"},D={class:"bg-gray-100 p-2 rounded text-sm"},H={class:"font-mono"},R={class:"bg-blue-50 border border-blue-200 rounded-lg p-3 sm:p-4 mt-6"},j={class:"mt-3 space-y-2"},B={class:"bg-gray-100 p-2 rounded text-sm font-mono"},K={class:"mt-8"},q={class:"space-y-4"},z={class:"bg-white rounded-lg p-3 sm:p-4 border border-green-200"},$={class:"bg-gray-900 text-green-400 p-2 sm:p-3 rounded font-mono text-xs sm:text-sm overflow-x-auto"},k={class:"text-gray-300 whitespace-nowrap"},W={class:"bg-white rounded-lg p-3 sm:p-4 border border-green-200"},M={class:"space-y-2"},V={class:"bg-gray-100 p-2 rounded text-sm"},F={class:"font-mono"},Q={key:1,class:"tutorial-content"},Y={class:"mb-6 sm:mb-10"},J={class:"bg-gradient-to-r from-orange-50 to-yellow-50 rounded-xl p-4 sm:p-6 border border-orange-100 mb-4 sm:mb-6"},X={class:"space-y-4"},Z={class:"bg-white rounded-lg p-3 sm:p-4 border border-orange-200"},ee={class:"bg-gray-900 text-green-400 p-2 sm:p-3 rounded font-mono text-xs sm:text-sm overflow-x-auto"},te={class:"text-gray-300 whitespace-nowrap"},se={class:"bg-white rounded-lg p-3 sm:p-4 border border-orange-200"},ae={class:"bg-gray-900 text-green-400 p-2 sm:p-3 rounded font-mono text-xs sm:text-sm overflow-x-auto mb-3"},de={class:"text-gray-300 whitespace-nowrap"},oe={class:"bg-gray-900 text-green-400 p-2 sm:p-3 rounded font-mono text-xs sm:text-sm overflow-x-auto"},re={class:"text-gray-300 whitespace-nowrap"},me={class:"mt-8"},le={class:"space-y-4"},ie={class:"bg-white rounded-lg p-3 sm:p-4 border border-green-200"},be={class:"bg-gray-900 text-green-400 p-2 sm:p-3 rounded font-mono text-xs sm:text-sm overflow-x-auto"},xe={class:"text-gray-300 whitespace-nowrap"},ne={class:"bg-white rounded-lg p-3 sm:p-4 border border-green-200"},ce={class:"bg-gray-900 text-green-400 p-2 sm:p-3 rounded font-mono text-xs sm:text-sm overflow-x-auto mb-3"},ve={class:"text-gray-300 whitespace-nowrap"},pe={class:"bg-gray-900 text-green-400 p-2 sm:p-3 rounded font-mono text-xs sm:text-sm overflow-x-auto"},ge={class:"text-gray-300 whitespace-nowrap"},ue={key:2,class:"tutorial-content"},ye={class:"mb-6 sm:mb-10"},we={class:"bg-gradient-to-r from-orange-50 to-yellow-50 rounded-xl p-4 sm:p-6 border border-orange-100 mb-4 sm:mb-6"},fe={class:"space-y-4"},he={class:"bg-white rounded-lg p-3 sm:p-4 border border-orange-200"},Ce={class:"bg-gray-900 text-green-400 p-2 sm:p-3 rounded font-mono text-xs sm:text-sm overflow-x-auto"},Oe={class:"text-gray-300 whitespace-nowrap"},Ae={class:"bg-white rounded-lg p-3 sm:p-4 border border-orange-200"},Ee={class:"bg-gray-900 text-green-400 p-2 sm:p-3 rounded font-mono text-xs sm:text-sm overflow-x-auto mb-3"},Se={class:"text-gray-300 whitespace-nowrap"},Te={class:"bg-gray-900 text-green-400 p-2 sm:p-3 rounded font-mono text-xs sm:text-sm overflow-x-auto"},Ie={class:"text-gray-300 whitespace-nowrap"},Ne={class:"mt-8"},Ge={class:"space-y-4"},Pe={class:"bg-white rounded-lg p-3 sm:p-4 border border-green-200"},_e={class:"bg-gray-900 text-green-400 p-2 sm:p-3 rounded font-mono text-xs sm:text-sm overflow-x-auto"},Le={class:"text-gray-300 whitespace-nowrap"},Ue={class:"bg-white rounded-lg p-3 sm:p-4 border border-green-200"},De={class:"bg-gray-900 text-green-400 p-2 sm:p-3 rounded font-mono text-xs sm:text-sm overflow-x-auto mb-3"},He={class:"text-gray-300 whitespace-nowrap"},Re={class:"bg-gray-900 text-green-400 p-2 sm:p-3 rounded font-mono text-xs sm:text-sm overflow-x-auto"},je={class:"text-gray-300 whitespace-nowrap"},Be={__name:"TutorialView",setup(Ke){const i=y("windows"),g=[{key:"windows",name:"Windows",icon:"fab fa-windows"},{key:"macos",name:"macOS",icon:"fab fa-apple"},{key:"linux",name:"Linux / WSL2",icon:"fab fa-linux"}],c=()=>{let l="";if(window.location.origin)l=window.location.origin;else{const e=window.location.protocol,o=window.location.hostname,b=window.location.port;l=e+"//"+o,b&&(e==="http:"&&b!=="80"||e==="https:"&&b!=="443")&&(l+=":"+b)}if(!l){const e=window.location.href,o=e.indexOf("/",8);if(o!==-1)l=e.substring(0,o);else return console.warn("无法获取完整的 origin,将使用相对路径"),""}return l},r=v(()=>c()+"/api"),m=v(()=>c()+"/gemini");return(l,e)=>(n(),x("div",C,[e[107]||(e[107]=t("div",{class:"mb-4 sm:mb-8"},[t("h3",{class:"text-xl sm:text-2xl font-bold text-gray-900 mb-3 sm:mb-4 flex items-center"},[t("i",{class:"fas fa-graduation-cap text-blue-600 mr-2 sm:mr-3"}),a(" Claude Code 使用教程 ")]),t("p",{class:"text-gray-600 text-sm sm:text-lg"}," 跟着这个教程,你可以轻松在自己的电脑上安装并使用 Claude Code。 ")],-1)),t("div",O,[t("div",A,[(n(),x(f,null,h(g,o=>t("button",{key:o.key,class:p(["flex-1 py-2 sm:py-3 px-3 sm:px-6 text-xs sm:text-sm font-semibold rounded-lg transition-all duration-300 flex items-center justify-center gap-1 sm:gap-2",i.value===o.key?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:bg-white/50 hover:text-gray-900"]),onClick:b=>i.value=o.key},[t("i",{class:p(o.icon)},null,2),a(" "+s(o.name),1)],10,E)),64))])]),i.value==="windows"?(n(),x("div",S,[e[35]||(e[35]=d('

1 安装 Node.js 环境

Claude Code 需要 Node.js 环境才能运行。

Windows 安装方法

方法一:官网下载(推荐)

  1. 打开浏览器访问 https://nodejs.org/
  2. 点击 "LTS" 版本进行下载(推荐长期支持版本)
  3. 下载完成后双击 .msi 文件
  4. 按照安装向导完成安装,保持默认设置即可

方法二:使用包管理器

如果你安装了 Chocolatey 或 Scoop,可以使用命令行安装:

# 使用 Chocolatey
choco install nodejs
# 或使用 Scoop
scoop install nodejs
Windows 注意事项
  • • 建议使用 PowerShell 而不是 CMD
  • • 如果遇到权限问题,尝试以管理员身份运行
  • • 某些杀毒软件可能会误报,需要添加白名单
验证安装是否成功

安装完成后,打开 PowerShell 或 CMD,输入以下命令:

node --version
npm --version

如果显示版本号,说明安装成功了!

2 安装 Git Bash

Windows 环境下需要使用 Git Bash 安装Claude code。安装完成后,环境变量设置和使用 Claude Code 仍然在普通的 PowerShell 或 CMD 中进行。

下载并安装 Git for Windows
  1. 访问 https://git-scm.com/downloads/win
  2. 点击 "Download for Windows" 下载安装包
  3. 运行下载的 .exe 安装文件
  4. 在安装过程中保持默认设置,直接点击 "Next" 完成安装
安装完成后
  • • 在任意文件夹右键可以看到 "Git Bash Here" 选项
  • • 也可以从开始菜单启动 "Git Bash"
  • • 只需要在 Git Bash 中运行 npm install 命令
  • • 后续的环境变量设置和使用都在 PowerShell/CMD 中
验证 Git Bash 安装

打开 Git Bash,输入以下命令验证:

git --version

如果显示 Git 版本号,说明安装成功!

3 安装 Claude Code

安装 Claude Code

打开 Git Bash(重要:不要使用 PowerShell),运行以下命令:

# 在 Git Bash 中全局安装 Claude Code
npm install -g @anthropic-ai/claude-code

这个命令会从 npm 官方仓库下载并安装最新版本的 Claude Code。

重要提醒
  • • 必须在 Git Bash 中运行,不要在 PowerShell 中运行
  • • 如果遇到权限问题,可以尝试在 Git Bash 中使用 sudo 命令
验证 Claude Code 安装

安装完成后,输入以下命令检查是否安装成功:

claude --version

如果显示版本号,恭喜你!Claude Code 已经成功安装了。

',3)),t("div",T,[e[34]||(e[34]=t("h4",{class:"text-lg sm:text-xl font-semibold text-gray-800 mb-3 sm:mb-4 flex items-center"},[t("span",{class:"w-6 h-6 sm:w-8 sm:h-8 bg-orange-500 text-white rounded-full flex items-center justify-center text-xs sm:text-sm font-bold mr-2 sm:mr-3"},"4"),a(" 设置环境变量 ")],-1)),t("div",I,[e[12]||(e[12]=t("h5",{class:"text-base sm:text-lg font-semibold text-gray-800 mb-2 sm:mb-3 flex items-center"},[t("i",{class:"fas fa-cog text-orange-600 mr-2"}),a(" 配置 Claude Code 环境变量 ")],-1)),e[13]||(e[13]=t("p",{class:"text-gray-700 mb-3 sm:mb-4 text-sm sm:text-base"}," 为了让 Claude Code 连接到你的中转服务,需要设置两个环境变量: ",-1)),t("div",N,[t("div",G,[e[1]||(e[1]=t("h6",{class:"font-medium text-sm sm:text-base text-gray-800 mb-2"}," 方法一:PowerShell 临时设置(推荐) ",-1)),e[2]||(e[2]=t("p",{class:"text-gray-600 text-sm mb-3"}," 在 PowerShell 中运行以下命令: ",-1)),t("div",P,[t("div",_,' $env:ANTHROPIC_BASE_URL = "'+s(r.value)+'" ',1),e[0]||(e[0]=t("div",{class:"text-gray-300 whitespace-nowrap"},' $env:ANTHROPIC_AUTH_TOKEN = "你的API密钥" ',-1))]),e[3]||(e[3]=t("p",{class:"text-yellow-700 text-xs mt-2"},' 💡 记得将 "你的API密钥" 替换为在上方 "API Keys" 标签页中创建的实际密钥。 ',-1))]),t("div",L,[e[10]||(e[10]=t("h6",{class:"font-medium text-sm sm:text-base text-gray-800 mb-2"}," 方法二:系统环境变量(永久设置) ",-1)),e[11]||(e[11]=t("ol",{class:"text-gray-600 text-xs sm:text-sm space-y-1 list-decimal list-inside"},[t("li",null,'右键"此电脑" → "属性" → "高级系统设置"'),t("li",null,'点击"环境变量"按钮'),t("li",null,'在"用户变量"或"系统变量"中点击"新建"'),t("li",null,"添加以下两个变量:")],-1)),t("div",U,[t("div",D,[e[4]||(e[4]=t("strong",null,"变量名:",-1)),e[5]||(e[5]=a(" ANTHROPIC_BASE_URL",-1)),e[6]||(e[6]=t("br",null,null,-1)),e[7]||(e[7]=t("strong",null,"变量值:",-1)),e[8]||(e[8]=a()),t("span",H,s(r.value),1)]),e[9]||(e[9]=t("div",{class:"bg-gray-100 p-2 rounded text-sm"},[t("strong",null,"变量名:"),a(" ANTHROPIC_AUTH_TOKEN"),t("br"),t("strong",null,"变量值:"),a(),t("span",{class:"font-mono"},"你的API密钥")],-1))])])])]),t("div",R,[e[17]||(e[17]=d('
验证环境变量设置

设置完环境变量后,可以通过以下命令验证是否设置成功:

在 PowerShell 中验证:
echo $env:ANTHROPIC_BASE_URL
echo $env:ANTHROPIC_AUTH_TOKEN
在 CMD 中验证:
echo %ANTHROPIC_BASE_URL%
echo %ANTHROPIC_AUTH_TOKEN%
',3)),t("div",j,[e[15]||(e[15]=t("p",{class:"text-blue-700 text-sm"},[t("strong",null,"预期输出示例:")],-1)),t("div",B,[t("div",null,s(r.value),1),e[14]||(e[14]=t("div",null,"cr_xxxxxxxxxxxxxxxxxx",-1))]),e[16]||(e[16]=t("p",{class:"text-blue-700 text-xs"}," 💡 如果输出为空或显示变量名本身,说明环境变量设置失败,请重新设置。 ",-1))])]),t("div",K,[e[32]||(e[32]=t("h5",{class:"text-base sm:text-lg font-semibold text-gray-800 mb-2 sm:mb-3 flex items-center"},[t("i",{class:"fas fa-robot text-green-600 mr-2"}),a(" 配置 Gemini CLI 环境变量 ")],-1)),e[33]||(e[33]=t("p",{class:"text-gray-700 mb-3 sm:mb-4 text-sm sm:text-base"}," 如果你使用 Gemini CLI,需要设置以下环境变量: ",-1)),t("div",q,[t("div",z,[e[20]||(e[20]=t("h6",{class:"font-medium text-sm sm:text-base text-gray-800 mb-2"}," PowerShell 设置方法 ",-1)),e[21]||(e[21]=t("p",{class:"text-gray-600 text-sm mb-3"}," 在 PowerShell 中运行以下命令: ",-1)),t("div",$,[t("div",k,' $env:CODE_ASSIST_ENDPOINT = "'+s(m.value)+'" ',1),e[18]||(e[18]=t("div",{class:"text-gray-300 whitespace-nowrap"},' $env:GOOGLE_CLOUD_ACCESS_TOKEN = "你的API密钥" ',-1)),e[19]||(e[19]=t("div",{class:"text-gray-300 whitespace-nowrap"},' $env:GOOGLE_GENAI_USE_GCA = "true" ',-1))]),e[22]||(e[22]=t("p",{class:"text-yellow-700 text-xs mt-2"}," 💡 使用与 Claude Code 相同的 API 密钥即可。 ",-1))]),t("div",W,[e[29]||(e[29]=t("h6",{class:"font-medium text-sm sm:text-base text-gray-800 mb-2"}," 系统环境变量(永久设置) ",-1)),e[30]||(e[30]=t("p",{class:"text-gray-600 text-sm mb-3"}," 在系统环境变量中添加: ",-1)),t("div",M,[t("div",V,[e[23]||(e[23]=t("strong",null,"变量名:",-1)),e[24]||(e[24]=a(" CODE_ASSIST_ENDPOINT",-1)),e[25]||(e[25]=t("br",null,null,-1)),e[26]||(e[26]=t("strong",null,"变量值:",-1)),e[27]||(e[27]=a()),t("span",F,s(m.value),1)]),e[28]||(e[28]=d('
变量名: GOOGLE_CLOUD_ACCESS_TOKEN
变量值: 你的API密钥
变量名: GOOGLE_GENAI_USE_GCA
变量值: true
',2))])]),e[31]||(e[31]=d('
验证 Gemini CLI 环境变量

在 PowerShell 中验证:

echo $env:CODE_ASSIST_ENDPOINT
echo $env:GOOGLE_CLOUD_ACCESS_TOKEN
echo $env:GOOGLE_GENAI_USE_GCA
',1))])])]),e[36]||(e[36]=d('

5 开始使用 Claude Code

现在你可以开始使用 Claude Code 了!

启动 Claude Code
claude
在特定项目中使用
# 进入你的项目目录
cd C:\\path\\to\\your\\project
# 启动 Claude Code
claude

Windows 常见问题解决

安装时提示 "permission denied" 错误

这通常是权限问题,尝试以下解决方法:

  • 以管理员身份运行 PowerShell
  • 或者配置 npm 使用用户目录:npm config set prefix %APPDATA%\\npm
PowerShell 执行策略错误

如果遇到执行策略限制,运行:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
环境变量设置后不生效

设置永久环境变量后需要:

  • 重新启动 PowerShell 或 CMD
  • 或者注销并重新登录 Windows
  • 验证设置:echo $env:ANTHROPIC_BASE_URL
',2))])):i.value==="macos"?(n(),x("div",Q,[e[70]||(e[70]=d('

1 安装 Node.js 环境

Claude Code 需要 Node.js 环境才能运行。

macOS 安装方法

方法一:使用 Homebrew(推荐)

如果你已经安装了 Homebrew,使用它安装 Node.js 会更方便:

# 更新 Homebrew
brew update
# 安装 Node.js
brew install node

方法二:官网下载

  1. 访问 https://nodejs.org/
  2. 下载适合 macOS 的 LTS 版本
  3. 打开下载的 .pkg 文件
  4. 按照安装程序指引完成安装
macOS 注意事项
  • • 如果遇到权限问题,可能需要使用 sudo
  • • 首次运行可能需要在系统偏好设置中允许
  • • 建议使用 Terminal 或 iTerm2
验证安装是否成功

安装完成后,打开 Terminal,输入以下命令:

node --version
npm --version

如果显示版本号,说明安装成功了!

2 安装 Claude Code

安装 Claude Code

打开 Terminal,运行以下命令:

# 全局安装 Claude Code
npm install -g @anthropic-ai/claude-code

如果遇到权限问题,可以使用 sudo:

sudo npm install -g @anthropic-ai/claude-code
验证 Claude Code 安装

安装完成后,输入以下命令检查是否安装成功:

claude --version

如果显示版本号,恭喜你!Claude Code 已经成功安装了。

',2)),t("div",Y,[e[69]||(e[69]=t("h4",{class:"text-lg sm:text-xl font-semibold text-gray-800 mb-3 sm:mb-4 flex items-center"},[t("span",{class:"w-6 h-6 sm:w-8 sm:h-8 bg-orange-500 text-white rounded-full flex items-center justify-center text-xs sm:text-sm font-bold mr-2 sm:mr-3"},"3"),a(" 设置环境变量 ")],-1)),t("div",J,[e[49]||(e[49]=t("h5",{class:"text-base sm:text-lg font-semibold text-gray-800 mb-2 sm:mb-3 flex items-center"},[t("i",{class:"fas fa-cog text-orange-600 mr-2"}),a(" 配置 Claude Code 环境变量 ")],-1)),e[50]||(e[50]=t("p",{class:"text-gray-700 mb-3 sm:mb-4 text-sm sm:text-base"}," 为了让 Claude Code 连接到你的中转服务,需要设置两个环境变量: ",-1)),t("div",X,[t("div",Z,[e[38]||(e[38]=t("h6",{class:"font-medium text-sm sm:text-base text-gray-800 mb-2"}," 方法一:临时设置(当前会话) ",-1)),e[39]||(e[39]=t("p",{class:"text-gray-600 text-sm mb-3"}," 在 Terminal 中运行以下命令: ",-1)),t("div",ee,[t("div",te,' export ANTHROPIC_BASE_URL="'+s(r.value)+'" ',1),e[37]||(e[37]=t("div",{class:"text-gray-300 whitespace-nowrap"},' export ANTHROPIC_AUTH_TOKEN="你的API密钥" ',-1))]),e[40]||(e[40]=t("p",{class:"text-yellow-700 text-xs mt-2"},' 💡 记得将 "你的API密钥" 替换为在上方 "API Keys" 标签页中创建的实际密钥。 ',-1))]),t("div",se,[e[47]||(e[47]=t("h6",{class:"font-medium text-sm sm:text-base text-gray-800 mb-2"}," 方法二:永久设置 ",-1)),e[48]||(e[48]=t("p",{class:"text-gray-600 text-sm mb-3"}," 编辑你的 shell 配置文件(根据你使用的 shell): ",-1)),t("div",ae,[e[41]||(e[41]=t("div",{class:"mb-2"}," # 对于 zsh (默认) ",-1)),t("div",de,` echo 'export ANTHROPIC_BASE_URL="`+s(r.value)+`"' >> ~/.zshrc `,1),e[42]||(e[42]=t("div",{class:"text-gray-300 whitespace-nowrap"},` echo 'export ANTHROPIC_AUTH_TOKEN="你的API密钥"' >> ~/.zshrc `,-1)),e[43]||(e[43]=t("div",{class:"text-gray-300 whitespace-nowrap"}," source ~/.zshrc ",-1))]),t("div",oe,[e[44]||(e[44]=t("div",{class:"mb-2"}," # 对于 bash ",-1)),t("div",re,` echo 'export ANTHROPIC_BASE_URL="`+s(r.value)+`"' >> ~/.bash_profile `,1),e[45]||(e[45]=t("div",{class:"text-gray-300 whitespace-nowrap"},` echo 'export ANTHROPIC_AUTH_TOKEN="你的API密钥"' >> ~/.bash_profile `,-1)),e[46]||(e[46]=t("div",{class:"text-gray-300 whitespace-nowrap"}," source ~/.bash_profile ",-1))])])])]),t("div",me,[e[67]||(e[67]=t("h5",{class:"text-base sm:text-lg font-semibold text-gray-800 mb-2 sm:mb-3 flex items-center"},[t("i",{class:"fas fa-robot text-green-600 mr-2"}),a(" 配置 Gemini CLI 环境变量 ")],-1)),e[68]||(e[68]=t("p",{class:"text-gray-700 mb-3 sm:mb-4 text-sm sm:text-base"}," 如果你使用 Gemini CLI,需要设置以下环境变量: ",-1)),t("div",le,[t("div",ie,[e[53]||(e[53]=t("h6",{class:"font-medium text-sm sm:text-base text-gray-800 mb-2"}," Terminal 设置方法 ",-1)),e[54]||(e[54]=t("p",{class:"text-gray-600 text-sm mb-3"}," 在 Terminal 中运行以下命令: ",-1)),t("div",be,[t("div",xe,' export CODE_ASSIST_ENDPOINT="'+s(m.value)+'" ',1),e[51]||(e[51]=t("div",{class:"text-gray-300 whitespace-nowrap"},' export GOOGLE_CLOUD_ACCESS_TOKEN="你的API密钥" ',-1)),e[52]||(e[52]=t("div",{class:"text-gray-300 whitespace-nowrap"},' export GOOGLE_GENAI_USE_GCA="true" ',-1))]),e[55]||(e[55]=t("p",{class:"text-yellow-700 text-xs mt-2"}," 💡 使用与 Claude Code 相同的 API 密钥即可。 ",-1))]),t("div",ne,[e[64]||(e[64]=t("h6",{class:"font-medium text-sm sm:text-base text-gray-800 mb-2"}," 永久设置方法 ",-1)),e[65]||(e[65]=t("p",{class:"text-gray-600 text-sm mb-3"}," 添加到你的 shell 配置文件: ",-1)),t("div",ce,[e[56]||(e[56]=t("div",{class:"mb-2"}," # 对于 zsh (默认) ",-1)),t("div",ve,` echo 'export CODE_ASSIST_ENDPOINT="`+s(m.value)+`"' >> ~/.zshrc `,1),e[57]||(e[57]=t("div",{class:"text-gray-300 whitespace-nowrap"},` echo 'export GOOGLE_CLOUD_ACCESS_TOKEN="你的API密钥"' >> ~/.zshrc `,-1)),e[58]||(e[58]=t("div",{class:"text-gray-300 whitespace-nowrap"},` echo 'export GOOGLE_GENAI_USE_GCA="true"' >> ~/.zshrc `,-1)),e[59]||(e[59]=t("div",{class:"text-gray-300 whitespace-nowrap"}," source ~/.zshrc ",-1))]),t("div",pe,[e[60]||(e[60]=t("div",{class:"mb-2"}," # 对于 bash ",-1)),t("div",ge,` echo 'export CODE_ASSIST_ENDPOINT="`+s(m.value)+`"' >> ~/.bash_profile `,1),e[61]||(e[61]=t("div",{class:"text-gray-300 whitespace-nowrap"},` echo 'export GOOGLE_CLOUD_ACCESS_TOKEN="你的API密钥"' >> ~/.bash_profile `,-1)),e[62]||(e[62]=t("div",{class:"text-gray-300 whitespace-nowrap"},` echo 'export GOOGLE_GENAI_USE_GCA="true"' >> ~/.bash_profile `,-1)),e[63]||(e[63]=t("div",{class:"text-gray-300 whitespace-nowrap"}," source ~/.bash_profile ",-1))])]),e[66]||(e[66]=d('
验证 Gemini CLI 环境变量

在 Terminal 中验证:

echo $CODE_ASSIST_ENDPOINT
echo $GOOGLE_CLOUD_ACCESS_TOKEN
echo $GOOGLE_GENAI_USE_GCA
',1))])])]),e[71]||(e[71]=d('

4 开始使用 Claude Code

现在你可以开始使用 Claude Code 了!

启动 Claude Code
claude
在特定项目中使用
# 进入你的项目目录
cd /path/to/your/project
# 启动 Claude Code
claude

macOS 常见问题解决

安装时提示权限错误

尝试以下解决方法:

  • 使用 sudo 安装:sudo npm install -g @anthropic-ai/claude-code
  • 或者配置 npm 使用用户目录:npm config set prefix ~/.npm-global
macOS 安全设置阻止运行

如果系统阻止运行 Claude Code:

  • 打开"系统偏好设置" → "安全性与隐私"
  • 点击"仍要打开"或"允许"
  • 或者在 Terminal 中运行:sudo spctl --master-disable
环境变量不生效

检查以下几点:

  • 确认修改了正确的配置文件(.zshrc 或 .bash_profile)
  • 重新启动 Terminal
  • 验证设置:echo $ANTHROPIC_BASE_URL
',2))])):i.value==="linux"?(n(),x("div",ue,[e[105]||(e[105]=d('

1 安装 Node.js 环境

Claude Code 需要 Node.js 环境才能运行。

Linux 安装方法

方法一:使用官方仓库(推荐)

# 添加 NodeSource 仓库
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
# 安装 Node.js
sudo apt-get install -y nodejs

方法二:使用系统包管理器

虽然版本可能不是最新的,但对于基本使用已经足够:

# Ubuntu/Debian
sudo apt update
sudo apt install nodejs npm
# CentOS/RHEL/Fedora
sudo dnf install nodejs npm
Linux 注意事项
  • • 某些发行版可能需要安装额外的依赖
  • • 如果遇到权限问题,使用 sudo
  • • 确保你的用户在 npm 的全局目录有写权限
验证安装是否成功

安装完成后,打开终端,输入以下命令:

node --version
npm --version

如果显示版本号,说明安装成功了!

2 安装 Claude Code

安装 Claude Code

打开终端,运行以下命令:

# 全局安装 Claude Code
npm install -g @anthropic-ai/claude-code

如果遇到权限问题,可以使用 sudo:

sudo npm install -g @anthropic-ai/claude-code
验证 Claude Code 安装

安装完成后,输入以下命令检查是否安装成功:

claude --version

如果显示版本号,恭喜你!Claude Code 已经成功安装了。

',2)),t("div",ye,[e[104]||(e[104]=t("h4",{class:"text-lg sm:text-xl font-semibold text-gray-800 mb-3 sm:mb-4 flex items-center"},[t("span",{class:"w-6 h-6 sm:w-8 sm:h-8 bg-orange-500 text-white rounded-full flex items-center justify-center text-xs sm:text-sm font-bold mr-2 sm:mr-3"},"3"),a(" 设置环境变量 ")],-1)),t("div",we,[e[84]||(e[84]=t("h5",{class:"text-base sm:text-lg font-semibold text-gray-800 mb-2 sm:mb-3 flex items-center"},[t("i",{class:"fas fa-cog text-orange-600 mr-2"}),a(" 配置 Claude Code 环境变量 ")],-1)),e[85]||(e[85]=t("p",{class:"text-gray-700 mb-3 sm:mb-4 text-sm sm:text-base"}," 为了让 Claude Code 连接到你的中转服务,需要设置两个环境变量: ",-1)),t("div",fe,[t("div",he,[e[73]||(e[73]=t("h6",{class:"font-medium text-sm sm:text-base text-gray-800 mb-2"}," 方法一:临时设置(当前会话) ",-1)),e[74]||(e[74]=t("p",{class:"text-gray-600 text-sm mb-3"}," 在终端中运行以下命令: ",-1)),t("div",Ce,[t("div",Oe,' export ANTHROPIC_BASE_URL="'+s(r.value)+'" ',1),e[72]||(e[72]=t("div",{class:"text-gray-300 whitespace-nowrap"},' export ANTHROPIC_AUTH_TOKEN="你的API密钥" ',-1))]),e[75]||(e[75]=t("p",{class:"text-yellow-700 text-xs mt-2"},' 💡 记得将 "你的API密钥" 替换为在上方 "API Keys" 标签页中创建的实际密钥。 ',-1))]),t("div",Ae,[e[82]||(e[82]=t("h6",{class:"font-medium text-sm sm:text-base text-gray-800 mb-2"}," 方法二:永久设置 ",-1)),e[83]||(e[83]=t("p",{class:"text-gray-600 text-sm mb-3"}," 编辑你的 shell 配置文件: ",-1)),t("div",Ee,[e[76]||(e[76]=t("div",{class:"mb-2"}," # 对于 bash (默认) ",-1)),t("div",Se,` echo 'export ANTHROPIC_BASE_URL="`+s(r.value)+`"' >> ~/.bashrc `,1),e[77]||(e[77]=t("div",{class:"text-gray-300 whitespace-nowrap"},` echo 'export ANTHROPIC_AUTH_TOKEN="你的API密钥"' >> ~/.bashrc `,-1)),e[78]||(e[78]=t("div",{class:"text-gray-300 whitespace-nowrap"}," source ~/.bashrc ",-1))]),t("div",Te,[e[79]||(e[79]=t("div",{class:"mb-2"}," # 对于 zsh ",-1)),t("div",Ie,` echo 'export ANTHROPIC_BASE_URL="`+s(r.value)+`"' >> ~/.zshrc `,1),e[80]||(e[80]=t("div",{class:"text-gray-300 whitespace-nowrap"},` echo 'export ANTHROPIC_AUTH_TOKEN="你的API密钥"' >> ~/.zshrc `,-1)),e[81]||(e[81]=t("div",{class:"text-gray-300 whitespace-nowrap"}," source ~/.zshrc ",-1))])])])]),t("div",Ne,[e[102]||(e[102]=t("h5",{class:"text-base sm:text-lg font-semibold text-gray-800 mb-2 sm:mb-3 flex items-center"},[t("i",{class:"fas fa-robot text-green-600 mr-2"}),a(" 配置 Gemini CLI 环境变量 ")],-1)),e[103]||(e[103]=t("p",{class:"text-gray-700 mb-3 sm:mb-4 text-sm sm:text-base"}," 如果你使用 Gemini CLI,需要设置以下环境变量: ",-1)),t("div",Ge,[t("div",Pe,[e[88]||(e[88]=t("h6",{class:"font-medium text-sm sm:text-base text-gray-800 mb-2"}," 终端设置方法 ",-1)),e[89]||(e[89]=t("p",{class:"text-gray-600 text-sm mb-3"}," 在终端中运行以下命令: ",-1)),t("div",_e,[t("div",Le,' export CODE_ASSIST_ENDPOINT="'+s(m.value)+'" ',1),e[86]||(e[86]=t("div",{class:"text-gray-300 whitespace-nowrap"},' export GOOGLE_CLOUD_ACCESS_TOKEN="你的API密钥" ',-1)),e[87]||(e[87]=t("div",{class:"text-gray-300 whitespace-nowrap"},' export GOOGLE_GENAI_USE_GCA="true" ',-1))]),e[90]||(e[90]=t("p",{class:"text-yellow-700 text-xs mt-2"}," 💡 使用与 Claude Code 相同的 API 密钥即可。 ",-1))]),t("div",Ue,[e[99]||(e[99]=t("h6",{class:"font-medium text-sm sm:text-base text-gray-800 mb-2"}," 永久设置方法 ",-1)),e[100]||(e[100]=t("p",{class:"text-gray-600 text-sm mb-3"}," 添加到你的 shell 配置文件: ",-1)),t("div",De,[e[91]||(e[91]=t("div",{class:"mb-2"}," # 对于 bash (默认) ",-1)),t("div",He,` echo 'export CODE_ASSIST_ENDPOINT="`+s(m.value)+`"' >> ~/.bashrc `,1),e[92]||(e[92]=t("div",{class:"text-gray-300 whitespace-nowrap"},` echo 'export GOOGLE_CLOUD_ACCESS_TOKEN="你的API密钥"' >> ~/.bashrc `,-1)),e[93]||(e[93]=t("div",{class:"text-gray-300 whitespace-nowrap"},` echo 'export GOOGLE_GENAI_USE_GCA="true"' >> ~/.bashrc `,-1)),e[94]||(e[94]=t("div",{class:"text-gray-300 whitespace-nowrap"}," source ~/.bashrc ",-1))]),t("div",Re,[e[95]||(e[95]=t("div",{class:"mb-2"}," # 对于 zsh ",-1)),t("div",je,` echo 'export CODE_ASSIST_ENDPOINT="`+s(m.value)+`"' >> ~/.zshrc `,1),e[96]||(e[96]=t("div",{class:"text-gray-300 whitespace-nowrap"},` echo 'export GOOGLE_CLOUD_ACCESS_TOKEN="你的API密钥"' >> ~/.zshrc `,-1)),e[97]||(e[97]=t("div",{class:"text-gray-300 whitespace-nowrap"},` echo 'export GOOGLE_GENAI_USE_GCA="true"' >> ~/.zshrc `,-1)),e[98]||(e[98]=t("div",{class:"text-gray-300 whitespace-nowrap"}," source ~/.zshrc ",-1))])]),e[101]||(e[101]=d('
验证 Gemini CLI 环境变量

在终端中验证:

echo $CODE_ASSIST_ENDPOINT
echo $GOOGLE_CLOUD_ACCESS_TOKEN
echo $GOOGLE_GENAI_USE_GCA
',1))])])]),e[106]||(e[106]=d('

4 开始使用 Claude Code

现在你可以开始使用 Claude Code 了!

启动 Claude Code
claude
在特定项目中使用
# 进入你的项目目录
cd /path/to/your/project
# 启动 Claude Code
claude

Linux 常见问题解决

安装时提示权限错误

尝试以下解决方法:

  • 使用 sudo 安装:sudo npm install -g @anthropic-ai/claude-code
  • 或者配置 npm 使用用户目录:npm config set prefix ~/.npm-global
  • 然后添加到 PATH:export PATH=~/.npm-global/bin:$PATH
缺少依赖库

某些 Linux 发行版需要安装额外依赖:

# Ubuntu/Debian
sudo apt install build-essential
# CentOS/RHEL
sudo dnf groupinstall "Development Tools"
环境变量不生效

检查以下几点:

  • 确认修改了正确的配置文件(.bashrc 或 .zshrc)
  • 重新启动终端或运行 source ~/.bashrc
  • 验证设置:echo $ANTHROPIC_BASE_URL
',2))])):w("",!0),e[108]||(e[108]=t("div",{class:"bg-gradient-to-r from-blue-500 to-purple-600 text-white rounded-xl p-4 sm:p-6 text-center"},[t("h5",{class:"text-lg sm:text-xl font-semibold mb-2"}," 🎉 恭喜你! "),t("p",{class:"text-blue-100 mb-3 sm:mb-4 text-sm sm:text-base"}," 你已经成功安装并配置了 Claude Code,现在可以开始享受 AI 编程助手带来的便利了。 "),t("p",{class:"text-xs sm:text-sm text-blue-200"}," 如果在使用过程中遇到任何问题,可以查看官方文档或社区讨论获取帮助。 ")],-1))]))}},We=u(Be,[["__scopeId","data-v-3c2eeab4"]]);export{We as default};