修复bug

This commit is contained in:
zhinianboke 2026-01-05 14:01:18 +08:00
parent 64504701ff
commit e0abe8fc8b
2 changed files with 3 additions and 17 deletions

View File

@ -16,6 +16,7 @@ const statusMap: Record<string, { label: string; class: string }> = {
shipped: { label: '已发货', class: 'badge-success' },
completed: { label: '已完成', class: 'badge-success' },
refunding: { label: '退款中', class: 'badge-warning' },
refund_cancelled: { label: '退款撤销', class: 'badge-info' },
cancelled: { label: '已关闭', class: 'badge-danger' },
unknown: { label: '未知', class: 'badge-gray' },
}

View File

@ -332,27 +332,12 @@ logger.info("Web服务器启动文件日志收集器已初始化")
async def log_requests(request, call_next):
start_time = time.time()
# 获取用户信息
user_info = "未登录"
try:
# 从请求头中获取Authorization
auth_header = request.headers.get("Authorization")
if auth_header and auth_header.startswith("Bearer "):
token = auth_header.split(" ")[1]
if token in SESSION_TOKENS:
token_data = SESSION_TOKENS[token]
# 检查token是否过期
if time.time() - token_data['timestamp'] <= TOKEN_EXPIRE_TIME:
user_info = f"{token_data['username']}#{token_data['user_id']}"
except Exception:
pass
logger.info(f"🌐 {user_info} API请求: {request.method} {request.url.path}")
logger.info(f"🌐 API请求: {request.method} {request.url.path}")
response = await call_next(request)
process_time = time.time() - start_time
logger.info(f"{user_info} API响应: {request.method} {request.url.path} - {response.status_code} ({process_time:.3f}s)")
logger.info(f"✅ API响应: {request.method} {request.url.path} - {response.status_code} ({process_time:.3f}s)")
return response