# Electron 镜像源快速参考

## 🚀 快速解决

### 已配置完成 ✅

项目已经配置了镜像源，直接打包即可：

```bash
npm run pack:win    # Windows
npm run pack:mac    # Mac
```

## 📝 配置位置

### 1. 项目根目录 `.npmrc`
```ini
registry=https://registry.npmmirror.com
electron_mirror=https://npmmirror.com/mirrors/electron/
electron_builder_binaries_mirror=https://npmmirror.com/mirrors/electron-builder-binaries/
```

### 2. electron 目录 `.npmrc`
```ini
electron_mirror=https://npmmirror.com/mirrors/electron/
electron_builder_binaries_mirror=https://npmmirror.com/mirrors/electron-builder-binaries/
registry=https://registry.npmmirror.com
```

### 3. electron/package.json
```json
{
  "scripts": {
    "pack:win": "cross-env ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/ ..."
  }
}
```

## 🔍 验证配置

```bash
npm config get electron_mirror
# 应该输出: https://npmmirror.com/mirrors/electron/
```

## 🛠️ 故障排查

### 打包失败？

```bash
# 1. 清除缓存
npm cache clean --force

# 2. 重新安装依赖
cd electron
rm -rf node_modules
npm install

# 3. 重新打包
npm run pack:win
```

### 检查环境变量

```bash
# Windows
echo %ELECTRON_MIRROR%

# Mac/Linux
echo $ELECTRON_MIRROR
```

## 📦 可用镜像源

| 镜像源 | 地址 |
|--------|------|
| 淘宝 | `https://npmmirror.com/mirrors/electron/` |
| 华为云 | `https://mirrors.huaweicloud.com/electron/` |
| 腾讯云 | `https://mirrors.cloud.tencent.com/npm/electron/` |

## 📚 相关文档

- [完整指南](./electron-mirror-setup.md)
- [Electron 官方文档](https://www.electronjs.org/docs)
