@echo off
chcp 65001 >nul
echo ========================================
echo   会面点 Meeting Point - 构建脚本
echo ========================================
echo.

:: 检查 Go 是否安装
where go >nul 2>nul
if %ERRORLEVEL% neq 0 (
    echo [错误] 未找到 Go，请先安装 Go 语言环境
    pause
    exit /b 1
)

echo [1/3] 清理旧构建...
if exist "dist" rd /s /q "dist"
mkdir dist

echo [2/3] 编译 Windows 可执行文件...
set CGO_ENABLED=0
set GOOS=windows
set GOARCH=amd64
go build -ldflags="-s -w" -o dist\meeting-point.exe .

if %ERRORLEVEL% neq 0 (
    echo [错误] 编译失败
    pause
    exit /b 1
)

echo [3/3] 复制配置文件...
copy config.example.json dist\config.json >nul

echo.
echo ========================================
echo   构建完成！
echo ========================================
echo.
echo 输出目录: dist\
echo   - meeting-point.exe  (可执行文件)
echo   - config.json        (配置文件模板)
echo.
echo 使用方法:
echo   1. 编辑 config.json，填入高德地图 API Key
echo   2. 双击运行 meeting-point.exe
echo   3. 打开浏览器访问 http://localhost:8080
echo.
pause
