style: 统一 Ruff 代码格式
This commit is contained in:
+23
-3
@@ -12,7 +12,20 @@ from fastapi.responses import FileResponse
|
||||
from starlette.middleware.base import BaseHTTPMiddleware
|
||||
|
||||
from .database import init_db
|
||||
from .routers import auth, users, accounts, account_check, dashboard, login, proxy, cookies, huya, douyu, yyb, audit
|
||||
from .routers import (
|
||||
auth,
|
||||
users,
|
||||
accounts,
|
||||
account_check,
|
||||
dashboard,
|
||||
login,
|
||||
proxy,
|
||||
cookies,
|
||||
huya,
|
||||
douyu,
|
||||
yyb,
|
||||
audit,
|
||||
)
|
||||
from .schemas import AppInfo
|
||||
from .version import get_app_version
|
||||
from utils import setup_logger
|
||||
@@ -22,7 +35,9 @@ from utils import setup_logger
|
||||
async def lifespan(app: FastAPI):
|
||||
# 本地 dev.sh 和 Docker 均显式设置 LOG_DIR;直接运行时回退到项目 logs/。
|
||||
_log_level = os.getenv("LOG_LEVEL", "INFO")
|
||||
_log_dir = Path(os.getenv("LOG_DIR", str(Path(__file__).resolve().parents[2] / "logs")))
|
||||
_log_dir = Path(
|
||||
os.getenv("LOG_DIR", str(Path(__file__).resolve().parents[2] / "logs"))
|
||||
)
|
||||
setup_logger(level=_log_level, log_dir=str(_log_dir))
|
||||
|
||||
init_db()
|
||||
@@ -46,6 +61,7 @@ async def lifespan(app: FastAPI):
|
||||
if cleaned_relogin:
|
||||
logger.info(f"启动清理 CK 重登残留任务: {cleaned_relogin} 条")
|
||||
from .services.yyb_service import cleanup_orphan_yyb_tasks
|
||||
|
||||
cleaned_yyb = cleanup_orphan_yyb_tasks(db, message="任务已中断(服务重启)")
|
||||
if cleaned_yyb:
|
||||
logger.info(f"启动清理应用宝残留任务: {cleaned_yyb} 条")
|
||||
@@ -65,7 +81,11 @@ _cors_env = os.getenv("CORS_ORIGINS", "")
|
||||
if _cors_env:
|
||||
_cors_origins = [o.strip() for o in _cors_env.split(",") if o.strip()]
|
||||
else:
|
||||
_cors_origins = ["http://localhost:5174", "http://localhost:5173", "http://localhost:3000"]
|
||||
_cors_origins = [
|
||||
"http://localhost:5174",
|
||||
"http://localhost:5173",
|
||||
"http://localhost:3000",
|
||||
]
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
|
||||
Reference in New Issue
Block a user