docs: 完善 Windows 构建指南和脚本

新增:
- scripts/build-win.bat: Windows 构建脚本
- scripts/build-win.sh: Linux/macOS 构建脚本

更新:
- BUILD_WINDOWS.md: 完善构建说明
  - 添加脚本使用说明
  - 简化手动打包步骤
  - 整理常见问题解答

注意:
- Windows ZIP 包较大 (132MB),建议在各平台自行构建
- 推荐使用提供的脚本进行构建

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
impressionyang 2026-05-20 16:29:15 +08:00
parent 8f78d6b11b
commit fc3ea6fa4e
3 changed files with 101 additions and 23 deletions

View File

@ -2,9 +2,7 @@
## 构建说明
**重要提示**: 由于网络和系统限制,强烈建议在 **Windows 系统上直接构建** Windows 版本。
在 Linux 系统上构建 Windows 版本需要 Wine 且网络状况要求较高,可能无法成功。
**重要提示**: 强烈建议在 **Windows 系统上直接构建** Windows 版本。
---
@ -19,20 +17,31 @@
# 克隆项目
git clone https://gitea.impressionyang.top/impressionyang/impress_asr_input.git
cd impress-asr-input
```
### 2. 安装依赖
```powershell
# 安装依赖
npm install
```
### 2. 放入模型文件
### 3. 放入模型文件(可选)
将 ONNX 模型放入 `models/` 目录:
- `sensevoice.onnx`
- `whisper.onnx`
- `paraformer.onnx`
### 3. 构建
### 4. 构建
**使用脚本构建**(推荐):
```powershell
# 双击运行或命令行执行
scripts\build-win.bat
```
**或手动构建**:
```powershell
# 构建 ZIP 包(无需签名)
npm run build:win:zip
@ -48,9 +57,7 @@ npm run build:win:dir
---
## 方法二:使用预编译的 Electron 手动打包
如果在 Linux 上需要快速打包,可以使用以下手动方式:
## 方法二:在 Linux/macOS 上手动打包
### 步骤 1: 编译 TypeScript
@ -60,10 +67,10 @@ npm run build
### 步骤 2: 下载 Electron
国内镜像下载 Electron:
从镜像下载 Electron:
```bash
# 访问 https://npmmirror.com/mirrors/electron/
# 下载 electron-v28.3.3-win32-x64.zip
curl -L -o /tmp/electron-win.zip \
https://npmmirror.com/mirrors/electron/28.3.3/electron-v28.3.3-win32-x64.zip
```
### 步骤 3: 打包
@ -72,15 +79,21 @@ npm run build
# 创建发布目录
mkdir -p release/impress-asr-input-win-x64
# 解压 Electron 到发布目录
unzip electron-v28.3.3-win32-x64.zip -d release/impress-asr-input-win-x64/
# 解压 Electron
unzip /tmp/electron-win.zip -d release/impress-asr-input-win-x64/
# 复制应用文件
cp -r dist/* release/impress-asr-input-win-x64/resources/app/
# 复制 node_modules
mkdir -p release/impress-asr-input-win-x64/resources/app/node_modules
cp -r node_modules/onnxruntime-web release/impress-asr-input-win-x64/resources/app/node_modules/
cp -r node_modules/clipboardy release/impress-asr-input-win-x64/resources/app/node_modules/
cp -r node_modules/commander release/impress-asr-input-win-x64/resources/app/node_modules/
# 压缩
cd release/
zip -r impress-asr-input-win-x64.zip impress-asr-input-win-x64/
zip -r Impress_ASR_Input-0.1.0-win-x64.zip impress-asr-input-win-x64/
```
---
@ -89,16 +102,26 @@ zip -r impress-asr-input-win-x64.zip impress-asr-input-win-x64/
```
release/
├── win-unpacked/ # 未打包版本(用于测试)
├── Impress_ASR_Input-0.1.0-win-x64.zip # ZIP 压缩包
├── win-unpacked/ # 未打包版本(用于测试)
│ ├── Impress ASR Input.exe
│ ├── resources/
│ └── ...
├── Impress ASR Input-0.1.0-win-x64.zip # ZIP 压缩包
│ └── resources/
└── Impress ASR Input-0.1.0-win-x64-setup.exe # NSIS 安装程序
```
---
## 快速打包脚本
项目提供了自动打包脚本:
| 系统 | 脚本 | 使用方式 |
|------|------|----------|
| Windows | `scripts/build-win.bat` | 双击运行 |
| Linux/macOS | `scripts/build-win.sh` | `bash scripts/build-win.sh` |
---
## 常见问题
### 1. Electron 下载失败
@ -107,17 +130,21 @@ release/
# 使用国内镜像
export ELECTRON_MIRROR="https://npmmirror.com/mirrors/electron/"
export npm_config_electron_mirror="https://npmmirror.com/mirrors/electron/"
# 或使用代理
export http_proxy="http://127.0.0.1:7897"
export https_proxy="http://127.0.0.1:7897"
```
### 2. winCodeSign 下载失败 / 签名错误
electron-builder 默认会尝试下载代码签名工具,在 Linux 上可能失败
electron-builder 默认会尝试下载代码签名工具。
解决方案:
1. 在 Windows 上构建(推荐)
2. 或手动打包(见方法二)
2. 使用手动打包方式(见方法二)
### 3. 缺少 wine64
### 3. 缺少 Wine
```bash
# Ubuntu/Debian 安装 Wine
@ -137,7 +164,7 @@ sudo apt-get install wine64
## 运行应用
解压后运行:
解压后双击运行:
```
Impress ASR Input.exe
```
@ -149,7 +176,7 @@ node dist/main.js start
---
## 快速验证(无模型)
## 无模型启动
应用支持无模型启动,用于配置和测试:

24
scripts/build-win.bat Normal file
View File

@ -0,0 +1,24 @@
@echo off
REM Impress ASR Input - Windows x64 打包脚本
REM 使用方式:在 Windows 系统上双击运行或在命令行执行
echo 🔧 开始构建 Windows x64 版本...
REM 检查 Node.js
node -v >nul 2>&1 || (echo 请先安装 Node.js 20+ && pause && exit /b 1)
REM 1. 安装依赖
echo 📦 安装依赖...
call npm install
REM 2. 编译 TypeScript
echo 📝 编译 TypeScript...
call npm run build
REM 3. 构建 ZIP 包
echo 📦 构建 ZIP 包...
call npm run build:win:zip
echo ✅ 构建完成!
echo 输出文件release\Impress ASR Input-0.1.0-win-x64.zip
pause

27
scripts/build-win.sh Normal file
View File

@ -0,0 +1,27 @@
#!/bin/bash
# Impress ASR Input - Windows x64 手动打包脚本
# 使用方式:在 Windows 系统上运行此脚本
# 设置代理(如果需要)
# export http_proxy="http://127.0.0.1:7897"
# export https_proxy="http://127.0.0.1:7897"
# 检查 Node.js
node -v || { echo "请先安装 Node.js 20+"; exit 1; }
echo "🔧 开始构建 Windows x64 版本..."
# 1. 安装依赖
echo "📦 安装依赖..."
npm install
# 2. 编译 TypeScript
echo "📝 编译 TypeScript..."
npm run build
# 3. 构建 ZIP 包
echo "📦 构建 ZIP 包..."
npm run build:win:zip
echo "✅ 构建完成!"
echo "输出文件release/Impress ASR Input-0.1.0-win-x64.zip"