docs: 更新 API 分组说明、客户端推荐及重启终端提醒
All checks were successful
Deploy to Cloudflare Pages / deploy (push) Successful in 1m4s
All checks were successful
Deploy to Cloudflare Pages / deploy (push) Successful in 1m4s
- 文档新增 ccmax/cc2api 分组说明:cc2api 推荐优先使用(Claude 系列,无客户端限制),ccmax 仅限 Claude Code - 推荐 OpenCode、OpenClaw 作为 cc2api 客户端,GPT 模型推荐 v1/responses 端点 - Cherry Studio 兼容性说明更新:支持所有模型,仅 ccmax 分组 Claude 模型不可用 - 所有脚本重启终端提示改为中文 - 三个工具文档页及快速开始页添加重启终端 warning 框
This commit is contained in:
@@ -18,7 +18,6 @@ DEFAULT_BASE_URL="https://api2.xcodecli.com"
|
||||
CLAUDE_CONFIG_DIR="$HOME/.claude"
|
||||
CLAUDE_SETTINGS_FILE="$CLAUDE_CONFIG_DIR/settings.json"
|
||||
TOOL_COMMAND="claude"
|
||||
TOOL_PACKAGE="@anthropic-ai/claude-code"
|
||||
TOOL_NAME="Claude Code"
|
||||
|
||||
# ========== Shell 环境变量配置 ==========
|
||||
@@ -83,117 +82,14 @@ print_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# ========== Node.js 环境检测 ==========
|
||||
get_node_version() {
|
||||
if command -v node >/dev/null 2>&1; then
|
||||
node --version 2>/dev/null | sed 's/v//'
|
||||
fi
|
||||
}
|
||||
|
||||
get_node_major_version() {
|
||||
local version
|
||||
version=$(get_node_version)
|
||||
if [ -n "$version" ]; then
|
||||
echo "$version" | cut -d. -f1
|
||||
fi
|
||||
}
|
||||
|
||||
install_fnm() {
|
||||
echo ""
|
||||
print_info "正在安装 fnm (Fast Node Manager)..."
|
||||
|
||||
if curl -fsSL https://fnm.vercel.app/install | bash; then
|
||||
# 加载 fnm 环境
|
||||
export PATH="$HOME/.local/share/fnm:$PATH"
|
||||
if [ -f "$HOME/.local/share/fnm/fnm" ]; then
|
||||
eval "$(~/.local/share/fnm/fnm env)"
|
||||
fi
|
||||
|
||||
if command -v fnm >/dev/null 2>&1; then
|
||||
print_success "fnm 安装成功!"
|
||||
return 0
|
||||
else
|
||||
print_warning "fnm 可能已安装,但需要重新打开终端才能生效"
|
||||
print_info "请重新打开终端后再运行此脚本"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
print_error "fnm 安装失败"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_node_with_fnm() {
|
||||
print_info "使用 fnm 安装 Node.js 24.x..."
|
||||
|
||||
if fnm install 24 && fnm use 24 && fnm default 24; then
|
||||
# 刷新 PATH
|
||||
eval "$(fnm env)"
|
||||
|
||||
if command -v node >/dev/null 2>&1; then
|
||||
local version
|
||||
version=$(get_node_version)
|
||||
print_success "Node.js v$version 安装成功!"
|
||||
return 0
|
||||
else
|
||||
print_warning "Node.js 可能已安装,但需要重新打开终端才能生效"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
print_error "Node.js 安装失败"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_node_environment() {
|
||||
local version major
|
||||
|
||||
version=$(get_node_version)
|
||||
if [ -n "$version" ]; then
|
||||
major=$(get_node_major_version)
|
||||
print_info "检测到 Node.js v$version"
|
||||
|
||||
if [ "$major" -lt 20 ]; then
|
||||
print_warning "Node.js 版本过低 (需要 >= 20.x)"
|
||||
|
||||
read -p "是否使用 fnm 安装 Node.js 24.x? (Y/n): " -r
|
||||
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||
print_error "Node.js 版本不满足要求,请手动升级后重试"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! command -v fnm >/dev/null 2>&1; then
|
||||
install_fnm || return 1
|
||||
fi
|
||||
|
||||
install_node_with_fnm || return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
fi
|
||||
|
||||
print_warning "未检测到 Node.js"
|
||||
print_info "将使用 fnm 安装 Node.js 24.x"
|
||||
|
||||
read -p "是否继续? (Y/n): " -r
|
||||
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! command -v fnm >/dev/null 2>&1; then
|
||||
install_fnm || return 1
|
||||
fi
|
||||
|
||||
install_node_with_fnm || return 1
|
||||
}
|
||||
|
||||
install_tool() {
|
||||
ensure_node_environment || return 1
|
||||
print_info "使用官方安装脚本安装 $TOOL_NAME..."
|
||||
echo " 执行: curl -fsSL https://claude.ai/install.sh | bash"
|
||||
|
||||
print_info "使用 npm 安装 $TOOL_NAME..."
|
||||
echo " 执行: npm install -g $TOOL_PACKAGE"
|
||||
if bash -c 'set -o pipefail; curl -fsSL https://claude.ai/install.sh | bash'; then
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
hash -r 2>/dev/null || true
|
||||
|
||||
if npm install -g "$TOOL_PACKAGE"; then
|
||||
if command -v "$TOOL_COMMAND" >/dev/null 2>&1; then
|
||||
print_success "$TOOL_NAME 安装成功!"
|
||||
return 0
|
||||
@@ -565,7 +461,7 @@ EOF
|
||||
fi
|
||||
|
||||
echo
|
||||
print_warning "Please restart your terminal or run 'source $(get_shell_rc)' for environment variables to take effect."
|
||||
print_warning "⚠️ 请重启终端(或执行 'source $(get_shell_rc)')使环境变量生效,然后再启动 Claude Code"
|
||||
else
|
||||
print_error "Failed to create Claude Code settings"
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user