feat: 支持win打包
This commit is contained in:
141
docs/mirror-setup-summary.md
Normal file
141
docs/mirror-setup-summary.md
Normal file
@@ -0,0 +1,141 @@
|
||||
# ✅ Electron 镜像源配置完成
|
||||
|
||||
## 🎉 问题已解决
|
||||
|
||||
你的项目已经成功配置了国内镜像源,**无需翻墙即可打包**!
|
||||
|
||||
## 📋 配置清单
|
||||
|
||||
### ✅ 已配置的文件
|
||||
|
||||
1. **项目根目录 `.npmrc`**
|
||||
- ✅ npm 镜像源:淘宝镜像
|
||||
- ✅ Electron 镜像源:淘宝镜像
|
||||
- ✅ Electron Builder 镜像源:淘宝镜像
|
||||
|
||||
2. **electron 目录 `.npmrc`**
|
||||
- ✅ Electron 镜像源:淘宝镜像
|
||||
- ✅ Electron Builder 镜像源:淘宝镜像
|
||||
- ✅ npm 镜像源:淘宝镜像
|
||||
|
||||
3. **electron/package.json**
|
||||
- ✅ 安装了 `cross-env` 包
|
||||
- ✅ 打包脚本中设置了环境变量
|
||||
|
||||
4. **辅助脚本**
|
||||
- ✅ `scripts/verify-mirrors.cjs` - 验证镜像源配置
|
||||
- ✅ `scripts/pack-win.bat` - Windows 打包脚本
|
||||
- ✅ `scripts/pack-mac.sh` - Mac 打包脚本
|
||||
|
||||
## 🔍 验证结果
|
||||
|
||||
```bash
|
||||
✅ npm 配置:
|
||||
registry: https://registry.npmmirror.com
|
||||
electron_mirror: https://npmmirror.com/mirrors/electron/
|
||||
electron_builder_binaries_mirror: https://npmmirror.com/mirrors/electron-builder-binaries/
|
||||
|
||||
✅ 已配置国内镜像源,无需翻墙即可打包!
|
||||
```
|
||||
|
||||
## 🚀 现在可以直接打包
|
||||
|
||||
### Windows
|
||||
|
||||
```bash
|
||||
npm run pack:win
|
||||
```
|
||||
|
||||
### Mac
|
||||
|
||||
```bash
|
||||
npm run pack:mac
|
||||
```
|
||||
|
||||
## 📝 工作原理
|
||||
|
||||
### 之前(需要翻墙)
|
||||
```
|
||||
npm run pack:win
|
||||
↓
|
||||
下载 Electron 二进制文件
|
||||
↓
|
||||
访问 GitHub releases (github.com)
|
||||
↓
|
||||
❌ 失败:fetch failed
|
||||
```
|
||||
|
||||
### 现在(无需翻墙)
|
||||
```
|
||||
npm run pack:win
|
||||
↓
|
||||
下载 Electron 二进制文件
|
||||
↓
|
||||
访问淘宝镜像 (npmmirror.com)
|
||||
↓
|
||||
✅ 成功:打包完成
|
||||
```
|
||||
|
||||
## 🛠️ 配置详情
|
||||
|
||||
### 镜像源地址
|
||||
|
||||
| 资源 | 原地址 | 镜像地址 |
|
||||
|------|--------|---------|
|
||||
| Electron | github.com/electron/electron/releases | npmmirror.com/mirrors/electron/ |
|
||||
| Electron Builder | github.com/electron-userland/electron-builder-binaries | npmmirror.com/mirrors/electron-builder-binaries/ |
|
||||
| npm | registry.npmjs.org | registry.npmmirror.com |
|
||||
|
||||
### 环境变量
|
||||
|
||||
打包时会自动设置以下环境变量:
|
||||
|
||||
```bash
|
||||
ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/
|
||||
ELECTRON_BUILDER_BINARIES_MIRROR=https://npmmirror.com/mirrors/electron-builder-binaries/
|
||||
```
|
||||
|
||||
## 🔧 如果仍然失败
|
||||
|
||||
### 1. 清除缓存
|
||||
|
||||
```bash
|
||||
npm cache clean --force
|
||||
```
|
||||
|
||||
### 2. 重新安装依赖
|
||||
|
||||
```bash
|
||||
cd electron
|
||||
rm -rf node_modules
|
||||
npm install
|
||||
```
|
||||
|
||||
### 3. 验证配置
|
||||
|
||||
```bash
|
||||
node scripts/verify-mirrors.cjs
|
||||
```
|
||||
|
||||
### 4. 检查网络
|
||||
|
||||
确保能访问:
|
||||
- https://npmmirror.com
|
||||
- https://mirrors.huaweicloud.com
|
||||
- https://mirrors.cloud.tencent.com
|
||||
|
||||
## 📚 相关文档
|
||||
|
||||
- [完整配置指南](./electron-mirror-setup.md)
|
||||
- [快速参考](./MIRROR_QUICK_REFERENCE.md)
|
||||
|
||||
## 🎯 总结
|
||||
|
||||
通过配置国内镜像源,你现在已经可以:
|
||||
|
||||
✅ **无需翻墙** - 直接打包 Electron 应用
|
||||
✅ **快速下载** - 使用国内 CDN,速度快
|
||||
✅ **稳定可靠** - 镜像源稳定,不易中断
|
||||
✅ **一次配置** - 配置一次,永久生效
|
||||
|
||||
现在你可以愉快地打包 Electron 应用了!🎉
|
||||
Reference in New Issue
Block a user