| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- @echo off
- chcp 65001 >nul 2>&1
- :: 切换到脚本所在目录
- cd /d "%~dp0"
- :: 启用 ANSI 转义序列支持 (Windows 10+)
- :: 设置 ESC 变量为真正的 ESC 字符 (ASCII 27)
- for /f %%a in ('echo prompt $E^| cmd') do set "ESC=%%a"
- :: ============================================
- :: Claude AI Installer Windows 构建脚本
- :: Build script for Windows using Tauri
- :: 此脚本作为 scripts/build.js 的简单入口
- :: ============================================
- :: 检查是否请求帮助
- if /i "%~1"=="--help" goto :show_help
- if /i "%~1"=="-h" goto :show_help
- echo.
- echo ========================================
- echo Claude AI Installer - Windows 构建
- echo 使用 Tauri 2.0
- echo ========================================
- echo.
- :: 检查 Rust 是否安装
- where rustc >nul 2>&1
- if errorlevel 1 (
- echo %ESC%[91mx%ESC%[0m 未找到 Rust,请先安装 Rust
- echo %ESC%[94mi%ESC%[0m 访问: https://rustup.rs/
- pause
- exit /b 1
- )
- :: 显示 Rust 版本
- for /f "tokens=*" %%i in ('rustc --version') do echo %ESC%[92m√%ESC%[0m Rust: %%i
- :: 检查 Node.js
- where node >nul 2>&1
- if errorlevel 1 (
- echo %ESC%[91mx%ESC%[0m 未找到 Node.js,请先安装 Node.js
- pause
- exit /b 1
- )
- :: 显示 Node.js 版本
- for /f "tokens=*" %%i in ('node --version') do echo %ESC%[92m√%ESC%[0m Node.js: %%i
- :: 设置 Tauri 签名密钥环境变量
- if exist ".keys\tauri-signing.key" (
- echo %ESC%[92m√%ESC%[0m 找到签名密钥
- for /f "usebackq delims=" %%i in (".keys\tauri-signing.key") do set "TAURI_SIGNING_PRIVATE_KEY=%%i"
- set "TAURI_SIGNING_PRIVATE_KEY_PASSWORD="
- ) else (
- echo %ESC%[93m!%ESC%[0m 未找到签名密钥 (.keys\tauri-signing.key)
- echo %ESC%[94mi%ESC%[0m 更新功能将不可用,构建将继续...
- )
- :: 检查 node_modules
- if not exist "node_modules" (
- echo.
- echo %ESC%[93m!%ESC%[0m 未找到 node_modules,正在安装依赖...
- call npm install
- if errorlevel 1 (
- echo %ESC%[91mx%ESC%[0m 安装依赖失败
- pause
- exit /b 1
- )
- )
- :: 解析参数并转换为 Node.js 脚本参数
- set "NODE_ARGS="
- :parse_args
- if "%~1"=="" goto :run_build
- if /i "%~1"=="--debug" set "NODE_ARGS=%NODE_ARGS% --debug" & shift & goto :parse_args
- if /i "%~1"=="-d" set "NODE_ARGS=%NODE_ARGS% --debug" & shift & goto :parse_args
- if /i "%~1"=="--skip-frontend" set "NODE_ARGS=%NODE_ARGS% --skip-frontend" & shift & goto :parse_args
- if /i "%~1"=="-s" set "NODE_ARGS=%NODE_ARGS% --skip-frontend" & shift & goto :parse_args
- shift
- goto :parse_args
- :run_build
- echo.
- echo %ESC%[96m^> 调用 Node.js 构建脚本...%ESC%[0m
- echo %ESC%[94mi%ESC%[0m 执行: node scripts/build.js %NODE_ARGS%
- echo.
- call node scripts/build.js %NODE_ARGS%
- if errorlevel 1 (
- echo.
- echo %ESC%[91mx%ESC%[0m 构建失败!
- echo.
- pause
- exit /b 1
- )
- echo.
- pause
- goto :eof
- :: ============================================
- :: 显示帮助信息
- :: ============================================
- :show_help
- echo.
- echo Claude AI Installer Windows 构建脚本 (Tauri)
- echo.
- echo 用法:
- echo build-win.bat [参数]
- echo.
- echo 参数:
- echo --debug, -d 以调试模式构建
- echo --skip-frontend, -s 跳过前端构建
- echo --help, -h 显示此帮助信息
- echo.
- echo 示例:
- echo build-win.bat 完整发布构建
- echo build-win.bat --debug 调试构建
- echo build-win.bat -s 跳过前端,仅构建 Tauri
- echo.
- echo 输出 (发布模式):
- echo src-tauri\target\release\bundle\nsis\*.exe (NSIS 安装程序)
- echo src-tauri\target\release\bundle\msi\*.msi (MSI 安装程序)
- echo src-tauri\target\release\claude-ai-installer.exe (可执行文件)
- echo.
- echo 输出 (调试模式):
- echo src-tauri\target\debug\claude-ai-installer.exe (调试版可执行文件)
- echo.
- echo 前置要求:
- echo - Rust (https://rustup.rs/)
- echo - Node.js (https://nodejs.org/)
- echo - Visual Studio Build Tools (Windows 平台)
- echo.
- echo 注意: 此脚本调用 scripts/build.js 执行实际构建
- echo.
- goto :eof
|