import{_ as c}from"./index-6fdnI-vy.js";import{r as u,c as g,x as n,z as e,L as y,O as a,Q as w,ac as h,aY as d,P as s,y as v,C as b}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 rounded-xl bg-gray-100 p-1 sm:gap-2 sm:p-2"},E=["onClick"],S={key:0,class:"tutorial-content"},T={class:"mb-6 sm:mb-10"},I={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"},N={class:"space-y-4"},G={class:"rounded-lg border border-orange-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"},_={class:"whitespace-nowrap text-gray-300"},L={class:"rounded-lg border border-orange-200 bg-white p-3 sm:p-4"},U={class:"mt-3 space-y-2"},D={class:"rounded bg-gray-100 p-2 text-sm"},H={class:"font-mono"},R={class:"mt-6 rounded-lg border border-blue-200 bg-blue-50 p-3 sm:p-4"},j={class:"mt-3 space-y-2"},B={class:"rounded bg-gray-100 p-2 font-mono text-sm"},K={class:"mt-8"},q={class:"space-y-4"},z={class:"rounded-lg border border-green-200 bg-white p-3 sm:p-4"},$={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},k={class:"whitespace-nowrap text-gray-300"},W={class:"rounded-lg border border-green-200 bg-white p-3 sm:p-4"},M={class:"space-y-2"},V={class:"rounded bg-gray-100 p-2 text-sm"},F={class:"font-mono"},Q={key:1,class:"tutorial-content"},Y={class:"mb-6 sm:mb-10"},J={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"},X={class:"space-y-4"},Z={class:"rounded-lg border border-orange-200 bg-white p-3 sm:p-4"},tt={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},et={class:"whitespace-nowrap text-gray-300"},st={class:"rounded-lg border border-orange-200 bg-white p-3 sm:p-4"},at={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"},dt={class:"whitespace-nowrap text-gray-300"},ot={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},rt={class:"whitespace-nowrap text-gray-300"},mt={class:"mt-8"},lt={class:"space-y-4"},it={class:"rounded-lg border border-green-200 bg-white p-3 sm:p-4"},xt={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},nt={class:"whitespace-nowrap text-gray-300"},vt={class:"rounded-lg border border-green-200 bg-white p-3 sm:p-4"},pt={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"},gt={class:"whitespace-nowrap text-gray-300"},bt={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},ft={class:"whitespace-nowrap text-gray-300"},ct={key:2,class:"tutorial-content"},ut={class:"mb-6 sm:mb-10"},yt={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"},wt={class:"space-y-4"},ht={class:"rounded-lg border border-orange-200 bg-white p-3 sm:p-4"},Ct={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},Ot={class:"whitespace-nowrap text-gray-300"},At={class:"rounded-lg border border-orange-200 bg-white p-3 sm:p-4"},Et={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"},St={class:"whitespace-nowrap text-gray-300"},Tt={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},It={class:"whitespace-nowrap text-gray-300"},Nt={class:"mt-8"},Gt={class:"space-y-4"},Pt={class:"rounded-lg border border-green-200 bg-white p-3 sm:p-4"},_t={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},Lt={class:"whitespace-nowrap text-gray-300"},Ut={class:"rounded-lg border border-green-200 bg-white p-3 sm:p-4"},Dt={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"},Ht={class:"whitespace-nowrap text-gray-300"},Rt={class:"overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"},jt={class:"whitespace-nowrap text-gray-300"},Bt={__name:"TutorialView",setup(Kt){const i=u("windows"),f=[{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"}],p=()=>{let l="";if(window.location.origin)l=window.location.origin;else{const t=window.location.protocol,o=window.location.hostname,x=window.location.port;l=t+"//"+o,x&&(t==="http:"&&x!=="80"||t==="https:"&&x!=="443")&&(l+=":"+x)}if(!l){const t=window.location.href,o=t.indexOf("/",8);if(o!==-1)l=t.substring(0,o);else return console.warn("无法获取完整的 origin,将使用相对路径"),""}return l},r=g(()=>p()+"/api"),m=g(()=>p()+"/gemini");return(l,t)=>(v(),n("div",C,[t[107]||(t[107]=e("div",{class:"mb-4 sm:mb-8"},[e("h3",{class:"mb-3 flex items-center text-xl font-bold text-gray-900 sm:mb-4 sm:text-2xl"},[e("i",{class:"fas fa-graduation-cap mr-2 text-blue-600 sm:mr-3"}),a(" Claude Code 使用教程 ")]),e("p",{class:"text-sm text-gray-600 sm:text-lg"}," 跟着这个教程,你可以轻松在自己的电脑上安装并使用 Claude Code。 ")],-1)),e("div",O,[e("div",A,[(v(),n(w,null,h(f,o=>e("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",i.value===o.key?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:bg-white/50 hover:text-gray-900"]),onClick:x=>i.value=o.key},[e("i",{class:b(o.icon)},null,2),a(" "+s(o.name),1)],10,E)),64))])]),i.value==="windows"?(v(),n("div",S,[t[35]||(t[35]=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 安装 Git Bash
Windows 环境下需要使用 Git Bash 安装Claude code。安装完成后,环境变量设置和使用 Claude Code 仍然在普通的 PowerShell 或 CMD 中进行。
下载并安装 Git for Windows
- 访问
https://git-scm.com/downloads/win - 点击 "Download for Windows" 下载安装包
- 运行下载的
.exe 安装文件 - 在安装过程中保持默认设置,直接点击 "Next" 完成安装
安装完成后
- • 在任意文件夹右键可以看到 "Git Bash Here" 选项
- • 也可以从开始菜单启动 "Git Bash"
- • 只需要在 Git Bash 中运行 npm install 命令
- • 后续的环境变量设置和使用都在 PowerShell/CMD 中
验证 Git Bash 安装
打开 Git Bash,输入以下命令验证:
如果显示 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 Code 已经成功安装了。
',3)),e("div",T,[t[34]||(t[34]=e("h4",{class:"mb-3 flex items-center text-lg font-semibold text-gray-800 sm:mb-4 sm:text-xl"},[e("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"},"4"),a(" 设置环境变量 ")],-1)),e("div",I,[t[12]||(t[12]=e("h5",{class:"mb-2 flex items-center text-base font-semibold text-gray-800 sm:mb-3 sm:text-lg"},[e("i",{class:"fas fa-cog mr-2 text-orange-600"}),a(" 配置 Claude Code 环境变量 ")],-1)),t[13]||(t[13]=e("p",{class:"mb-3 text-sm text-gray-700 sm:mb-4 sm:text-base"}," 为了让 Claude Code 连接到你的中转服务,需要设置两个环境变量: ",-1)),e("div",N,[e("div",G,[t[1]||(t[1]=e("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"}," 方法一:PowerShell 临时设置(推荐) ",-1)),t[2]||(t[2]=e("p",{class:"mb-3 text-sm text-gray-600"},"在 PowerShell 中运行以下命令:",-1)),e("div",P,[e("div",_,' $env:ANTHROPIC_BASE_URL = "'+s(r.value)+'" ',1),t[0]||(t[0]=e("div",{class:"whitespace-nowrap text-gray-300"},' $env:ANTHROPIC_AUTH_TOKEN = "你的API密钥" ',-1))]),t[3]||(t[3]=e("p",{class:"mt-2 text-xs text-yellow-700"},' 💡 记得将 "你的API密钥" 替换为在上方 "API Keys" 标签页中创建的实际密钥。 ',-1))]),e("div",L,[t[10]||(t[10]=e("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"}," 方法二:系统环境变量(永久设置) ",-1)),t[11]||(t[11]=e("ol",{class:"list-inside list-decimal space-y-1 text-xs text-gray-600 sm:text-sm"},[e("li",null,'右键"此电脑" → "属性" → "高级系统设置"'),e("li",null,'点击"环境变量"按钮'),e("li",null,'在"用户变量"或"系统变量"中点击"新建"'),e("li",null,"添加以下两个变量:")],-1)),e("div",U,[e("div",D,[t[4]||(t[4]=e("strong",null,"变量名:",-1)),t[5]||(t[5]=a(" ANTHROPIC_BASE_URL",-1)),t[6]||(t[6]=e("br",null,null,-1)),t[7]||(t[7]=e("strong",null,"变量值:",-1)),t[8]||(t[8]=a()),e("span",H,s(r.value),1)]),t[9]||(t[9]=e("div",{class:"rounded bg-gray-100 p-2 text-sm"},[e("strong",null,"变量名:"),a(" ANTHROPIC_AUTH_TOKEN"),e("br"),e("strong",null,"变量值:"),a(),e("span",{class:"font-mono"},"你的API密钥")],-1))])])])]),e("div",R,[t[17]||(t[17]=d('验证环境变量设置
设置完环境变量后,可以通过以下命令验证是否设置成功:
在 PowerShell 中验证:
echo $env:ANTHROPIC_BASE_URL
echo $env:ANTHROPIC_AUTH_TOKEN
在 CMD 中验证:
echo %ANTHROPIC_BASE_URL%
echo %ANTHROPIC_AUTH_TOKEN%
',3)),e("div",j,[t[15]||(t[15]=e("p",{class:"text-sm text-blue-700"},[e("strong",null,"预期输出示例:")],-1)),e("div",B,[e("div",null,s(r.value),1),t[14]||(t[14]=e("div",null,"cr_xxxxxxxxxxxxxxxxxx",-1))]),t[16]||(t[16]=e("p",{class:"text-xs text-blue-700"}," 💡 如果输出为空或显示变量名本身,说明环境变量设置失败,请重新设置。 ",-1))])]),e("div",K,[t[32]||(t[32]=e("h5",{class:"mb-2 flex items-center text-base font-semibold text-gray-800 sm:mb-3 sm:text-lg"},[e("i",{class:"fas fa-robot mr-2 text-green-600"}),a(" 配置 Gemini CLI 环境变量 ")],-1)),t[33]||(t[33]=e("p",{class:"mb-3 text-sm text-gray-700 sm:mb-4 sm:text-base"}," 如果你使用 Gemini CLI,需要设置以下环境变量: ",-1)),e("div",q,[e("div",z,[t[20]||(t[20]=e("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"}," PowerShell 设置方法 ",-1)),t[21]||(t[21]=e("p",{class:"mb-3 text-sm text-gray-600"},"在 PowerShell 中运行以下命令:",-1)),e("div",$,[e("div",k,' $env:CODE_ASSIST_ENDPOINT = "'+s(m.value)+'" ',1),t[18]||(t[18]=e("div",{class:"whitespace-nowrap text-gray-300"},' $env:GOOGLE_CLOUD_ACCESS_TOKEN = "你的API密钥" ',-1)),t[19]||(t[19]=e("div",{class:"whitespace-nowrap text-gray-300"},' $env:GOOGLE_GENAI_USE_GCA = "true" ',-1))]),t[22]||(t[22]=e("p",{class:"mt-2 text-xs text-yellow-700"}," 💡 使用与 Claude Code 相同的 API 密钥即可。 ",-1))]),e("div",W,[t[29]||(t[29]=e("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"}," 系统环境变量(永久设置) ",-1)),t[30]||(t[30]=e("p",{class:"mb-3 text-sm text-gray-600"},"在系统环境变量中添加:",-1)),e("div",M,[e("div",V,[t[23]||(t[23]=e("strong",null,"变量名:",-1)),t[24]||(t[24]=a(" CODE_ASSIST_ENDPOINT",-1)),t[25]||(t[25]=e("br",null,null,-1)),t[26]||(t[26]=e("strong",null,"变量值:",-1)),t[27]||(t[27]=a()),e("span",F,s(m.value),1)]),t[28]||(t[28]=d('变量名: GOOGLE_CLOUD_ACCESS_TOKEN
变量值: 你的API密钥
变量名: GOOGLE_GENAI_USE_GCA
变量值: true
',2))])]),t[31]||(t[31]=d('验证 Gemini CLI 环境变量
在 PowerShell 中验证:
echo $env:CODE_ASSIST_ENDPOINT
echo $env:GOOGLE_CLOUD_ACCESS_TOKEN
echo $env:GOOGLE_GENAI_USE_GCA
',1))])])]),t[36]||(t[36]=d('5 开始使用 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))])):i.value==="macos"?(v(),n("div",Q,[t[70]||(t[70]=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)),e("div",Y,[t[69]||(t[69]=e("h4",{class:"mb-3 flex items-center text-lg font-semibold text-gray-800 sm:mb-4 sm:text-xl"},[e("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"),a(" 设置环境变量 ")],-1)),e("div",J,[t[49]||(t[49]=e("h5",{class:"mb-2 flex items-center text-base font-semibold text-gray-800 sm:mb-3 sm:text-lg"},[e("i",{class:"fas fa-cog mr-2 text-orange-600"}),a(" 配置 Claude Code 环境变量 ")],-1)),t[50]||(t[50]=e("p",{class:"mb-3 text-sm text-gray-700 sm:mb-4 sm:text-base"}," 为了让 Claude Code 连接到你的中转服务,需要设置两个环境变量: ",-1)),e("div",X,[e("div",Z,[t[38]||(t[38]=e("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"}," 方法一:临时设置(当前会话) ",-1)),t[39]||(t[39]=e("p",{class:"mb-3 text-sm text-gray-600"},"在 Terminal 中运行以下命令:",-1)),e("div",tt,[e("div",et,' export ANTHROPIC_BASE_URL="'+s(r.value)+'" ',1),t[37]||(t[37]=e("div",{class:"whitespace-nowrap text-gray-300"},' export ANTHROPIC_AUTH_TOKEN="你的API密钥" ',-1))]),t[40]||(t[40]=e("p",{class:"mt-2 text-xs text-yellow-700"},' 💡 记得将 "你的API密钥" 替换为在上方 "API Keys" 标签页中创建的实际密钥。 ',-1))]),e("div",st,[t[47]||(t[47]=e("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"},"方法二:永久设置",-1)),t[48]||(t[48]=e("p",{class:"mb-3 text-sm text-gray-600"}," 编辑你的 shell 配置文件(根据你使用的 shell): ",-1)),e("div",at,[t[41]||(t[41]=e("div",{class:"mb-2"},"# 对于 zsh (默认)",-1)),e("div",dt,` echo 'export ANTHROPIC_BASE_URL="`+s(r.value)+`"' >> ~/.zshrc `,1),t[42]||(t[42]=e("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export ANTHROPIC_AUTH_TOKEN="你的API密钥"' >> ~/.zshrc `,-1)),t[43]||(t[43]=e("div",{class:"whitespace-nowrap text-gray-300"},"source ~/.zshrc",-1))]),e("div",ot,[t[44]||(t[44]=e("div",{class:"mb-2"},"# 对于 bash",-1)),e("div",rt,` echo 'export ANTHROPIC_BASE_URL="`+s(r.value)+`"' >> ~/.bash_profile `,1),t[45]||(t[45]=e("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export ANTHROPIC_AUTH_TOKEN="你的API密钥"' >> ~/.bash_profile `,-1)),t[46]||(t[46]=e("div",{class:"whitespace-nowrap text-gray-300"},"source ~/.bash_profile",-1))])])])]),e("div",mt,[t[67]||(t[67]=e("h5",{class:"mb-2 flex items-center text-base font-semibold text-gray-800 sm:mb-3 sm:text-lg"},[e("i",{class:"fas fa-robot mr-2 text-green-600"}),a(" 配置 Gemini CLI 环境变量 ")],-1)),t[68]||(t[68]=e("p",{class:"mb-3 text-sm text-gray-700 sm:mb-4 sm:text-base"}," 如果你使用 Gemini CLI,需要设置以下环境变量: ",-1)),e("div",lt,[e("div",it,[t[53]||(t[53]=e("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"},"Terminal 设置方法",-1)),t[54]||(t[54]=e("p",{class:"mb-3 text-sm text-gray-600"},"在 Terminal 中运行以下命令:",-1)),e("div",xt,[e("div",nt,' export CODE_ASSIST_ENDPOINT="'+s(m.value)+'" ',1),t[51]||(t[51]=e("div",{class:"whitespace-nowrap text-gray-300"},' export GOOGLE_CLOUD_ACCESS_TOKEN="你的API密钥" ',-1)),t[52]||(t[52]=e("div",{class:"whitespace-nowrap text-gray-300"},' export GOOGLE_GENAI_USE_GCA="true" ',-1))]),t[55]||(t[55]=e("p",{class:"mt-2 text-xs text-yellow-700"}," 💡 使用与 Claude Code 相同的 API 密钥即可。 ",-1))]),e("div",vt,[t[64]||(t[64]=e("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"},"永久设置方法",-1)),t[65]||(t[65]=e("p",{class:"mb-3 text-sm text-gray-600"},"添加到你的 shell 配置文件:",-1)),e("div",pt,[t[56]||(t[56]=e("div",{class:"mb-2"},"# 对于 zsh (默认)",-1)),e("div",gt,` echo 'export CODE_ASSIST_ENDPOINT="`+s(m.value)+`"' >> ~/.zshrc `,1),t[57]||(t[57]=e("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export GOOGLE_CLOUD_ACCESS_TOKEN="你的API密钥"' >> ~/.zshrc `,-1)),t[58]||(t[58]=e("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export GOOGLE_GENAI_USE_GCA="true"' >> ~/.zshrc `,-1)),t[59]||(t[59]=e("div",{class:"whitespace-nowrap text-gray-300"},"source ~/.zshrc",-1))]),e("div",bt,[t[60]||(t[60]=e("div",{class:"mb-2"},"# 对于 bash",-1)),e("div",ft,` echo 'export CODE_ASSIST_ENDPOINT="`+s(m.value)+`"' >> ~/.bash_profile `,1),t[61]||(t[61]=e("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export GOOGLE_CLOUD_ACCESS_TOKEN="你的API密钥"' >> ~/.bash_profile `,-1)),t[62]||(t[62]=e("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export GOOGLE_GENAI_USE_GCA="true"' >> ~/.bash_profile `,-1)),t[63]||(t[63]=e("div",{class:"whitespace-nowrap text-gray-300"},"source ~/.bash_profile",-1))])]),t[66]||(t[66]=d('验证 Gemini CLI 环境变量
在 Terminal 中验证:
echo $CODE_ASSIST_ENDPOINT
echo $GOOGLE_CLOUD_ACCESS_TOKEN
echo $GOOGLE_GENAI_USE_GCA
',1))])])]),t[71]||(t[71]=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))])):i.value==="linux"?(v(),n("div",ct,[t[105]||(t[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 Code 已经成功安装了。
',2)),e("div",ut,[t[104]||(t[104]=e("h4",{class:"mb-3 flex items-center text-lg font-semibold text-gray-800 sm:mb-4 sm:text-xl"},[e("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"),a(" 设置环境变量 ")],-1)),e("div",yt,[t[84]||(t[84]=e("h5",{class:"mb-2 flex items-center text-base font-semibold text-gray-800 sm:mb-3 sm:text-lg"},[e("i",{class:"fas fa-cog mr-2 text-orange-600"}),a(" 配置 Claude Code 环境变量 ")],-1)),t[85]||(t[85]=e("p",{class:"mb-3 text-sm text-gray-700 sm:mb-4 sm:text-base"}," 为了让 Claude Code 连接到你的中转服务,需要设置两个环境变量: ",-1)),e("div",wt,[e("div",ht,[t[73]||(t[73]=e("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"}," 方法一:临时设置(当前会话) ",-1)),t[74]||(t[74]=e("p",{class:"mb-3 text-sm text-gray-600"},"在终端中运行以下命令:",-1)),e("div",Ct,[e("div",Ot,' export ANTHROPIC_BASE_URL="'+s(r.value)+'" ',1),t[72]||(t[72]=e("div",{class:"whitespace-nowrap text-gray-300"},' export ANTHROPIC_AUTH_TOKEN="你的API密钥" ',-1))]),t[75]||(t[75]=e("p",{class:"mt-2 text-xs text-yellow-700"},' 💡 记得将 "你的API密钥" 替换为在上方 "API Keys" 标签页中创建的实际密钥。 ',-1))]),e("div",At,[t[82]||(t[82]=e("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"},"方法二:永久设置",-1)),t[83]||(t[83]=e("p",{class:"mb-3 text-sm text-gray-600"},"编辑你的 shell 配置文件:",-1)),e("div",Et,[t[76]||(t[76]=e("div",{class:"mb-2"},"# 对于 bash (默认)",-1)),e("div",St,` echo 'export ANTHROPIC_BASE_URL="`+s(r.value)+`"' >> ~/.bashrc `,1),t[77]||(t[77]=e("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export ANTHROPIC_AUTH_TOKEN="你的API密钥"' >> ~/.bashrc `,-1)),t[78]||(t[78]=e("div",{class:"whitespace-nowrap text-gray-300"},"source ~/.bashrc",-1))]),e("div",Tt,[t[79]||(t[79]=e("div",{class:"mb-2"},"# 对于 zsh",-1)),e("div",It,` echo 'export ANTHROPIC_BASE_URL="`+s(r.value)+`"' >> ~/.zshrc `,1),t[80]||(t[80]=e("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export ANTHROPIC_AUTH_TOKEN="你的API密钥"' >> ~/.zshrc `,-1)),t[81]||(t[81]=e("div",{class:"whitespace-nowrap text-gray-300"},"source ~/.zshrc",-1))])])])]),e("div",Nt,[t[102]||(t[102]=e("h5",{class:"mb-2 flex items-center text-base font-semibold text-gray-800 sm:mb-3 sm:text-lg"},[e("i",{class:"fas fa-robot mr-2 text-green-600"}),a(" 配置 Gemini CLI 环境变量 ")],-1)),t[103]||(t[103]=e("p",{class:"mb-3 text-sm text-gray-700 sm:mb-4 sm:text-base"}," 如果你使用 Gemini CLI,需要设置以下环境变量: ",-1)),e("div",Gt,[e("div",Pt,[t[88]||(t[88]=e("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"},"终端设置方法",-1)),t[89]||(t[89]=e("p",{class:"mb-3 text-sm text-gray-600"},"在终端中运行以下命令:",-1)),e("div",_t,[e("div",Lt,' export CODE_ASSIST_ENDPOINT="'+s(m.value)+'" ',1),t[86]||(t[86]=e("div",{class:"whitespace-nowrap text-gray-300"},' export GOOGLE_CLOUD_ACCESS_TOKEN="你的API密钥" ',-1)),t[87]||(t[87]=e("div",{class:"whitespace-nowrap text-gray-300"},' export GOOGLE_GENAI_USE_GCA="true" ',-1))]),t[90]||(t[90]=e("p",{class:"mt-2 text-xs text-yellow-700"}," 💡 使用与 Claude Code 相同的 API 密钥即可。 ",-1))]),e("div",Ut,[t[99]||(t[99]=e("h6",{class:"mb-2 text-sm font-medium text-gray-800 sm:text-base"},"永久设置方法",-1)),t[100]||(t[100]=e("p",{class:"mb-3 text-sm text-gray-600"},"添加到你的 shell 配置文件:",-1)),e("div",Dt,[t[91]||(t[91]=e("div",{class:"mb-2"},"# 对于 bash (默认)",-1)),e("div",Ht,` echo 'export CODE_ASSIST_ENDPOINT="`+s(m.value)+`"' >> ~/.bashrc `,1),t[92]||(t[92]=e("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export GOOGLE_CLOUD_ACCESS_TOKEN="你的API密钥"' >> ~/.bashrc `,-1)),t[93]||(t[93]=e("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export GOOGLE_GENAI_USE_GCA="true"' >> ~/.bashrc `,-1)),t[94]||(t[94]=e("div",{class:"whitespace-nowrap text-gray-300"},"source ~/.bashrc",-1))]),e("div",Rt,[t[95]||(t[95]=e("div",{class:"mb-2"},"# 对于 zsh",-1)),e("div",jt,` echo 'export CODE_ASSIST_ENDPOINT="`+s(m.value)+`"' >> ~/.zshrc `,1),t[96]||(t[96]=e("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export GOOGLE_CLOUD_ACCESS_TOKEN="你的API密钥"' >> ~/.zshrc `,-1)),t[97]||(t[97]=e("div",{class:"whitespace-nowrap text-gray-300"},` echo 'export GOOGLE_GENAI_USE_GCA="true"' >> ~/.zshrc `,-1)),t[98]||(t[98]=e("div",{class:"whitespace-nowrap text-gray-300"},"source ~/.zshrc",-1))])]),t[101]||(t[101]=d('验证 Gemini CLI 环境变量
在终端中验证:
echo $CODE_ASSIST_ENDPOINT
echo $GOOGLE_CLOUD_ACCESS_TOKEN
echo $GOOGLE_GENAI_USE_GCA
',1))])])]),t[106]||(t[106]=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))])):y("",!0),t[108]||(t[108]=e("div",{class:"rounded-xl bg-gradient-to-r from-blue-500 to-purple-600 p-4 text-center text-white sm:p-6"},[e("h5",{class:"mb-2 text-lg font-semibold sm:text-xl"},"🎉 恭喜你!"),e("p",{class:"mb-3 text-sm text-blue-100 sm:mb-4 sm:text-base"}," 你已经成功安装并配置了 Claude Code,现在可以开始享受 AI 编程助手带来的便利了。 "),e("p",{class:"text-xs text-blue-200 sm:text-sm"}," 如果在使用过程中遇到任何问题,可以查看官方文档或社区讨论获取帮助。 ")],-1))]))}},Wt=c(Bt,[["__scopeId","data-v-8f349e24"]]);export{Wt as default};