@echo off setlocal EnableExtensions set "PATH=%SystemRoot%\System32;%PATH%" cd /d "%~dp0" if exist "%SystemRoot%\System32\chcp.com" ( "%SystemRoot%\System32\chcp.com" 65001 >nul 2>&1 ) echo ======================================== echo 打包 exe(方案 C · 免 Python 分发) echo ======================================== echo. set "PY=" if exist ".venv\Scripts\python.exe" set "PY=.venv\Scripts\python.exe" if not defined PY if exist "..\backend\.venv\Scripts\python.exe" set "PY=..\backend\.venv\Scripts\python.exe" if not defined PY ( where python >nul 2>&1 && set "PY=python" ) if not defined PY ( echo [错误] 未找到 Python,请先运行「安装.bat」 pause exit /b 1 ) echo 使用:%PY% echo. echo [1/3] 安装打包依赖 PyInstaller … "%PY%" -m pip install -q -r requirements-build.txt if errorlevel 1 ( echo pip 安装失败 pause exit /b 1 ) echo [2/3] 运行 PyInstaller(约 1~3 分钟)… "%PY%" -m PyInstaller --noconfirm --clean collector.spec if errorlevel 1 ( echo 打包失败 pause exit /b 1 ) set "DIST=dist\DouyinIMCollector" if not exist "%DIST%" ( echo 未找到输出目录 %DIST% pause exit /b 1 ) echo [3/3] 复制说明与启动脚本… copy /y "使用说明.txt" "%DIST%\" >nul copy /y "使用说明-exe版.txt" "%DIST%\" >nul copy /y "dist_extra\启动采集器.bat" "%DIST%\" >nul copy /y "dist_extra\一键采集.bat" "%DIST%\" >nul copy /y "dist_extra\修复浏览器.bat" "%DIST%\" >nul copy /y "splash.html" "%DIST%\" >nul echo. echo ======================================== echo 打包完成 echo ======================================== echo. echo 分发目录: echo %CD%\%DIST% echo. echo 将整个 DouyinIMCollector 文件夹打成 zip 发给用户即可。 echo. pause endlocal