feat: 实现积分系统与认证重构
重构认证系统,从next-auth迁移至better-auth,并实现完整的积分系统功能: 1. 新增积分账户管理、交易记录和扣减逻辑 2. 添加积分概览组件和API端点 3. 重构认证相关组件和路由 4. 优化播客生成流程与积分校验 5. 新增安全配置文档和数据库schema 6. 改进UI状态管理和错误处理 新增功能包括: - 用户注册自动初始化积分账户 - 播客生成前检查积分余额 - 积分交易记录查询 - 用户积分实时显示 - 安全回调处理
This commit is contained in:
4
main.py
4
main.py
@@ -230,7 +230,7 @@ async def _generate_podcast_task(
|
||||
"task_id": str(task_id),
|
||||
"auth_id": auth_id,
|
||||
"task_results": task_results[auth_id][task_id],
|
||||
"timestamp": time.time(),
|
||||
"timestamp": int(time.time()), # 确保发送整数秒级时间戳
|
||||
}
|
||||
|
||||
MAX_RETRIES = 3 # 定义最大重试次数
|
||||
@@ -239,7 +239,7 @@ async def _generate_podcast_task(
|
||||
for attempt in range(MAX_RETRIES + 1): # 尝试次数从0到MAX_RETRIES
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.post(callback_url, json=callback_data, timeout=30.0)
|
||||
response = await client.put(callback_url, json=callback_data, timeout=30.0)
|
||||
response.raise_for_status() # 对 4xx/5xx 响应抛出异常
|
||||
print(f"Callback successfully sent for task {task_id} on attempt {attempt + 1}. Status: {response.status_code}")
|
||||
break # 成功发送,跳出循环
|
||||
|
||||
Reference in New Issue
Block a user