@echo off REM ReTeamSpeak Windows 构建脚本 setlocal enabledelayedexpansion set SCRIPT_DIR=%~dp0 set PROJECT_DIR=%SCRIPT_DIR% set BUILD_DIR=%PROJECT_DIR%build REM 检查依赖 echo [INFO] 检查依赖... where rustc >nul 2>nul if %errorlevel% neq 0 ( echo [ERROR] Rust 未安装。请访问 https://rustup.rs 安装 Rust。 exit /b 1 ) where node >nul 2>nul if %errorlevel% neq 0 ( echo [ERROR] Node.js 未安装。请访问 https://nodejs.org 安装 Node.js。 exit /b 1 ) where npm >nul 2>nul if %errorlevel% neq 0 ( echo [ERROR] npm 未安装。 exit /b 1 ) echo [INFO] 依赖检查完成。 REM 解析命令 if "%1"=="" goto :help if "%1"=="all" goto :build_all if "%1"=="desktop" goto :build_desktop if "%1"=="frontend" goto :build_frontend if "%1"=="clean" goto :clean if "%1"=="help" goto :help goto :help :build_frontend echo [INFO] 构建前端... cd /d "%PROJECT_DIR%\src\tauri-app\frontend" call npm install call npm run build if %errorlevel% neq 0 ( echo [ERROR] 前端构建失败。 exit /b 1 ) echo [INFO] 前端构建完成。 goto :eof :build_desktop echo [INFO] 构建桌面应用... cd /d "%PROJECT_DIR%\src\tauri-app\src-tauri" cargo build --release if %errorlevel% neq 0 ( echo [ERROR] 桌面应用构建失败。 exit /b 1 ) echo [INFO] 桌面应用构建完成。 goto :eof :build_all echo [INFO] 构建所有平台... call :build_frontend call :build_desktop echo [INFO] 所有平台构建完成。 goto :eof :clean echo [INFO] 清理构建... if exist "%BUILD_DIR%" rmdir /s /q "%BUILD_DIR%" cd /d "%PROJECT_DIR%\src\tauri-app\src-tauri" cargo clean cd /d "%PROJECT_DIR%\src\tauri-app\frontend" if exist "node_modules" rmdir /s /q "node_modules" if exist "dist" rmdir /s /q "dist" echo [INFO] 清理完成。 goto :eof :help echo 用法: %0 [命令] echo. echo 命令: echo all 构建所有平台 echo desktop 构建桌面应用 echo frontend 构建前端 echo clean 清理构建 echo help 显示帮助 echo. echo 示例: echo %0 all # 构建所有平台 echo %0 desktop # 仅构建桌面应用 goto :eof