Files
YG_FT_Platform/web/start.bat

158 lines
3.0 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
chcp 65001 >nul
title FT-Platform Web 前端
echo.
echo 🚀 启动大模型微调平台 (Web 前端)
echo ========================================
echo.
:: 确保在正确的目录中
cd /d "%~dp0"
echo 📂 当前目录: %CD%
echo.
:: 检测运行环境
if not "%WSLENV%"=="" (
echo 📟 检测到 WSL 环境
set "IS_WSL=1"
) else (
echo 📟 检测到 Windows 环境
set "IS_WSL=0"
)
echo.
echo 请选择启动方式:
echo 1) 直接打开文件(本地访问)
echo 2) 启动HTTP服务器推荐跨域访问
echo 3) 使用 Python 启动 HTTP 服务器
echo.
set /p choice="请输入选择 (1-3): "
if "%choice%"=="1" goto open_file
if "%choice%"=="2" goto start_http
if "%choice%"=="3" goto start_python
echo ❌ 无效选择
pause
exit /b 1
:open_file
echo.
echo 🌐 打开本地文件...
echo.
echo 主页: file://%CD%\pages\main.html
echo 登录: file://%CD%\pages\login.html
echo.
:: 尝试打开浏览器
if exist "pages\main.html" (
start "FT-Platform 主页" "pages\main.html"
echo ✅ 已尝试在浏览器中打开主页
) else (
echo ❌ 未找到 pages\main.html 文件
)
echo.
echo 💡 如果浏览器未自动打开,请手动双击打开:
echo %CD%\pages\main.html
echo.
pause
goto end
:start_http
echo.
echo 🌐 启动 HTTP 服务器...
echo.
:: 检查 Python 命令
python --version >nul 2>&1
if %errorlevel% equ 0 (
set "PYTHON_CMD=python"
goto run_server
)
python3 --version >nul 2>&1
if %errorlevel% equ 0 (
set "PYTHON_CMD=python3"
goto run_server
)
echo ❌ 未找到 Python
echo.
echo 💡 请安装 Python 或选择方式 1 直接打开文件
echo.
pause
goto end
:start_python
echo.
echo 🌐 使用 Python 启动 HTTP 服务器...
echo.
:: 尝试多种 Python 命令
where python >nul 2>&1
if %errorlevel% equ 0 (
set "PYTHON_CMD=python"
goto run_server
)
where python3 >nul 2>&1
if %errorlevel% equ 0 (
set "PYTHON_CMD=python3"
goto run_server
)
echo ❌ 未找到 Python 命令
echo.
echo 💡 请检查 Python 是否已安装并添加到 PATH
echo.
pause
goto end
:run_server
echo ✅ 使用命令: %PYTHON_CMD%
echo.
:: 获取本机IP如果可能
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| findstr /i "IPv4" ^| findstr /v "127.0.0.1"') do (
set "SERVER_IP=%%a"
goto :ip_found
)
:ip_found
if defined SERVER_IP (
echo 🌐 检测到 IP: %SERVER_IP%
) else (
echo 🌐 使用 localhost 访问
set "SERVER_IP=localhost"
)
echo.
echo 📱 访问地址:
echo 主页: http://%SERVER_IP%:8000/pages/main.html
echo 登录: http://%SERVER_IP%:8000/pages/login.html
echo.
echo ⚠️ 服务器启动在端口 8000
echo 按 Ctrl+C 停止服务器
echo.
if "%IS_WSL%"=="1" (
echo 💡 WSL 环境提示: 如果无法访问 localhost请检查网络配置
echo.
)
:: 启动服务器
echo 🔧 启动中...
echo.
%PYTHON_CMD% -m http.server 8000
if %errorlevel% neq 0 (
echo.
echo ❌ 启动失败,请检查 Python 环境
pause
)
:end