Files
macos-tools/network/QUICKSTART.md
brunoandClaude Sonnet 4.5 6b9f741db4 feat: 添加国内镜像加速配置工具集
新增功能:
- 一键配置脚本(setup-china-mirrors.sh)
  - 清理7890代理配置
  - 配置Pip使用中科大镜像
  - 配置NPM使用阿里云镜像
  - 配置Maven使用阿里云镜像
  - 配置Docker使用Harbor镜像代理

- 配置恢复脚本(restore-configs.sh)
  - 从备份恢复原始配置
  - 自动查找最新备份文件
  - 恢复前再次备份当前配置

- 配置验证脚本(verify-config.sh)
  - 验证所有镜像源配置
  - 测试网络连通性
  - 生成测试报告

- Makefile 简化操作
  - make setup: 配置镜像源
  - make verify: 验证配置
  - make restore: 恢复配置
  - make status: 查看状态

- 完整文档
  - README.md: 详细使用文档
  - QUICKSTART.md: 快速开始指南
  - .gitignore: 忽略备份文件

支持环境:
- macOS 系统
- OrbStack / Docker Desktop
- Python (pip)
- Node.js (npm)
- Java (maven)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
2025-12-19 10:18:44 +08:00

1.8 KiB

快速开始指南

一键配置(推荐)

cd ~/work/codes/tools/macos/network
./setup-china-mirrors.sh

执行后会自动配置:

  • ✅ 清理 7890 代理
  • ✅ Pip → 中科大镜像
  • ✅ NPM → 阿里云镜像
  • ✅ Maven → 阿里云镜像
  • ✅ Docker → Harbor 代理

使配置生效

# 重新加载 Shell
source ~/.zshrc

# 重启 Docker (OrbStack)
orb restart

验证配置

# 查看所有配置
pip config list                          # Pip
npm config get registry                  # NPM
cat ~/.m2/settings.xml                  # Maven
docker info | grep "Registry Mirrors"   # Docker

恢复原始配置

./restore-configs.sh

常用命令

临时禁用镜像(使用官方源)

# Pip
pip install --index-url https://pypi.org/simple package-name

# NPM
npm install --registry=https://registry.npmjs.org package-name

临时启用代理

export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890

# 使用完后取消
unset http_proxy https_proxy

查看 Docker 镜像拉取速度

# 测试从 Harbor 拉取
time docker pull hello-world

# 查看镜像来源
docker inspect hello-world | grep -i source

故障排除

Docker 镜像代理未生效

# 检查配置
cat ~/.orbstack/config/daemon.json

# 确认包含 registry-mirrors
# 重启 Docker
orb restart

NPM 安装仍然很慢

# 清理缓存
npm cache clean --force

# 重新设置镜像
npm config set registry https://registry.npmmirror.com

Pip 仍从官方源下载

# 检查配置
pip config list

# 确认 index-url 是否正确
# 如不正确,重新运行配置脚本
./setup-china-mirrors.sh

更多信息

详细文档请查看 README.md