WebUI 前端 & 后端超级大重构

This commit is contained in:
DrSmoothl
2026-03-14 21:06:36 +08:00
parent 6ca5a2939e
commit 172615f18a
69 changed files with 3128 additions and 6581 deletions

View File

@@ -7,28 +7,20 @@
import os
import time
from datetime import datetime
from typing import Optional
from fastapi import APIRouter, HTTPException, Depends, Cookie, Header
from fastapi import APIRouter, Depends, HTTPException
from pydantic import BaseModel
from src.config.config import MMC_VERSION
from src.common.logger import get_logger
from src.webui.core import verify_auth_token_from_cookie_or_header
from src.webui.dependencies import require_auth
router = APIRouter(prefix="/system", tags=["system"])
router = APIRouter(prefix="/system", tags=["system"], dependencies=[Depends(require_auth)])
logger = get_logger("webui_system")
# 记录启动时间
_start_time = time.time()
def require_auth(
maibot_session: Optional[str] = Cookie(None),
authorization: Optional[str] = Header(None),
) -> bool:
"""认证依赖:验证用户是否已登录"""
return verify_auth_token_from_cookie_or_header(maibot_session, authorization)
class RestartResponse(BaseModel):
"""重启响应"""
@@ -46,7 +38,7 @@ class StatusResponse(BaseModel):
@router.post("/restart", response_model=RestartResponse)
async def restart_maibot(_auth: bool = Depends(require_auth)):
async def restart_maibot():
"""
重启麦麦主程序
@@ -77,7 +69,7 @@ async def restart_maibot(_auth: bool = Depends(require_auth)):
@router.get("/status", response_model=StatusResponse)
async def get_maibot_status(_auth: bool = Depends(require_auth)):
async def get_maibot_status():
"""
获取麦麦运行状态
@@ -100,7 +92,7 @@ async def get_maibot_status(_auth: bool = Depends(require_auth)):
@router.post("/reload-config")
async def reload_config(_auth: bool = Depends(require_auth)):
async def reload_config():
"""
热重载配置(不重启进程)