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

127 lines
3.3 KiB
Batchfile

@echo off
echo ====================================
echo Body Balance Evaluation System - Development Mode
echo ====================================
echo.
:: Check Python
python --version >nul 2>&1
if %errorlevel% neq 0 (
echo [Error] Python not found, please install Python 3.8 or higher
pause
exit /b 1
)
:: Check Node.js
node --version >nul 2>&1
if %errorlevel% neq 0 (
echo [Error] Node.js not found, please install Node.js 16.0 or higher
pause
exit /b 1
)
:: Show version info
echo [Info] Checking environment versions...
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.
:: Check virtual environment
if not exist "backend\venv" (
echo [Info] Creating Python virtual environment...
python -m venv backend\venv
if %errorlevel% neq 0 (
echo [Error] Failed to create virtual environment
pause
exit /b 1
)
)
:: Activate virtual environment
echo [Info] Activating virtual environment...
call backend\venv\Scripts\activate.bat
if %errorlevel% neq 0 (
echo [Error] Failed to activate virtual environment
pause
exit /b 1
)
:: Install Python dependencies
echo [Info] Checking and installing Python dependencies...
if not exist "backend\requirements.txt" (
echo [Error] requirements.txt file not found
pause
exit /b 1
)
pip install -r backend\requirements.txt
if %errorlevel% neq 0 (
echo [Error] Failed to install Python dependencies
pause
exit /b 1
)
:: Install frontend dependencies
echo [Info] Checking and installing frontend dependencies...
if exist "frontend\src\renderer\package.json" (
cd frontend\src\renderer
if not exist "node_modules" (
echo [Info] Installing frontend dependencies...
npm install
if %errorlevel% neq 0 (
echo [Error] Failed to install frontend dependencies
cd ..\..\..
pause
exit /b 1
)
) else (
echo [Info] Frontend dependencies already exist, skipping installation
)
cd ..\..\..
) else (
echo [Warning] Frontend package.json file not found
)
:: Create necessary directories
echo [Info] Creating necessary directories...
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
:: Check config file
if not exist "config.json" (
echo [Warning] config.json configuration file not found
echo [Info] Will use default configuration
)
:: Start application
echo.
echo ====================================
echo Starting Development Environment
echo ====================================
echo [Info] Starting backend server...
echo [Info] Backend address: http://127.0.0.1:5000
echo [Info] Frontend address: http://127.0.0.1:5173
echo [Info] Press Ctrl+C to stop service
echo.
:: Start main program
python backend\main.py --mode development --log-level DEBUG
if %errorlevel% neq 0 (
echo.
echo [Error] Application startup failed
echo [Tip] Please check error messages and fix issues
pause
exit /b 1
)
echo.
echo [Info] Application stopped
pause