backend v2.1: 公告管理功能 + 系统重构
- 新增 Announcement 数据模型,支持公告的增删改查 - 后台管理新增"公告管理"Tab(创建/编辑/删除/启用禁用) - 客户端 /api/announcement 改为从数据库读取 - 账号服务重构,新增无感换号、自动分析等功能 - 新增后台任务调度器、数据库迁移脚本 - Schema/Service/Config 全面升级至 v2.1 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,23 +4,40 @@ from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import HTMLResponse, FileResponse
|
||||
from contextlib import asynccontextmanager
|
||||
import os
|
||||
import logging
|
||||
|
||||
from app.database import engine, Base
|
||||
from app.api import client_router, admin_router
|
||||
from app.tasks import start_scheduler, stop_scheduler, run_startup_tasks
|
||||
|
||||
# 配置日志
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s [%(name)s] %(levelname)s: %(message)s"
|
||||
)
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
# 启动时创建数据库表
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
# 启动后台任务调度器
|
||||
start_scheduler()
|
||||
|
||||
# 运行启动任务
|
||||
await run_startup_tasks()
|
||||
|
||||
yield
|
||||
# 关闭时清理
|
||||
|
||||
# 关闭时停止调度器
|
||||
stop_scheduler()
|
||||
|
||||
|
||||
app = FastAPI(
|
||||
title="CursorPro 管理后台",
|
||||
description="Cursor 账号管理系统 API",
|
||||
version="1.0.0",
|
||||
title="蜂鸟Pro 管理后台",
|
||||
description="蜂鸟Pro 账号管理系统 API v2.1",
|
||||
version="2.1.0",
|
||||
lifespan=lifespan
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user