v1.3.0 — 钉钉日历同步
- 早间立志卡片新增日历同步按钮 - /api/calendar-sync 从缓存读取当日钉钉会议 - 自动填入立志:去重防重复,保留时间+地点格式 - 日历缓存: ~/.workbuddy/data/ziwei-power/calendar_cache.json
This commit is contained in:
21
app.py
21
app.py
@@ -225,6 +225,27 @@ def api_reorder_wishes():
|
||||
return jsonify({'ok': True})
|
||||
|
||||
|
||||
# ── 日历同步 API ────────────────────────────
|
||||
|
||||
CALENDAR_CACHE = os.path.join(os.path.expanduser('~'), '.workbuddy', 'data', 'ziwei-power', 'calendar_cache.json')
|
||||
|
||||
@app.route('/api/calendar-sync', methods=['GET'])
|
||||
@login_required
|
||||
def api_calendar_sync():
|
||||
"""获取指定日期的钉钉日历会议"""
|
||||
import json as _json
|
||||
date = request.args.get('date', '')
|
||||
if not date:
|
||||
return jsonify({'ok': False, 'error': '缺少 date 参数'}), 400
|
||||
try:
|
||||
with open(CALENDAR_CACHE, 'r') as f:
|
||||
events = _json.load(f)
|
||||
except (FileNotFoundError, _json.JSONDecodeError):
|
||||
return jsonify({'ok': True, 'data': []})
|
||||
today_events = [e for e in events if e.get('date') == date]
|
||||
return jsonify({'ok': True, 'data': today_events})
|
||||
|
||||
|
||||
# ── 启动 ──────────────────────────────────────────────
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user