保存现有功能 增加域名和添加时间关联

This commit is contained in:
huangzhenpc
2025-04-07 15:32:42 +08:00
parent 8fc5a04903
commit 74770fb3dd
2 changed files with 39 additions and 4 deletions

View File

@@ -309,7 +309,19 @@ class AutoCursorService:
}
upload_data.append(upload_item)
# 打印上传数据的部分细节(去除敏感信息)
debug_data = []
for item in upload_data[:2]: # 只打印前2个账号作为示例
debug_item = item.copy()
if "cookie" in debug_item and debug_item["cookie"]:
debug_item["cookie"] = debug_item["cookie"][:20] + "..." if len(debug_item["cookie"]) > 20 else debug_item["cookie"]
if "token" in debug_item and debug_item["token"]:
debug_item["token"] = debug_item["token"][:20] + "..." if len(debug_item["token"]) > 20 else debug_item["token"]
debug_data.append(debug_item)
logger.debug(f"准备上传 {len(upload_data)} 个账号")
logger.debug(f"上传数据示例: {json.dumps(debug_data, ensure_ascii=False)}")
logger.debug(f"API URL: {url}")
# 发送请求
async with aiohttp.ClientSession() as session:
@@ -319,17 +331,36 @@ class AutoCursorService:
proxy=self.proxy,
ssl=False
) as response:
response_text = await response.text()
logger.debug(f"API响应状态码: {response.status}")
logger.debug(f"API响应内容: {response_text}")
if response.status != 200:
logger.error(f"上传账号API请求失败状态码: {response.status}")
return False
data = await response.json()
try:
data = json.loads(response_text)
except json.JSONDecodeError:
logger.error(f"解析响应失败非JSON格式: {response_text[:100]}...")
return False
if data.get("code") != 0:
logger.error(f"上传账号API返回错误: {data.get('msg', 'Unknown error')}")
error_msg = data.get("msg", "Unknown error")
logger.error(f"上传账号API返回错误: {error_msg}")
return False
success_count = data.get("data", {}).get("success", 0)
failed_count = data.get("data", {}).get("failed", 0)
# 检查是否有详细的错误信息
if "details" in data.get("data", {}):
details = data.get("data", {}).get("details", [])
if details:
logger.error("错误详情:")
for i, detail in enumerate(details[:5]): # 只显示前5个错误
logger.error(f" 错误 {i+1}: {detail.get('email', '未知邮箱')} - {detail.get('message', '未知错误')}")
logger.info(f"账号上传结果: 成功 {success_count}, 失败 {failed_count}")
return success_count > 0

View File

@@ -243,9 +243,13 @@ class CursorRegister:
upload_data.append(upload_item)
# 上传账号
await service.upload_accounts(upload_data)
upload_result = await service.upload_accounts(upload_data)
await service.cleanup()
if upload_result:
self.logger.info(f"成功上传 {len(upload_data)} 个账号到服务器")
else:
self.logger.error(f"账号上传失败,请检查日志了解详细信息")
except Exception as e:
self.logger.error(f"上传账号时发生错误: {str(e)}")