diff --git a/docs/BUILD_WINDOWS.md b/docs/BUILD_WINDOWS.md index 5bfb34f..60cbb88 100644 --- a/docs/BUILD_WINDOWS.md +++ b/docs/BUILD_WINDOWS.md @@ -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 --- -## 快速验证(无模型) +## 无模型启动 应用支持无模型启动,用于配置和测试: diff --git a/scripts/build-win.bat b/scripts/build-win.bat new file mode 100644 index 0000000..57792a1 --- /dev/null +++ b/scripts/build-win.bat @@ -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 diff --git a/scripts/build-win.sh b/scripts/build-win.sh new file mode 100644 index 0000000..53f5e72 --- /dev/null +++ b/scripts/build-win.sh @@ -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"