Files
ai-mcp-web-ui/scripts/start_dev.sh
Claude AI a1deafe5a0 feat: 简化翻译卡片 + MCP 管理功能
- 简化 TranslationResult 组件,只显示译文和术语
- 修复数据结构适配后端 MCP 响应
- 添加复制按钮反馈提示
- 新增 MCP 管理页面,支持多 MCP 登录
- 新增 McpTokenManager 单例管理 Token
- 更新 JsonRenderer 支持 action 处理
- 修复热更新配置

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 00:02:15 +00:00

88 lines
2.4 KiB
Bash
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
# FastAPI 后端开发服务器启动脚本(热重载模式)
set -e
# 颜色定义
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# 项目根目录
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
BACKEND_DIR="$PROJECT_ROOT/backend"
LOG_FILE="$HOME/fastapi-dev.log"
# 端口配置
PORT=${PORT:-8081}
HOST=${HOST:-0.0.0.0}
echo -e "${GREEN}=== FastAPI 开发服务器启动 ===${NC}"
echo -e "项目目录: ${YELLOW}$PROJECT_ROOT${NC}"
echo -e "后端目录: ${YELLOW}$BACKEND_DIR${NC}"
echo -e "监听地址: ${YELLOW}$HOST:$PORT${NC} (内部服务)"
echo -e "前端访问: ${YELLOW}http://localhost:8080${NC}"
echo -e "日志文件: ${YELLOW}$LOG_FILE${NC}"
echo ""
# 检查 Python 是否安装
if ! command -v python3 &> /dev/null; then
echo -e "${RED}错误: 未找到 python3${NC}"
exit 1
fi
# 检查 uvicorn 是否安装
if ! python3 -c "import uvicorn" 2>/dev/null; then
echo -e "${YELLOW}警告: 未找到 uvicorn正在安装...${NC}"
pip install uvicorn[standard] || {
echo -e "${RED}错误: uvicorn 安装失败${NC}"
exit 1
}
fi
# 检查端口是否被占用
if lsof -Pi :$PORT -sTCP:LISTEN -t >/dev/null 2>&1; then
echo -e "${YELLOW}警告: 端口 $PORT 已被占用${NC}"
echo -e "正在尝试停止占用端口的进程..."
lsof -ti:$PORT | xargs kill -9 2>/dev/null || true
sleep 1
fi
# 切换到后端目录
cd "$BACKEND_DIR"
# 启动服务器(热重载模式)
echo -e "${GREEN}启动服务器(热重载模式)...${NC}"
echo -e "${GREEN}代码修改将自动重启服务${NC}"
echo ""
python3 -m uvicorn app_fastapi:app \
--host $HOST \
--port $PORT \
--reload \
--log-level info \
> "$LOG_FILE" 2>&1 &
PID=$!
echo $PID > "$HOME/fastapi-dev.pid"
sleep 2
# 检查服务是否启动成功
if ps -p $PID > /dev/null; then
echo -e "${GREEN}✓ 服务启动成功!${NC}"
echo -e " PID: ${YELLOW}$PID${NC}"
echo -e " 内网访问: ${YELLOW}http://localhost:$PORT${NC}"
echo -e " 外网访问: ${YELLOW}https://d8d-ai-vscode-8080-223-240-template-6-group.dev.d8d.fun/${NC}"
echo ""
echo -e "${YELLOW}查看日志: tail -f $LOG_FILE${NC}"
echo -e "${YELLOW}停止服务: kill $PID${NC}"
echo ""
echo -e "${GREEN}热重载已启用,修改代码后自动重启${NC}"
else
echo -e "${RED}✗ 服务启动失败${NC}"
echo -e "查看日志: ${YELLOW}cat $LOG_FILE${NC}"
exit 1
fi