import{_ as u}from"./index-BrpEHVq4.js";import{r as y,c as p,x,z as t,L as w,O as e,Q as f,ac as h,aY as d,P as s,y as n,C as b}from"./vue-vendor-DfnFpxGJ.js";import"./element-plus-BaMaLFJp.js";import"./vendor-BDiMbLwQ.js";const C={class:"card p-3 sm:p-6"},S={class:"mb-4 sm:mb-8"},E={class:"flex flex-wrap gap-1 rounded-xl bg-gray-100 p-1 sm:gap-2 sm:p-2"},O=["onClick"],A={key:0,class:"tutorial-content"},T={class:"mb-6 sm:mb-10"},I={class:"mb-4 rounded-xl border border-purple-100 bg-gradient-to-r from-purple-50 to-pink-50 p-4 sm:mb-6 sm:p-6"},N={class:"space-y-4"},_={class:"rounded-lg border border-purple-200 bg-white p-3 sm:p-4"},P={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},G={class:"whitespace-nowrap text-gray-300"},L={class:"rounded-lg border border-purple-200 bg-white p-3 sm:p-4"},U={class:"mb-3 overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},D={class:"whitespace-nowrap text-gray-300"},H={class:"mt-6 rounded-lg border border-blue-200 bg-blue-50 p-3 sm:p-4"},R={class:"mt-3 space-y-2"},j={class:"rounded bg-gray-100 p-2 font-mono text-sm"},K={class:"mt-8"},z={class:"space-y-4"},$={class:"rounded-lg border border-green-200 bg-white p-3 sm:p-4"},B={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},V={class:"whitespace-nowrap text-gray-300"},k={class:"rounded-lg border border-green-200 bg-white p-3 sm:p-4"},q={class:"mb-3 overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},M={class:"whitespace-nowrap text-gray-300"},W={key:1,class:"tutorial-content"},F={class:"mb-6 sm:mb-10"},Q={class:"mb-4 rounded-xl border border-orange-100 bg-gradient-to-r from-orange-50 to-yellow-50 p-4 sm:mb-6 sm:p-6"},Y={class:"space-y-4"},J={class:"rounded-lg border border-orange-200 bg-white p-3 sm:p-4"},X={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},Z={class:"whitespace-nowrap text-gray-300"},aa={class:"rounded-lg border border-orange-200 bg-white p-3 sm:p-4"},ta={class:"mb-3 overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},sa={class:"whitespace-nowrap text-gray-300"},ea={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},da={class:"whitespace-nowrap text-gray-300"},oa={class:"mt-8"},ra={class:"space-y-4"},ma={class:"rounded-lg border border-green-200 bg-white p-3 sm:p-4"},ca={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},la={class:"whitespace-nowrap text-gray-300"},ia={class:"rounded-lg border border-green-200 bg-white p-3 sm:p-4"},xa={class:"mb-3 overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},na={class:"whitespace-nowrap text-gray-300"},va={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},pa={class:"whitespace-nowrap text-gray-300"},ba={key:2,class:"tutorial-content"},ga={class:"mb-6 sm:mb-10"},ua={class:"mb-4 rounded-xl border border-orange-100 bg-gradient-to-r from-orange-50 to-yellow-50 p-4 sm:mb-6 sm:p-6"},ya={class:"space-y-4"},wa={class:"rounded-lg border border-orange-200 bg-white p-3 sm:p-4"},fa={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},ha={class:"whitespace-nowrap text-gray-300"},Ca={class:"rounded-lg border border-orange-200 bg-white p-3 sm:p-4"},Sa={class:"mb-3 overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},Ea={class:"whitespace-nowrap text-gray-300"},Oa={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},Aa={class:"whitespace-nowrap text-gray-300"},Ta={class:"mt-8"},Ia={class:"space-y-4"},Na={class:"rounded-lg border border-green-200 bg-white p-3 sm:p-4"},_a={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},Pa={class:"whitespace-nowrap text-gray-300"},Ga={class:"rounded-lg border border-green-200 bg-white p-3 sm:p-4"},La={class:"mb-3 overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},Ua={class:"whitespace-nowrap text-gray-300"},Da={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},Ha={class:"whitespace-nowrap text-gray-300"},Ra={__name:"TutorialView",setup(ja){const l=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"}],v=()=>{let c="";if(window.location.origin)c=window.location.origin;else{const a=window.location.protocol,o=window.location.hostname,i=window.location.port;c=a+"//"+o,i&&(a==="http:"&&i!=="80"||a==="https:"&&i!=="443")&&(c+=":"+i)}if(!c){const a=window.location.href,o=a.indexOf("/",8);if(o!==-1)c=a.substring(0,o);else return console.warn("无法获取完整的 origin,将使用相对路径"),""}return c},r=p(()=>v()+"/api"),m=p(()=>v()+"/gemini");return(c,a)=>(n(),x("div",C,[a[102]||(a[102]=t("div",{class:"mb-4 sm:mb-8"},[t("h3",{class:"mb-3 flex items-center text-xl font-bold text-gray-900 sm:mb-4 sm:text-2xl"},[t("i",{class:"fas fa-graduation-cap mr-2 text-blue-600 sm:mr-3"}),e(" Claude Code 使用教程 ")]),t("p",{class:"text-sm text-gray-600 sm:text-lg"}," 跟着这个教程,你可以轻松在自己的电脑上安装并使用 Claude Code。 ")],-1)),t("div",S,[t("div",E,[(n(),x(f,null,h(g,o=>t("button",{key:o.key,class:b(["flex flex-1 items-center justify-center gap-1 rounded-lg px-3 py-2 text-xs font-semibold transition-all duration-300 sm:gap-2 sm:px-6 sm:py-3 sm:text-sm",l.value===o.key?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:bg-white/50 hover:text-gray-900"]),onClick:i=>l.value=o.key},[t("i",{class:b(o.icon)},null,2),e(" "+s(o.name),1)],10,O)),64))])]),l.value==="windows"?(n(),x("div",A,[a[30]||(a[30]=d('
1 安装 Node.js 环境
Claude Code 需要 Node.js 环境才能运行。
Windows 安装方法
方法一:官网下载(推荐)
- 打开浏览器访问
https://nodejs.org/ - 点击 "LTS" 版本进行下载(推荐长期支持版本)
- 下载完成后双击
.msi 文件 - 按照安装向导完成安装,保持默认设置即可
方法二:使用包管理器
如果你安装了 Chocolatey 或 Scoop,可以使用命令行安装:
# 使用 Chocolatey
choco install nodejs
# 或使用 Scoop
scoop install nodejs
Windows 注意事项
- • 建议使用 PowerShell 而不是 CMD
- • 如果遇到权限问题,尝试以管理员身份运行
- • 某些杀毒软件可能会误报,需要添加白名单
验证安装是否成功
安装完成后,打开 PowerShell 或 CMD,输入以下命令:
node --version
npm --version
如果显示版本号,说明安装成功了!
2 安装 Claude Code
安装 Claude Code
打开 PowerShell 或 CMD,运行以下命令:
# 全局安装 Claude Code
npm install -g @anthropic-ai/claude-code
这个命令会从 npm 官方仓库下载并安装最新版本的 Claude Code。
提示
- • 建议使用 PowerShell 而不是 CMD,功能更强大
- • 如果遇到权限问题,以管理员身份运行 PowerShell
验证 Claude Code 安装
安装完成后,输入以下命令检查是否安装成功:
如果显示版本号,恭喜你!Claude Code 已经成功安装了。
',2)),t("div",T,[a[29]||(a[29]=t("h4",{class:"mb-3 flex items-center text-lg font-semibold text-gray-800 sm:mb-4 sm:text-xl"},[t("span",{class:"mr-2 flex h-6 w-6 items-center justify-center rounded-full bg-purple-500 text-xs font-bold text-white sm:mr-3 sm:h-8 sm:w-8 sm:text-sm"},"3"),e(" 设置环境变量 ")],-1)),t("div",I,[a[9]||(a[9]=t("h5",{class:"mb-2 flex items-center text-base font-semibold text-gray-800 sm:mb-3 sm:text-lg"},[t("i",{class:"fas fa-cog mr-2 text-purple-600"}),e(" 配置 Claude Code 环境变量 ")],-1)),a[10]||(a[10]=t("p",{class:"mb-3 text-sm text-gray-700 sm:mb-4 sm:text-base"}," 为了让 Claude Code 连接到你的中转服务,需要设置两个环境变量: ",-1)),t("div",N,[t("div",_,[a[1]||(a[1]=t("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"}," 方法一:PowerShell 临时设置(当前会话) ",-1)),a[2]||(a[2]=t("p",{class:"mb-3 text-sm text-gray-600"},"在 PowerShell 中运行以下命令:",-1)),t("div",P,[t("div",G,' $env:ANTHROPIC_BASE_URL = "'+s(r.value)+'" ',1),a[0]||(a[0]=t("div",{class:"whitespace-nowrap text-gray-300"},' $env:ANTHROPIC_AUTH_TOKEN = "你的API密钥" ',-1))]),a[3]||(a[3]=t("p",{class:"mt-2 text-xs text-yellow-700"},' 💡 记得将 "你的API密钥" 替换为在上方 "API Keys" 标签页中创建的实际密钥。 ',-1))]),t("div",L,[a[6]||(a[6]=t("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"}," 方法二:PowerShell 永久设置(用户级) ",-1)),a[7]||(a[7]=t("p",{class:"mb-3 text-sm text-gray-600"}," 在 PowerShell 中运行以下命令设置用户级环境变量: ",-1)),t("div",U,[a[4]||(a[4]=t("div",{class:"mb-2"},"# 设置用户级环境变量(永久生效)",-1)),t("div",D,' [System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "'+s(r.value)+'", [System.EnvironmentVariableTarget]::User) ',1),a[5]||(a[5]=t("div",{class:"whitespace-nowrap text-gray-300"},' [System.Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "你的API密钥", [System.EnvironmentVariableTarget]::User) ',-1))]),a[8]||(a[8]=d('查看已设置的环境变量:
# 查看用户级环境变量
[System.Environment]::GetEnvironmentVariable("ANTHROPIC_BASE_URL", [System.EnvironmentVariableTarget]::User)
[System.Environment]::GetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", [System.EnvironmentVariableTarget]::User)
💡 设置后需要重新打开 PowerShell 窗口才能生效。
',3))])])]),t("div",H,[a[14]||(a[14]=d('验证环境变量设置
设置完环境变量后,可以通过以下命令验证是否设置成功:
在 PowerShell 中验证:
echo $env:ANTHROPIC_BASE_URL
echo $env:ANTHROPIC_AUTH_TOKEN
在 CMD 中验证:
echo %ANTHROPIC_BASE_URL%
echo %ANTHROPIC_AUTH_TOKEN%
',3)),t("div",R,[a[12]||(a[12]=t("p",{class:"text-sm text-blue-700"},[t("strong",null,"预期输出示例:")],-1)),t("div",j,[t("div",null,s(r.value),1),a[11]||(a[11]=t("div",null,"cr_xxxxxxxxxxxxxxxxxx",-1))]),a[13]||(a[13]=t("p",{class:"text-xs text-blue-700"}," 💡 如果输出为空或显示变量名本身,说明环境变量设置失败,请重新设置。 ",-1))])]),t("div",K,[a[27]||(a[27]=t("h5",{class:"mb-2 flex items-center text-base font-semibold text-gray-800 sm:mb-3 sm:text-lg"},[t("i",{class:"fas fa-robot mr-2 text-green-600"}),e(" 配置 Gemini CLI 环境变量 ")],-1)),a[28]||(a[28]=t("p",{class:"mb-3 text-sm text-gray-700 sm:mb-4 sm:text-base"}," 如果你使用 Gemini CLI,需要设置以下环境变量: ",-1)),t("div",z,[t("div",$,[a[17]||(a[17]=t("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"}," PowerShell 设置方法 ",-1)),a[18]||(a[18]=t("p",{class:"mb-3 text-sm text-gray-600"},"在 PowerShell 中运行以下命令:",-1)),t("div",B,[t("div",V,' $env:CODE_ASSIST_ENDPOINT = "'+s(m.value)+'" ',1),a[15]||(a[15]=t("div",{class:"whitespace-nowrap text-gray-300"},' $env:GOOGLE_CLOUD_ACCESS_TOKEN = "你的API密钥" ',-1)),a[16]||(a[16]=t("div",{class:"whitespace-nowrap text-gray-300"},' $env:GOOGLE_GENAI_USE_GCA = "true" ',-1))]),a[19]||(a[19]=t("p",{class:"mt-2 text-xs text-yellow-700"}," 💡 使用与 Claude Code 相同的 API 密钥即可。 ",-1))]),t("div",k,[a[23]||(a[23]=t("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"}," PowerShell 永久设置(用户级) ",-1)),a[24]||(a[24]=t("p",{class:"mb-3 text-sm text-gray-600"},"在 PowerShell 中运行以下命令:",-1)),t("div",q,[a[20]||(a[20]=t("div",{class:"mb-2"},"# 设置用户级环境变量(永久生效)",-1)),t("div",M,' [System.Environment]::SetEnvironmentVariable("CODE_ASSIST_ENDPOINT", "'+s(m.value)+'", [System.EnvironmentVariableTarget]::User) ',1),a[21]||(a[21]=t("div",{class:"whitespace-nowrap text-gray-300"},' [System.Environment]::SetEnvironmentVariable("GOOGLE_CLOUD_ACCESS_TOKEN", "你的API密钥", [System.EnvironmentVariableTarget]::User) ',-1)),a[22]||(a[22]=t("div",{class:"whitespace-nowrap text-gray-300"},' [System.Environment]::SetEnvironmentVariable("GOOGLE_GENAI_USE_GCA", "true", [System.EnvironmentVariableTarget]::User) ',-1))]),a[25]||(a[25]=t("p",{class:"mt-2 text-xs text-blue-700"}," 💡 设置后需要重新打开 PowerShell 窗口才能生效。 ",-1))]),a[26]||(a[26]=d('验证 Gemini CLI 环境变量
在 PowerShell 中验证:
echo $env:CODE_ASSIST_ENDPOINT
echo $env:GOOGLE_CLOUD_ACCESS_TOKEN
echo $env:GOOGLE_GENAI_USE_GCA
',1))])])]),a[31]||(a[31]=d('4 开始使用 Claude Code
现在你可以开始使用 Claude Code 了!
在特定项目中使用
# 进入你的项目目录
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))])):l.value==="macos"?(n(),x("div",W,[a[65]||(a[65]=d('1 安装 Node.js 环境
Claude Code 需要 Node.js 环境才能运行。
macOS 安装方法
方法一:使用 Homebrew(推荐)
如果你已经安装了 Homebrew,使用它安装 Node.js 会更方便:
# 更新 Homebrew
brew update
# 安装 Node.js
brew install node
方法二:官网下载
- 访问
https://nodejs.org/ - 下载适合 macOS 的 LTS 版本
- 打开下载的
.pkg 文件 - 按照安装程序指引完成安装
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 Code 已经成功安装了。
',2)),t("div",F,[a[64]||(a[64]=t("h4",{class:"mb-3 flex items-center text-lg font-semibold text-gray-800 sm:mb-4 sm:text-xl"},[t("span",{class:"mr-2 flex h-6 w-6 items-center justify-center rounded-full bg-orange-500 text-xs font-bold text-white sm:mr-3 sm:h-8 sm:w-8 sm:text-sm"},"3"),e(" 设置环境变量 ")],-1)),t("div",Q,[a[44]||(a[44]=t("h5",{class:"mb-2 flex items-center text-base font-semibold text-gray-800 sm:mb-3 sm:text-lg"},[t("i",{class:"fas fa-cog mr-2 text-orange-600"}),e(" 配置 Claude Code 环境变量 ")],-1)),a[45]||(a[45]=t("p",{class:"mb-3 text-sm text-gray-700 sm:mb-4 sm:text-base"}," 为了让 Claude Code 连接到你的中转服务,需要设置两个环境变量: ",-1)),t("div",Y,[t("div",J,[a[33]||(a[33]=t("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"}," 方法一:临时设置(当前会话) ",-1)),a[34]||(a[34]=t("p",{class:"mb-3 text-sm text-gray-600"},"在 Terminal 中运行以下命令:",-1)),t("div",X,[t("div",Z,' export ANTHROPIC_BASE_URL="'+s(r.value)+'" ',1),a[32]||(a[32]=t("div",{class:"whitespace-nowrap text-gray-300"},' export ANTHROPIC_AUTH_TOKEN="你的API密钥" ',-1))]),a[35]||(a[35]=t("p",{class:"mt-2 text-xs text-yellow-700"},' 💡 记得将 "你的API密钥" 替换为在上方 "API Keys" 标签页中创建的实际密钥。 ',-1))]),t("div",aa,[a[42]||(a[42]=t("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"},"方法二:永久设置",-1)),a[43]||(a[43]=t("p",{class:"mb-3 text-sm text-gray-600"}," 编辑你的 shell 配置文件(根据你使用的 shell): ",-1)),t("div",ta,[a[36]||(a[36]=t("div",{class:"mb-2"},"# 对于 zsh (默认)",-1)),t("div",sa,` echo 'export ANTHROPIC_BASE_URL="`+s(r.value)+`"' >> ~/.zshrc `,1),a[37]||(a[37]=t("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export ANTHROPIC_AUTH_TOKEN="你的API密钥"' >> ~/.zshrc `,-1)),a[38]||(a[38]=t("div",{class:"whitespace-nowrap text-gray-300"},"source ~/.zshrc",-1))]),t("div",ea,[a[39]||(a[39]=t("div",{class:"mb-2"},"# 对于 bash",-1)),t("div",da,` echo 'export ANTHROPIC_BASE_URL="`+s(r.value)+`"' >> ~/.bash_profile `,1),a[40]||(a[40]=t("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export ANTHROPIC_AUTH_TOKEN="你的API密钥"' >> ~/.bash_profile `,-1)),a[41]||(a[41]=t("div",{class:"whitespace-nowrap text-gray-300"},"source ~/.bash_profile",-1))])])])]),t("div",oa,[a[62]||(a[62]=t("h5",{class:"mb-2 flex items-center text-base font-semibold text-gray-800 sm:mb-3 sm:text-lg"},[t("i",{class:"fas fa-robot mr-2 text-green-600"}),e(" 配置 Gemini CLI 环境变量 ")],-1)),a[63]||(a[63]=t("p",{class:"mb-3 text-sm text-gray-700 sm:mb-4 sm:text-base"}," 如果你使用 Gemini CLI,需要设置以下环境变量: ",-1)),t("div",ra,[t("div",ma,[a[48]||(a[48]=t("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"},"Terminal 设置方法",-1)),a[49]||(a[49]=t("p",{class:"mb-3 text-sm text-gray-600"},"在 Terminal 中运行以下命令:",-1)),t("div",ca,[t("div",la,' export CODE_ASSIST_ENDPOINT="'+s(m.value)+'" ',1),a[46]||(a[46]=t("div",{class:"whitespace-nowrap text-gray-300"},' export GOOGLE_CLOUD_ACCESS_TOKEN="你的API密钥" ',-1)),a[47]||(a[47]=t("div",{class:"whitespace-nowrap text-gray-300"},' export GOOGLE_GENAI_USE_GCA="true" ',-1))]),a[50]||(a[50]=t("p",{class:"mt-2 text-xs text-yellow-700"}," 💡 使用与 Claude Code 相同的 API 密钥即可。 ",-1))]),t("div",ia,[a[59]||(a[59]=t("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"},"永久设置方法",-1)),a[60]||(a[60]=t("p",{class:"mb-3 text-sm text-gray-600"},"添加到你的 shell 配置文件:",-1)),t("div",xa,[a[51]||(a[51]=t("div",{class:"mb-2"},"# 对于 zsh (默认)",-1)),t("div",na,` echo 'export CODE_ASSIST_ENDPOINT="`+s(m.value)+`"' >> ~/.zshrc `,1),a[52]||(a[52]=t("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export GOOGLE_CLOUD_ACCESS_TOKEN="你的API密钥"' >> ~/.zshrc `,-1)),a[53]||(a[53]=t("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export GOOGLE_GENAI_USE_GCA="true"' >> ~/.zshrc `,-1)),a[54]||(a[54]=t("div",{class:"whitespace-nowrap text-gray-300"},"source ~/.zshrc",-1))]),t("div",va,[a[55]||(a[55]=t("div",{class:"mb-2"},"# 对于 bash",-1)),t("div",pa,` echo 'export CODE_ASSIST_ENDPOINT="`+s(m.value)+`"' >> ~/.bash_profile `,1),a[56]||(a[56]=t("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export GOOGLE_CLOUD_ACCESS_TOKEN="你的API密钥"' >> ~/.bash_profile `,-1)),a[57]||(a[57]=t("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export GOOGLE_GENAI_USE_GCA="true"' >> ~/.bash_profile `,-1)),a[58]||(a[58]=t("div",{class:"whitespace-nowrap text-gray-300"},"source ~/.bash_profile",-1))])]),a[61]||(a[61]=d('验证 Gemini CLI 环境变量
在 Terminal 中验证:
echo $CODE_ASSIST_ENDPOINT
echo $GOOGLE_CLOUD_ACCESS_TOKEN
echo $GOOGLE_GENAI_USE_GCA
',1))])])]),a[66]||(a[66]=d('4 开始使用 Claude Code
现在你可以开始使用 Claude Code 了!
在特定项目中使用
# 进入你的项目目录
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))])):l.value==="linux"?(n(),x("div",ba,[a[100]||(a[100]=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 Code 已经成功安装了。
',2)),t("div",ga,[a[99]||(a[99]=t("h4",{class:"mb-3 flex items-center text-lg font-semibold text-gray-800 sm:mb-4 sm:text-xl"},[t("span",{class:"mr-2 flex h-6 w-6 items-center justify-center rounded-full bg-orange-500 text-xs font-bold text-white sm:mr-3 sm:h-8 sm:w-8 sm:text-sm"},"3"),e(" 设置环境变量 ")],-1)),t("div",ua,[a[79]||(a[79]=t("h5",{class:"mb-2 flex items-center text-base font-semibold text-gray-800 sm:mb-3 sm:text-lg"},[t("i",{class:"fas fa-cog mr-2 text-orange-600"}),e(" 配置 Claude Code 环境变量 ")],-1)),a[80]||(a[80]=t("p",{class:"mb-3 text-sm text-gray-700 sm:mb-4 sm:text-base"}," 为了让 Claude Code 连接到你的中转服务,需要设置两个环境变量: ",-1)),t("div",ya,[t("div",wa,[a[68]||(a[68]=t("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"}," 方法一:临时设置(当前会话) ",-1)),a[69]||(a[69]=t("p",{class:"mb-3 text-sm text-gray-600"},"在终端中运行以下命令:",-1)),t("div",fa,[t("div",ha,' export ANTHROPIC_BASE_URL="'+s(r.value)+'" ',1),a[67]||(a[67]=t("div",{class:"whitespace-nowrap text-gray-300"},' export ANTHROPIC_AUTH_TOKEN="你的API密钥" ',-1))]),a[70]||(a[70]=t("p",{class:"mt-2 text-xs text-yellow-700"},' 💡 记得将 "你的API密钥" 替换为在上方 "API Keys" 标签页中创建的实际密钥。 ',-1))]),t("div",Ca,[a[77]||(a[77]=t("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"},"方法二:永久设置",-1)),a[78]||(a[78]=t("p",{class:"mb-3 text-sm text-gray-600"},"编辑你的 shell 配置文件:",-1)),t("div",Sa,[a[71]||(a[71]=t("div",{class:"mb-2"},"# 对于 bash (默认)",-1)),t("div",Ea,` echo 'export ANTHROPIC_BASE_URL="`+s(r.value)+`"' >> ~/.bashrc `,1),a[72]||(a[72]=t("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export ANTHROPIC_AUTH_TOKEN="你的API密钥"' >> ~/.bashrc `,-1)),a[73]||(a[73]=t("div",{class:"whitespace-nowrap text-gray-300"},"source ~/.bashrc",-1))]),t("div",Oa,[a[74]||(a[74]=t("div",{class:"mb-2"},"# 对于 zsh",-1)),t("div",Aa,` echo 'export ANTHROPIC_BASE_URL="`+s(r.value)+`"' >> ~/.zshrc `,1),a[75]||(a[75]=t("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export ANTHROPIC_AUTH_TOKEN="你的API密钥"' >> ~/.zshrc `,-1)),a[76]||(a[76]=t("div",{class:"whitespace-nowrap text-gray-300"},"source ~/.zshrc",-1))])])])]),t("div",Ta,[a[97]||(a[97]=t("h5",{class:"mb-2 flex items-center text-base font-semibold text-gray-800 sm:mb-3 sm:text-lg"},[t("i",{class:"fas fa-robot mr-2 text-green-600"}),e(" 配置 Gemini CLI 环境变量 ")],-1)),a[98]||(a[98]=t("p",{class:"mb-3 text-sm text-gray-700 sm:mb-4 sm:text-base"}," 如果你使用 Gemini CLI,需要设置以下环境变量: ",-1)),t("div",Ia,[t("div",Na,[a[83]||(a[83]=t("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"},"终端设置方法",-1)),a[84]||(a[84]=t("p",{class:"mb-3 text-sm text-gray-600"},"在终端中运行以下命令:",-1)),t("div",_a,[t("div",Pa,' export CODE_ASSIST_ENDPOINT="'+s(m.value)+'" ',1),a[81]||(a[81]=t("div",{class:"whitespace-nowrap text-gray-300"},' export GOOGLE_CLOUD_ACCESS_TOKEN="你的API密钥" ',-1)),a[82]||(a[82]=t("div",{class:"whitespace-nowrap text-gray-300"},' export GOOGLE_GENAI_USE_GCA="true" ',-1))]),a[85]||(a[85]=t("p",{class:"mt-2 text-xs text-yellow-700"}," 💡 使用与 Claude Code 相同的 API 密钥即可。 ",-1))]),t("div",Ga,[a[94]||(a[94]=t("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"},"永久设置方法",-1)),a[95]||(a[95]=t("p",{class:"mb-3 text-sm text-gray-600"},"添加到你的 shell 配置文件:",-1)),t("div",La,[a[86]||(a[86]=t("div",{class:"mb-2"},"# 对于 bash (默认)",-1)),t("div",Ua,` echo 'export CODE_ASSIST_ENDPOINT="`+s(m.value)+`"' >> ~/.bashrc `,1),a[87]||(a[87]=t("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export GOOGLE_CLOUD_ACCESS_TOKEN="你的API密钥"' >> ~/.bashrc `,-1)),a[88]||(a[88]=t("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export GOOGLE_GENAI_USE_GCA="true"' >> ~/.bashrc `,-1)),a[89]||(a[89]=t("div",{class:"whitespace-nowrap text-gray-300"},"source ~/.bashrc",-1))]),t("div",Da,[a[90]||(a[90]=t("div",{class:"mb-2"},"# 对于 zsh",-1)),t("div",Ha,` echo 'export CODE_ASSIST_ENDPOINT="`+s(m.value)+`"' >> ~/.zshrc `,1),a[91]||(a[91]=t("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export GOOGLE_CLOUD_ACCESS_TOKEN="你的API密钥"' >> ~/.zshrc `,-1)),a[92]||(a[92]=t("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export GOOGLE_GENAI_USE_GCA="true"' >> ~/.zshrc `,-1)),a[93]||(a[93]=t("div",{class:"whitespace-nowrap text-gray-300"},"source ~/.zshrc",-1))])]),a[96]||(a[96]=d('验证 Gemini CLI 环境变量
在终端中验证:
echo $CODE_ASSIST_ENDPOINT
echo $GOOGLE_CLOUD_ACCESS_TOKEN
echo $GOOGLE_GENAI_USE_GCA
',1))])])]),a[101]||(a[101]=d('4 开始使用 Claude Code
现在你可以开始使用 Claude Code 了!
在特定项目中使用
# 进入你的项目目录
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),a[103]||(a[103]=t("div",{class:"rounded-xl bg-gradient-to-r from-blue-500 to-purple-600 p-4 text-center text-white sm:p-6"},[t("h5",{class:"mb-2 text-lg font-semibold sm:text-xl"},"🎉 恭喜你!"),t("p",{class:"mb-3 text-sm text-blue-100 sm:mb-4 sm:text-base"}," 你已经成功安装并配置了 Claude Code,现在可以开始享受 AI 编程助手带来的便利了。 "),t("p",{class:"text-xs text-blue-200 sm:text-sm"}," 如果在使用过程中遇到任何问题,可以查看官方文档或社区讨论获取帮助。 ")],-1))]))}},Va=u(Ra,[["__scopeId","data-v-cd06aa6c"]]);export{Va as default};