BodyBalanceEvaluation/start_dev_new.bat
2025-07-28 11:59:56 +08:00

127 lines
2.8 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
echo ====================================
echo 身体平衡评估系统 - 开发环境启动脚本
echo ====================================
echo.
:: 检查Python是否安装
python --version >nul 2>&1
if %errorlevel% neq 0 (
echo [错误] 未找到Python请先安装Python 3.8或更高版本
pause
exit /b 1
)
:: 检查Node.js是否安装
node --version >nul 2>&1
if %errorlevel% neq 0 (
echo [错误] 未找到Node.js请先安装Node.js 16.0或更高版本
pause
exit /b 1
)
:: 显示版本信息
echo [信息] 检查环境版本...
for /f "tokens=*" %%i in ('python --version') do echo Python: %%i
for /f "tokens=*" %%i in ('node --version') do echo Node.js: %%i
for /f "tokens=*" %%i in ('npm --version') do echo npm: %%i
echo.
:: 检查虚拟环境
if not exist "backend\venv" (
echo [信息] 创建Python虚拟环境...
python -m venv backend\venv
if %errorlevel% neq 0 (
echo [错误] 创建虚拟环境失败
pause
exit /b 1
)
)
:: 激活虚拟环境
echo [信息] 激活虚拟环境...
call backend\venv\Scripts\activate.bat
if %errorlevel% neq 0 (
echo [错误] 激活虚拟环境失败
pause
exit /b 1
)
:: 安装Python依赖
echo [信息] 检查并安装Python依赖...
if not exist "backend\requirements.txt" (
echo [错误] 未找到requirements.txt文件
pause
exit /b 1
)
pip install -r backend\requirements.txt
if %errorlevel% neq 0 (
echo [错误] 安装Python依赖失败
pause
exit /b 1
)
:: 安装前端依赖
echo [信息] 检查并安装前端依赖...
if exist "frontend\src\renderer\package.json" (
cd frontend\src\renderer
if not exist "node_modules" (
echo [信息] 安装前端依赖...
npm install
if %errorlevel% neq 0 (
echo [错误] 安装前端依赖失败
cd ..\..\..
pause
exit /b 1
)
) else (
echo [信息] 前端依赖已存在,跳过安装
)
cd ..\..\..
) else (
echo [警告] 未找到前端package.json文件
)
:: 创建必要的目录
echo [信息] 创建必要的目录...
if not exist "data" mkdir data
if not exist "data\patients" mkdir data\patients
if not exist "data\sessions" mkdir data\sessions
if not exist "data\exports" mkdir data\exports
if not exist "data\backups" mkdir data\backups
if not exist "logs" mkdir logs
if not exist "temp" mkdir temp
:: 检查配置文件
if not exist "config.json" (
echo [警告] 未找到config.json配置文件
echo [信息] 将使用默认配置
)
:: 启动应用
echo.
echo ====================================
echo 启动开发环境
echo ====================================
echo [信息] 启动后端服务器...
echo [信息] 后端地址: http://127.0.0.1:5000
echo [信息] 前端地址: http://127.0.0.1:5173
echo [信息] 按 Ctrl+C 停止服务
echo.
:: 启动主程序
python backend\main.py --mode development --log-level DEBUG
if %errorlevel% neq 0 (
echo.
echo [错误] 应用启动失败
echo [提示] 请检查错误信息并修复问题
pause
exit /b 1
)
echo.
echo [信息] 应用已停止
pause