docs: 更新 Windows 构建指南,添加手动打包方法

修改:
- BUILD_WINDOWS.md: 更新构建说明
  - 强调推荐在 Windows 上构建
  - 添加手动打包步骤
  - 整理常见问题解答
- package.json: 添加 forceCodeSigning 配置

原因:
- Linux 下 electron-builder 需要 Wine 且网络要求高
- 手动打包提供更灵活的替代方案

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
impressionyang 2026-05-20 16:22:09 +08:00
parent 1e06cbc2b8
commit 8f78d6b11b
2 changed files with 78 additions and 39 deletions

View File

@ -2,18 +2,22 @@
## 构建说明
由于网络问题,在 Linux 环境下构建 Windows 版本可能需要多次尝试。建议在 Windows 系统上直接构建,或使用以下方法。
**重要提示**: 由于网络和系统限制,强烈建议在 **Windows 系统上直接构建** Windows 版本。
在 Linux 系统上构建 Windows 版本需要 Wine 且网络状况要求较高,可能无法成功。
---
## 方法一:在 Windows 上构建(推荐)
### 1. 环境准备
```powerslhell
```powershell
# 安装 Node.js 20+
# 从 https://nodejs.org 下载安装
# 克隆项目
git clone <repository-url>
git clone https://gitea.impressionyang.top/impressionyang/impress_asr_input.git
cd impress-asr-input
# 安装依赖
@ -35,23 +39,52 @@ npm run build:win:zip
# 构建 NSIS 安装程序
npm run build:win
# 构建解压目录版本(用于测试)
npm run build:win:dir
```
输出目录:`release/`
## 方法二:在 Linux 上构建(需要良好网络)
---
## 方法二:使用预编译的 Electron 手动打包
如果在 Linux 上需要快速打包,可以使用以下手动方式:
### 步骤 1: 编译 TypeScript
```bash
# 设置 Electron 镜像
export ELECTRON_MIRROR="https://npmmirror.com/mirrors/electron/"
# 构建解压目录版本(用于测试)
npm run build:win:dir
# 构建 ZIP 包
npm run build:win:zip
npm run build
```
### 步骤 2: 下载 Electron
从国内镜像下载 Electron:
```bash
# 访问 https://npmmirror.com/mirrors/electron/
# 下载 electron-v28.3.3-win32-x64.zip
```
### 步骤 3: 打包
```bash
# 创建发布目录
mkdir -p release/impress-asr-input-win-x64
# 解压 Electron 到发布目录
unzip electron-v28.3.3-win32-x64.zip -d release/impress-asr-input-win-x64/
# 复制应用文件
cp -r dist/* release/impress-asr-input-win-x64/resources/app/
# 压缩
cd release/
zip -r impress-asr-input-win-x64.zip impress-asr-input-win-x64/
```
---
## 构建输出
```
@ -64,6 +97,8 @@ release/
└── Impress ASR Input-0.1.0-win-x64-setup.exe # NSIS 安装程序
```
---
## 常见问题
### 1. Electron 下载失败
@ -74,40 +109,31 @@ export ELECTRON_MIRROR="https://npmmirror.com/mirrors/electron/"
export npm_config_electron_mirror="https://npmmirror.com/mirrors/electron/"
```
### 2. winCodeSign 下载失败
### 2. winCodeSign 下载失败 / 签名错误
这是 electron-builder 依赖的签名工具,可以:
- 添加 `"sign": null``package.json``build` 字段禁用签名
- 或手动下载https://github.com/electron-userland/electron-builder-binaries/releases
electron-builder 默认会尝试下载代码签名工具,在 Linux 上可能失败。
### 3. 图标文件缺失
解决方案:
1. 在 Windows 上构建(推荐)
2. 或手动打包(见方法二)
### 3. 缺少 wine64
```bash
# Ubuntu/Debian 安装 Wine
sudo apt-get install wine64
```
但 Wine 配置复杂,仍建议在 Windows 上构建。
### 4. 图标文件缺失
构建时会使用默认图标,如需自定义:
1. 准备 `icon.ico` (256x256)
2. 放入 `build/` 目录
3. 在 `package.json` 中添加 `"icon": "build/icon.ico"`
3. 在 `package.json` `build.win` 中添加 `"icon": "build/icon.ico"`
## 手动分发(无打包工具)
如果 electron-builder 无法使用,可以手动创建分发包:
```bash
# 1. 编译 TypeScript
npm run build
# 2. 复制 Electron 和资源文件
cp -r dist/ release/my-app/
cp -r node_modules/ release/my-app/node_modules/
cp -r src/ui/ release/my-app/src/ui/
cp -r models/ release/my-app/models/
# 3. 下载 Electron 并放入
# https://npmmirror.com/mirrors/electron/
# 4. 压缩
cd release/
zip -r impress-asr-input-win-x64.zip my-app/
```
---
## 运行应用
@ -120,3 +146,15 @@ Impress ASR Input.exe
```
node dist/main.js start
```
---
## 快速验证(无模型)
应用支持无模型启动,用于配置和测试:
```bash
npm start -- start
```
会显示模型下载指引和配置说明。

View File

@ -58,6 +58,7 @@
"win": {
"target": "zip",
"requestedExecutionLevel": "asInvoker",
"forceCodeSigning": false,
"artifactName": "${productName}-${version}-win-${arch}.${ext}"
},
"mac": {