fix(notif): 修复潜在的KeyError:index问题

This commit is contained in:
Alirea
2025-09-29 19:28:45 +08:00
parent 98a2b0f176
commit e5b43a9c45
2 changed files with 10 additions and 1 deletions

View File

@@ -2272,7 +2272,12 @@ class AppConfig(GlobalConfig):
logger.success(f"统计信息合并完成, 共计 {len(data['index'])} 条记录")
return {k: v for k, v in data.items() if v}
# 确保返回的字典始终包含 index 字段,即使为空
result = {k: v for k, v in data.items() if v}
if "index" not in result:
result["index"] = []
return result
async def search_history(self, mode: str, start_date: date, end_date: date) -> dict:
"""