Files
pqs-9100_client/build/clean-and-build.bat
2025-10-16 20:19:22 +08:00

105 lines
2.5 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
chcp 65001 >nul
echo ========================================
echo 清理并重新打包
echo ========================================
echo.
echo [1/5] 结束所有相关进程...
echo 正在停止 NPQS9100...
taskkill /F /IM NPQS9100.exe 2>nul
echo 正在停止 MySQL...
taskkill /F /IM mysqld.exe 2>nul
timeout /t 2 /nobreak >nul
REM 验证 MySQL 是否真的停止了
tasklist | find /I "mysqld.exe" >nul 2>&1
if %errorlevel% equ 0 (
echo ! MySQL 进程还在运行,再次尝试...
taskkill /F /IM mysqld.exe 2>nul
timeout /t 2 /nobreak >nul
REM 再次验证
tasklist | find /I "mysqld.exe" >nul 2>&1
if %errorlevel% equ 0 (
echo ! MySQL 进程仍在运行,使用强制方法...
REM 找出所有 mysqld.exe 的 PID 并逐个杀死
for /f "tokens=2" %%a in ('tasklist ^| find /I "mysqld.exe"') do (
echo 强制结束 PID: %%a
taskkill /F /PID %%a 2>nul
)
timeout /t 2 /nobreak >nul
)
)
REM 最终验证
tasklist | find /I "mysqld.exe" >nul 2>&1
if %errorlevel% equ 0 (
echo ✗ 警告MySQL 进程可能仍在运行
echo 请手动运行 build\extraResources\mysql\kill-running-port.bat
pause
) else (
echo ✓ MySQL 已完全停止
)
echo 正在停止 Java...
taskkill /F /IM java.exe 2>nul
taskkill /F /IM javaw.exe 2>nul
echo ✓ 所有进程已结束
timeout /t 2 /nobreak >nul
echo.
echo [2/5] 删除 out 目录...
cd /d "%~dp0.."
if exist out (
rmdir /s /q out 2>nul
if exist out (
echo ✗ 删除失败,请手动删除 out 目录
pause
exit /b 1
) else (
echo ✓ out 目录已删除
)
) else (
echo ✓ out 目录不存在
)
echo.
echo [3/5] 构建前端代码...
call npm run build-frontend
if %errorlevel% neq 0 (
echo ✗ 前端构建失败
pause
exit /b 1
)
echo ✓ 前端代码构建完成
echo.
echo [4/5] 构建 electron 代码...
call npm run build-electron
if %errorlevel% neq 0 (
echo ✗ electron 构建失败
pause
exit /b 1
)
echo ✓ electron 代码构建完成
echo.
echo [5/5] 打包 Windows 版本(包含代码加密)...
call npm run build-w
if %errorlevel% neq 0 (
echo ✗ 打包失败
pause
exit /b 1
)
echo.
echo ========================================
echo ✓ 打包完成!
echo 输出目录: out\win-unpacked\
echo ========================================
echo.
pause