v1.3.2 — 日历同步批量查询+弹窗结果展示

- /api/calendar-sync-all 批量查询过去15天~未来15天
- 弹窗展示:加载动画 → 统计摘要 → 按日期分组日程列表
- 自动填充今日日程到早间立志
- 批量查询约需10秒,首次查询后同步写入缓存
This commit is contained in:
mac
2026-06-04 13:38:50 +08:00
parent f015b72ad8
commit c3dba63870
4 changed files with 232 additions and 24 deletions

17
app.py
View File

@@ -308,6 +308,23 @@ def api_calendar_sync():
return jsonify({'ok': True, 'data': events})
@app.route('/api/calendar-sync-all', methods=['GET'])
@login_required
def api_calendar_sync_all():
"""批量查询过去15天~未来15天的钉钉日程按日期分组返回"""
import json as _json
from datetime import datetime, timedelta
today = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
results = []
for delta in range(-15, 16):
d = today + timedelta(days=delta)
ds = d.strftime('%Y-%m-%d')
events = _fetch_dingtalk_events(ds)
if events:
results.append({'date': ds, 'events': events})
return jsonify({'ok': True, 'data': results})
# ── 启动 ──────────────────────────────────────────────
if __name__ == '__main__':