Files
YG_FT_Platform/web/start.sh
2026-01-09 10:38:04 +08:00

83 lines
2.2 KiB
Bash
Executable File
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.
#!/bin/bash
echo "🚀 启动大模型微调平台..."
echo ""
# 确保在正确的目录中
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "📂 当前目录: $SCRIPT_DIR"
echo ""
# 获取本机IP地址
SERVER_IP=$(hostname -I | awk '{print $1}')
echo "请选择启动方式:"
echo "1) 直接打开文件(本地访问)"
echo "2) 启动HTTP服务器可通过IP访问"
echo ""
read -p "请输入选择 (1-2): " choice
case $choice in
1)
echo ""
echo "🌐 打开本地文件..."
echo " - 主页: file://$SCRIPT_DIR/pages/main.html"
echo " - 登录: file://$SCRIPT_DIR/pages/login.html"
echo ""
# 检测操作系统并打开浏览器
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
open "pages/main.html"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux
xdg-open "pages/main.html"
elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
# Windows (Git Bash or Cygwin)
start "pages/main.html"
else
echo "请手动打开以下文件:"
echo " $SCRIPT_DIR/pages/main.html"
fi
echo "✅ 已在浏览器中打开主页"
;;
2)
echo ""
echo "🌐 本机 IP 地址: $SERVER_IP"
echo ""
# 检查Python是否可用
if command -v python3 &> /dev/null; then
PYTHON_CMD="python3"
elif command -v python &> /dev/null; then
PYTHON_CMD="python"
else
echo "❌ 错误: 未找到 Python"
echo "请安装 Python 或使用方式 1 直接打开文件"
exit 1
fi
echo "📱 访问地址:"
echo " - 主页: http://$SERVER_IP:8000/pages/main.html"
echo " - 登录: http://$SERVER_IP:8000/pages/login.html"
echo ""
echo "⚠️ 服务器将在端口 8000 启动"
echo "按 Ctrl+C 停止服务器"
echo ""
# 启动HTTP服务器
$PYTHON_CMD -m http.server 8000
;;
*)
echo "❌ 无效选择,请运行脚本重新选择"
exit 1
;;
esac