You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

@echo off
REM 快速启动脚本 - 自动下载、编译、启动Web服务器 (Windows)
echo =========================================
echo 快速启动Web聊天服务器
echo =========================================
echo.
REM 检查Java
java -version >nul 2>&1
if %errorlevel% neq 0 (
echo X 未找到Java请先安装Java 11+
pause
exit /b 1
)
REM 检查web文件
if not exist "web\index.html" (
echo X 错误: 找不到web\index.html文件
echo 请确保在项目根目录运行此脚本
pause
exit /b 1
)
REM 下载Gson
if not exist "lib\gson-2.10.1.jar" (
echo 下载依赖...
if not exist lib mkdir lib
powershell -Command "Invoke-WebRequest -Uri 'https://repo1.maven.org/maven2/com/google/code/gson/gson/2.10.1/gson-2.10.1.jar' -OutFile 'lib\gson-2.10.1.jar'" 2>nul
)
REM 编译
echo 编译项目...
if not exist bin mkdir bin
javac -cp "lib\gson-2.10.1.jar" -d bin -encoding UTF-8 src/common/*.java src/server/WebSocketServer.java src/server/WebSocketClient.java 2>&1
if %errorlevel% neq 0 (
echo X 编译失败
pause
exit /b 1
)
REM 启动
echo √ 编译成功
echo.
echo 启动Web服务器...
echo 访问地址: http://localhost:8080
echo.
echo 按 Ctrl+C 停止服务器
echo.
cd bin
java -cp ".;..\lib\gson-2.10.1.jar" server.WebSocketServer