Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99bc6d3c6c | ||
|
|
5d3192dfaf | ||
|
|
9c9511e817 | ||
|
|
b5dbb13956 | ||
|
|
5ef340cb08 | ||
|
|
073b570681 | ||
|
|
ce0e374e86 | ||
|
|
f7bbc505b9 | ||
|
|
351e1f18ae | ||
|
|
0e75326b5f | ||
|
|
cd90c2d799 | ||
|
|
c2cbbdb12a | ||
|
|
8223f72544 | ||
|
|
36b58a8b73 | ||
|
|
5b73fc0eae | ||
|
|
5b637e7fed | ||
|
|
350c9fb877 | ||
|
|
19ae81ae6e | ||
|
|
535af35911 | ||
|
|
fc338f426a | ||
|
|
5300ee426d | ||
|
|
8ac6f1af6b | ||
|
|
8c81fae334 | ||
|
|
67505414d9 | ||
|
|
03745e19c3 | ||
|
|
be9f10e968 | ||
|
|
6e1b793b40 | ||
|
|
e90e8c30ff | ||
|
|
046f144896 | ||
|
|
ba592c07b7 | ||
|
|
105d62f8db | ||
|
|
c3dba63870 | ||
|
|
f015b72ad8 | ||
|
|
bb07d320f2 | ||
|
|
46862e5110 | ||
|
|
7b4134a72c | ||
|
|
13a0e12b34 | ||
|
|
1ea81b3086 | ||
|
|
bafac0bc12 | ||
|
|
1d86d7f736 | ||
|
|
690509bfb3 | ||
|
|
668576b866 | ||
|
|
abdc1fc739 |
306
app.py
306
app.py
@@ -6,10 +6,11 @@ from datetime import timedelta
|
||||
from functools import wraps
|
||||
from flask import Flask, render_template, request, jsonify, session, redirect, url_for
|
||||
from werkzeug.security import generate_password_hash, check_password_hash
|
||||
from database import init_db, get_checkin, save_checkin, delete_checkin, get_all_checkins
|
||||
from database import init_db, get_checkin, save_checkin, delete_checkin, get_all_checkins, get_weeks_list, get_daily_backup, get_wishes, save_wish, update_wish, delete_wish, reorder_wishes
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = os.urandom(24)
|
||||
# 固定密钥确保 gunicorn 多 worker 下 session 可互通
|
||||
app.secret_key = os.environ.get('SECRET_KEY', 'ziwei-power-secret-2026')
|
||||
|
||||
# 会话持久化:30 天
|
||||
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=30)
|
||||
@@ -71,11 +72,35 @@ def logout():
|
||||
def compute_stats():
|
||||
"""计算统计数据,供 API 和模板共用"""
|
||||
rows = get_all_checkins()
|
||||
total_days = len(rows)
|
||||
total_weeks = len(rows)
|
||||
total_morning = 0
|
||||
total_evening = 0
|
||||
total_study = 0
|
||||
calendar = {}
|
||||
all_morning_items = []
|
||||
all_evening_items = []
|
||||
all_study_items = []
|
||||
|
||||
# 关键词 → 板块 自动归类规则
|
||||
PILLAR_KEYWORDS = {
|
||||
'医药营销': ['科普','科研','学术会议','学术','会议','患者管理','临床推广','临床','药企','处方','KOL','代表','拜访','荣昌','恒瑞','信达','鲁银','OPC','项目','标杆','客户'],
|
||||
'医疗服务': ['诊疗','治疗','医生','医院','科室','手术','门诊','患者','病','护理','诊断','影像','检验'],
|
||||
'医疗支付': ['医保','商保','理赔','支付','保险','费用','报销','商业保险','保单'],
|
||||
'AI 智能': ['AI','数字人','智能','算法','自动化','平台','系统','网站','开发','代码','程序','模型'],
|
||||
'公司治理': ['团队','组织','管理','招聘','HR','制度','流程','财务','考核','KPI','规划','人才','架构','预算'],
|
||||
'个人修养': ['早起','睡觉','俯卧撑','运动','冥想','阅读','复盘','写作','习惯','修身','立志','责善','改过','勤学'],
|
||||
}
|
||||
|
||||
def classify_auto(text):
|
||||
"""根据文本内容自动归类"""
|
||||
if not text or not text.strip():
|
||||
return ''
|
||||
text_lower = text.strip()
|
||||
for pillar, keywords in PILLAR_KEYWORDS.items():
|
||||
for kw in keywords:
|
||||
if kw in text_lower:
|
||||
return pillar
|
||||
return '' # 未匹配
|
||||
|
||||
for row in rows:
|
||||
d = row['date']
|
||||
@@ -84,7 +109,42 @@ def compute_stats():
|
||||
evening = data.get('evening', [])
|
||||
study = data.get('study', [])
|
||||
|
||||
morning_count = sum(1 for x in morning if isinstance(x, str) and x.strip())
|
||||
# 收集并自动归类
|
||||
for mi in morning:
|
||||
text = mi if isinstance(mi, str) else mi.get('text', '')
|
||||
if isinstance(text, str) and text.strip():
|
||||
auto_pillar = mi.get('pillar', '') if isinstance(mi, dict) else ''
|
||||
if not auto_pillar:
|
||||
auto_pillar = classify_auto(text)
|
||||
all_morning_items.append({'text': text.strip(), 'pillar': auto_pillar})
|
||||
|
||||
for ei in evening:
|
||||
if isinstance(ei, dict):
|
||||
m = (ei.get('mistake') or '').strip()
|
||||
imp = (ei.get('improvement') or '').strip()
|
||||
if m or imp:
|
||||
pillar = ei.get('pillar', '') or classify_auto(m + ' ' + imp)
|
||||
all_evening_items.append({'mistake': m, 'improvement': imp, 'pillar': pillar})
|
||||
elif isinstance(ei, str) and ei.strip():
|
||||
all_evening_items.append({'mistake': ei.strip(), 'improvement': '', 'pillar': classify_auto(ei)})
|
||||
|
||||
for si in study:
|
||||
name = si.get('name', '') if isinstance(si, dict) else str(si)
|
||||
if name.strip():
|
||||
pillar = si.get('pillar', '') if isinstance(si, dict) else ''
|
||||
if not pillar:
|
||||
pillar = classify_auto(name)
|
||||
all_study_items.append({
|
||||
'name': name.strip(),
|
||||
'done': si.get('done', False) if isinstance(si, dict) else False,
|
||||
'note': si.get('note', '') if isinstance(si, dict) else '',
|
||||
'pillar': pillar
|
||||
})
|
||||
|
||||
morning_count = sum(1 for x in morning if (
|
||||
isinstance(x, str) and x.strip() or
|
||||
isinstance(x, dict) and (x.get('text', '') or '').strip()
|
||||
))
|
||||
evening_count = sum(1 for x in evening if (
|
||||
isinstance(x, str) and x.strip() or
|
||||
isinstance(x, dict) and (x.get('mistake', '') or '').strip()
|
||||
@@ -102,10 +162,38 @@ def compute_stats():
|
||||
# day_score = 60 + extra * 5 (不在此处使用,仅用于日历状态)
|
||||
calendar[d] = 'pass' if all_three else 'fail'
|
||||
|
||||
# 构建板块统计
|
||||
pillars = ['医疗服务','医药营销','医疗支付','AI 智能','公司治理','个人修养']
|
||||
pillar_breakdown = {}
|
||||
for p in pillars:
|
||||
pillar_breakdown[p] = {
|
||||
'morning': 0, 'evening': 0, 'study': 0,
|
||||
'morning_items': [], 'evening_items': [], 'study_items': []
|
||||
}
|
||||
for mi in all_morning_items:
|
||||
p = mi['pillar']
|
||||
if p in pillar_breakdown:
|
||||
pillar_breakdown[p]['morning'] += 1
|
||||
pillar_breakdown[p]['morning_items'].append(mi)
|
||||
for ei in all_evening_items:
|
||||
p = ei['pillar']
|
||||
if p in pillar_breakdown:
|
||||
pillar_breakdown[p]['evening'] += 1
|
||||
pillar_breakdown[p]['evening_items'].append(ei)
|
||||
for si in all_study_items:
|
||||
p = si['pillar']
|
||||
if p in pillar_breakdown:
|
||||
pillar_breakdown[p]['study'] += 1
|
||||
pillar_breakdown[p]['study_items'].append(si)
|
||||
|
||||
return dict(
|
||||
total_days=total_days, total_morning=total_morning,
|
||||
total_weeks=total_weeks, total_morning=total_morning,
|
||||
total_evening=total_evening, total_study=total_study,
|
||||
calendar=calendar
|
||||
calendar=calendar,
|
||||
morning_items=all_morning_items,
|
||||
evening_items=all_evening_items,
|
||||
study_items=all_study_items,
|
||||
pillar_breakdown=pillar_breakdown
|
||||
)
|
||||
|
||||
|
||||
@@ -114,9 +202,11 @@ def compute_stats():
|
||||
def index():
|
||||
import json
|
||||
stats = compute_stats()
|
||||
wishes = [dict(w) for w in get_wishes()]
|
||||
return render_template('index.html',
|
||||
username=session.get('display_name', session.get('username', '')),
|
||||
initial_stats=json.dumps(stats, ensure_ascii=False))
|
||||
initial_stats=json.dumps(stats, ensure_ascii=False),
|
||||
initial_wishes=json.dumps(wishes, ensure_ascii=False))
|
||||
|
||||
|
||||
# ── API ──────────────────────────────────────────────
|
||||
@@ -124,10 +214,10 @@ def index():
|
||||
@app.route('/api/checkin', methods=['GET'])
|
||||
@login_required
|
||||
def api_get_checkin():
|
||||
date = request.args.get('date', '')
|
||||
if not date:
|
||||
return jsonify({'ok': False, 'error': '缺少 date 参数'}), 400
|
||||
row = get_checkin(date)
|
||||
week = request.args.get('week', '')
|
||||
if not week:
|
||||
return jsonify({'ok': False, 'error': '缺少 week 参数'}), 400
|
||||
row = get_checkin(week)
|
||||
return jsonify({'ok': True, 'data': row})
|
||||
|
||||
|
||||
@@ -135,21 +225,29 @@ def api_get_checkin():
|
||||
@login_required
|
||||
def api_save_checkin():
|
||||
body = request.get_json(force=True)
|
||||
date = body.get('date', '')
|
||||
if not date:
|
||||
return jsonify({'ok': False, 'error': '缺少 date 字段'}), 400
|
||||
week = body.get('week', '')
|
||||
if not week:
|
||||
return jsonify({'ok': False, 'error': '缺少 week 字段'}), 400
|
||||
data = body.get('data', {})
|
||||
save_checkin(date, data)
|
||||
save_checkin(week, data)
|
||||
return jsonify({'ok': True})
|
||||
|
||||
|
||||
@app.route('/api/checkin/<date>', methods=['DELETE'])
|
||||
@app.route('/api/checkin/<week>', methods=['DELETE'])
|
||||
@login_required
|
||||
def api_delete_checkin(date):
|
||||
delete_checkin(date)
|
||||
def api_delete_checkin(week):
|
||||
delete_checkin(week)
|
||||
return jsonify({'ok': True})
|
||||
|
||||
|
||||
@app.route('/api/checkin/weeks', methods=['GET'])
|
||||
@login_required
|
||||
def api_weeks():
|
||||
"""返回所有已打卡周号"""
|
||||
weeks = get_weeks_list()
|
||||
return jsonify({'ok': True, 'data': weeks})
|
||||
|
||||
|
||||
@app.route('/api/history', methods=['GET'])
|
||||
@login_required
|
||||
def api_history():
|
||||
@@ -157,6 +255,17 @@ def api_history():
|
||||
return jsonify({'ok': True, 'data': rows})
|
||||
|
||||
|
||||
@app.route('/api/history/daily', methods=['GET'])
|
||||
@login_required
|
||||
def api_history_daily():
|
||||
"""查看某周的原始日记录"""
|
||||
week = request.args.get('week', '')
|
||||
if not week:
|
||||
return jsonify({'ok': False, 'error': '缺少 week 参数'}), 400
|
||||
rows = get_daily_backup(week)
|
||||
return jsonify({'ok': True, 'data': rows})
|
||||
|
||||
|
||||
@app.route('/api/stats', methods=['GET'])
|
||||
@login_required
|
||||
def api_stats():
|
||||
@@ -174,6 +283,167 @@ def api_user():
|
||||
})
|
||||
|
||||
|
||||
# ── 心愿清单 API ──────────────────────────────
|
||||
|
||||
@app.route('/api/wishes', methods=['GET'])
|
||||
@login_required
|
||||
def api_get_wishes():
|
||||
wishes = [dict(w) for w in get_wishes()]
|
||||
return jsonify({'ok': True, 'data': wishes})
|
||||
|
||||
|
||||
@app.route('/api/wishes', methods=['POST'])
|
||||
@login_required
|
||||
def api_create_wish():
|
||||
body = request.get_json(force=True)
|
||||
name = body.get('name', '').strip()
|
||||
if not name:
|
||||
return jsonify({'ok': False, 'error': '名称不能为空'}), 400
|
||||
quadrant = body.get('quadrant', '重要不紧急')
|
||||
deadline = body.get('deadline', '')
|
||||
wid = save_wish(name, quadrant, deadline)
|
||||
return jsonify({'ok': True, 'id': wid})
|
||||
|
||||
|
||||
@app.route('/api/wishes/<int:wish_id>', methods=['PUT'])
|
||||
@login_required
|
||||
def api_update_wish(wish_id):
|
||||
body = request.get_json(force=True)
|
||||
update_wish(wish_id, **body)
|
||||
return jsonify({'ok': True})
|
||||
|
||||
|
||||
@app.route('/api/wishes/<int:wish_id>', methods=['DELETE'])
|
||||
@login_required
|
||||
def api_delete_wish(wish_id):
|
||||
delete_wish(wish_id)
|
||||
return jsonify({'ok': True})
|
||||
|
||||
|
||||
@app.route('/api/wishes/reorder', methods=['PUT'])
|
||||
@login_required
|
||||
def api_reorder_wishes():
|
||||
body = request.get_json(force=True)
|
||||
order = body.get('order', [])
|
||||
if not isinstance(order, list):
|
||||
return jsonify({'ok': False, 'error': 'order 必须是列表'}), 400
|
||||
reorder_wishes(order)
|
||||
return jsonify({'ok': True})
|
||||
|
||||
|
||||
# ── 日历同步 API ────────────────────────────
|
||||
|
||||
CALENDAR_CACHE = os.path.join(os.path.expanduser('~'), '.workbuddy', 'data', 'ziwei-power', 'calendar_cache.json')
|
||||
DING_MCP_URL = 'https://mcp-gw.dingtalk.com/server/95959163f85d8b58a167f65cd8bd3d22690b16c75ebacd0fa095016396a10e0d?key=0993e4d4e44c50ea25a0db840cc5815e'
|
||||
|
||||
|
||||
def _fetch_dingtalk_events_week(week_str):
|
||||
"""调用钉钉 MCP 查询指定周(周一~周日)的全部日程"""
|
||||
import json as _json, urllib.request as _ur
|
||||
from datetime import datetime, timezone, timedelta
|
||||
tz = timezone(timedelta(hours=8))
|
||||
try:
|
||||
year_part, week_part = week_str.split('-W')
|
||||
year = int(year_part)
|
||||
week = int(week_part)
|
||||
except (ValueError, IndexError):
|
||||
return []
|
||||
jan1 = datetime(year, 1, 1, tzinfo=tz)
|
||||
monday = jan1 + timedelta(days=(week - 1) * 7 - jan1.weekday())
|
||||
results = []
|
||||
for i in range(7):
|
||||
d = monday + timedelta(days=i)
|
||||
ds = d.strftime('%Y-%m-%d')
|
||||
start_ts = int(d.replace(hour=0, minute=0, second=0).timestamp() * 1000)
|
||||
end_ts = int(d.replace(hour=23, minute=59, second=59).timestamp() * 1000)
|
||||
body = _json.dumps({
|
||||
'jsonrpc': '2.0', 'method': 'tools/call', 'id': 1,
|
||||
'params': {'name': 'list_calendar_events', 'arguments': {
|
||||
'calendarId': 'primary', 'startTime': start_ts, 'endTime': end_ts, 'limit': 20
|
||||
}}
|
||||
}).encode('utf-8')
|
||||
req = _ur.Request(DING_MCP_URL, data=body, headers={
|
||||
'Content-Type': 'application/json', 'Accept': 'application/json'
|
||||
})
|
||||
try:
|
||||
with _ur.urlopen(req, timeout=10) as resp:
|
||||
data = _json.loads(resp.read())
|
||||
events = data.get('result', {}).get('structuredContent', {}).get('result', {}).get('events', [])
|
||||
except Exception:
|
||||
continue
|
||||
for e in events:
|
||||
summary = (e.get('summary') or '').strip()
|
||||
if not summary:
|
||||
continue
|
||||
start = e.get('start', {}).get('dateTime', '')
|
||||
end = e.get('end', {}).get('dateTime', '')
|
||||
time_str = ''
|
||||
if start and end:
|
||||
time_str = start[11:16] + '-' + end[11:16]
|
||||
results.append({
|
||||
'date': ds, 'summary': summary,
|
||||
'time': time_str, 'location': e.get('location') or ''
|
||||
})
|
||||
return results
|
||||
|
||||
|
||||
@app.route('/api/calendar-sync', methods=['GET'])
|
||||
@login_required
|
||||
def api_calendar_sync():
|
||||
week = request.args.get('week', '')
|
||||
if not week:
|
||||
return jsonify({'ok': False, 'error': '缺少 week 参数'}), 400
|
||||
events = _fetch_dingtalk_events_week(week)
|
||||
return jsonify({'ok': True, 'data': events})
|
||||
|
||||
|
||||
@app.route('/api/calendar-sync-all', methods=['GET'])
|
||||
@login_required
|
||||
def api_calendar_sync_all():
|
||||
"""批量查询过去4周~未来4周的钉钉日程,并自动填充到对应周的 checkin"""
|
||||
import json as _json
|
||||
from datetime import datetime, timedelta
|
||||
today = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
results = []
|
||||
saved_weeks = 0
|
||||
for delta in range(-4, 5):
|
||||
# 计算目标周
|
||||
target = today + timedelta(weeks=delta)
|
||||
iso_year, iso_week, _ = target.isocalendar()
|
||||
week_key = f"{iso_year}-W{iso_week:02d}"
|
||||
events = _fetch_dingtalk_events_week(week_key)
|
||||
if events:
|
||||
results.append({'date': week_key, 'events': events})
|
||||
# 自动去重填充
|
||||
existing = get_checkin(week_key)
|
||||
data = existing['data'] if existing else {'morning': [], 'evening': [], 'study': []}
|
||||
morning = data.get('morning', [])
|
||||
existing_texts = set()
|
||||
for mi in morning:
|
||||
t = mi if isinstance(mi, str) else mi.get('text', '')
|
||||
if t.strip():
|
||||
existing_texts.add(t.strip())
|
||||
added = False
|
||||
for evt in events:
|
||||
summary = (evt.get('summary') or '').strip()
|
||||
if not summary:
|
||||
continue
|
||||
text = f"【{evt['time']}】{summary}" if evt.get('time') else summary
|
||||
loc = evt.get('location', '')
|
||||
if loc:
|
||||
text += f" @{loc}"
|
||||
text = text.strip()
|
||||
if text not in existing_texts:
|
||||
morning.append(text)
|
||||
existing_texts.add(text)
|
||||
added = True
|
||||
if added:
|
||||
data['morning'] = morning
|
||||
save_checkin(week_key, data)
|
||||
saved_weeks += 1
|
||||
return jsonify({'ok': True, 'data': results, 'saved_days': saved_weeks})
|
||||
|
||||
|
||||
# ── 启动 ──────────────────────────────────────────────
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
237
database.py
237
database.py
@@ -10,6 +10,9 @@ DB_DIR = os.path.join(os.path.expanduser('~'), '.workbuddy', 'data', 'ziwei-powe
|
||||
os.makedirs(DB_DIR, exist_ok=True)
|
||||
DB_PATH = os.path.join(DB_DIR, 'ziwei_power.db')
|
||||
|
||||
# 当前数据库 schema 版本 —— 改表结构时必须 +1 并补迁移逻辑
|
||||
CURRENT_SCHEMA_VERSION = 4
|
||||
|
||||
|
||||
def get_conn():
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
@@ -17,18 +20,91 @@ def get_conn():
|
||||
return conn
|
||||
|
||||
|
||||
def init_db():
|
||||
"""初始化数据库表"""
|
||||
conn = get_conn()
|
||||
def _get_schema_version(conn):
|
||||
"""读取当前数据库的 schema 版本,无表时返回 0"""
|
||||
conn.execute('''
|
||||
CREATE TABLE IF NOT EXISTS checkins (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
date TEXT UNIQUE NOT NULL,
|
||||
data TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL
|
||||
CREATE TABLE IF NOT EXISTS schema_version (
|
||||
version INTEGER NOT NULL
|
||||
)
|
||||
''')
|
||||
row = conn.execute('SELECT version FROM schema_version').fetchone()
|
||||
return row['version'] if row else 0
|
||||
|
||||
|
||||
def _set_schema_version(conn, version):
|
||||
"""写入 schema 版本"""
|
||||
conn.execute('DELETE FROM schema_version')
|
||||
conn.execute('INSERT INTO schema_version (version) VALUES (?)', (version,))
|
||||
|
||||
|
||||
def init_db():
|
||||
"""初始化数据库表 & 自动迁移"""
|
||||
conn = get_conn()
|
||||
current = _get_schema_version(conn)
|
||||
|
||||
# ── 迁移步骤(按版本号递增)────────────────────────
|
||||
if current < 1:
|
||||
# v1: 初始表结构
|
||||
conn.execute('''
|
||||
CREATE TABLE IF NOT EXISTS checkins (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
date TEXT UNIQUE NOT NULL,
|
||||
data TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL
|
||||
)
|
||||
''')
|
||||
|
||||
if current < 2:
|
||||
# v2: 心愿清单
|
||||
conn.execute('''
|
||||
CREATE TABLE IF NOT EXISTS wishes (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
priority TEXT NOT NULL DEFAULT '中',
|
||||
deadline TEXT NOT NULL DEFAULT '',
|
||||
done INTEGER NOT NULL DEFAULT 0,
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
created_at TEXT NOT NULL
|
||||
)
|
||||
''')
|
||||
|
||||
if current < 3:
|
||||
# v3: 优先级改为四象限
|
||||
conn.execute("ALTER TABLE wishes ADD COLUMN quadrant TEXT NOT NULL DEFAULT '重要不紧急'")
|
||||
conn.execute("UPDATE wishes SET quadrant = CASE priority WHEN '高' THEN '重要紧急' WHEN '中' THEN '重要不紧急' WHEN '低' THEN '不紧急不重要' ELSE '重要不紧急' END WHERE quadrant = '重要不紧急'")
|
||||
|
||||
if current < 4:
|
||||
# v4: 日打卡 → 周打卡
|
||||
# 备份旧表 → 聚合 → 新建周表
|
||||
existing = conn.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='checkins'").fetchone()
|
||||
if existing:
|
||||
# 检查是否已有备份表(幂等)
|
||||
backup_exists = conn.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='checkins_daily_backup'").fetchone()
|
||||
if not backup_exists:
|
||||
conn.execute("ALTER TABLE checkins RENAME TO checkins_daily_backup")
|
||||
# 重新创建 checkins 表(结构不变,date 语义变为周号)
|
||||
conn.execute('''
|
||||
CREATE TABLE IF NOT EXISTS checkins (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
date TEXT UNIQUE NOT NULL,
|
||||
data TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL
|
||||
)
|
||||
''')
|
||||
# 聚合日数据到周
|
||||
if not backup_exists:
|
||||
_aggregate_daily_to_weekly(conn)
|
||||
|
||||
# ── 将来加字段/改表在此扩展 ──
|
||||
# if current < 2:
|
||||
# conn.execute('ALTER TABLE checkins ADD COLUMN tags TEXT DEFAULT ""')
|
||||
# # 可选:对已有行做数据补全
|
||||
# conn.execute("UPDATE checkins SET tags = '[]' WHERE tags IS NULL")
|
||||
|
||||
# ── 写入最新版本号 ──
|
||||
_set_schema_version(conn, CURRENT_SCHEMA_VERSION)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
@@ -92,3 +168,146 @@ def get_all_checkins():
|
||||
'updated_at': row['updated_at']
|
||||
})
|
||||
return results
|
||||
|
||||
|
||||
# ── 心愿清单 CRUD ──────────────────────────────────
|
||||
|
||||
def get_wishes():
|
||||
"""获取所有心愿,按 sort_order 排序"""
|
||||
conn = get_conn()
|
||||
rows = conn.execute('SELECT * FROM wishes ORDER BY sort_order').fetchall()
|
||||
conn.close()
|
||||
return [dict(row) for row in rows]
|
||||
|
||||
|
||||
def save_wish(name, quadrant, deadline):
|
||||
"""新增一条心愿"""
|
||||
now = datetime.now().isoformat()
|
||||
conn = get_conn()
|
||||
max_order = conn.execute('SELECT COALESCE(MAX(sort_order), -1) + 1 AS n FROM wishes').fetchone()['n']
|
||||
conn.execute(
|
||||
'INSERT INTO wishes (name, quadrant, deadline, done, sort_order, created_at) VALUES (?, ?, ?, 0, ?, ?)',
|
||||
(name, quadrant, deadline, max_order, now)
|
||||
)
|
||||
conn.commit()
|
||||
wish_id = conn.execute('SELECT last_insert_rowid()').fetchone()[0]
|
||||
conn.close()
|
||||
return wish_id
|
||||
|
||||
|
||||
def update_wish(wish_id, **kwargs):
|
||||
"""更新心愿字段"""
|
||||
allowed = ['name', 'quadrant', 'deadline', 'done']
|
||||
updates = {k: v for k, v in kwargs.items() if k in allowed}
|
||||
if not updates:
|
||||
return
|
||||
conn = get_conn()
|
||||
sets = ', '.join(f'{k} = ?' for k in updates)
|
||||
vals = list(updates.values()) + [wish_id]
|
||||
conn.execute(f'UPDATE wishes SET {sets} WHERE id = ?', vals)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
|
||||
def delete_wish(wish_id):
|
||||
"""删除心愿"""
|
||||
conn = get_conn()
|
||||
conn.execute('DELETE FROM wishes WHERE id = ?', (wish_id,))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
|
||||
def reorder_wishes(order_list):
|
||||
"""批量更新排序:order_list = [id1, id2, ...]"""
|
||||
conn = get_conn()
|
||||
for idx, wid in enumerate(order_list):
|
||||
conn.execute('UPDATE wishes SET sort_order = ? WHERE id = ?', (idx, wid))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
|
||||
def get_weeks_list():
|
||||
"""返回所有已有打卡记录的周号列表"""
|
||||
conn = get_conn()
|
||||
rows = conn.execute('SELECT DISTINCT date FROM checkins ORDER BY date').fetchall()
|
||||
conn.close()
|
||||
return [r['date'] for r in rows]
|
||||
|
||||
|
||||
def get_daily_backup(week_str):
|
||||
"""获取某周的原始日记录(从备份表)"""
|
||||
from datetime import datetime as _dt, timedelta
|
||||
if '-W' not in week_str:
|
||||
return []
|
||||
year_part, week_part = week_str.split('-W')
|
||||
try:
|
||||
year = int(year_part)
|
||||
week = int(week_part)
|
||||
except (ValueError, IndexError):
|
||||
return []
|
||||
jan1 = _dt(year, 1, 1)
|
||||
delta = timedelta(days=(week - 1) * 7 - jan1.weekday())
|
||||
monday = jan1 + delta
|
||||
dates = [monday.strftime('%Y-%m-%d')]
|
||||
for i in range(1, 7):
|
||||
dates.append((monday + timedelta(days=i)).strftime('%Y-%m-%d'))
|
||||
conn = get_conn()
|
||||
placeholders = ','.join('?' for _ in dates)
|
||||
exists = conn.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='checkins_daily_backup'").fetchone()
|
||||
if not exists:
|
||||
conn.close()
|
||||
return []
|
||||
rows = conn.execute(
|
||||
f"SELECT date, data FROM checkins_daily_backup WHERE date IN ({placeholders}) ORDER BY date",
|
||||
dates
|
||||
).fetchall()
|
||||
conn.close()
|
||||
results = []
|
||||
for row in rows:
|
||||
results.append({'date': row['date'], 'data': json.loads(row['data'])})
|
||||
return results
|
||||
|
||||
|
||||
def _aggregate_daily_to_weekly(conn):
|
||||
"""将 checkins_daily_backup 的日数据聚合为周数据,写入 checkins"""
|
||||
from datetime import datetime as _dt
|
||||
rows = conn.execute('SELECT date, data FROM checkins_daily_backup ORDER BY date').fetchall()
|
||||
weekly = {}
|
||||
for row in rows:
|
||||
try:
|
||||
d = _dt.strptime(row['date'], '%Y-%m-%d')
|
||||
except ValueError:
|
||||
continue
|
||||
iso_year, iso_week, _ = d.isocalendar()
|
||||
week_key = f"{iso_year}-W{iso_week:02d}"
|
||||
if week_key not in weekly:
|
||||
weekly[week_key] = {'morning': [], 'evening': [], 'study': []}
|
||||
data = json.loads(row['data'])
|
||||
for mi in data.get('morning', []):
|
||||
text = mi if isinstance(mi, str) else mi.get('text', '')
|
||||
if text:
|
||||
existing_texts = {x if isinstance(x, str) else x.get('text', '') for x in weekly[week_key]['morning']}
|
||||
if text not in existing_texts:
|
||||
weekly[week_key]['morning'].append(mi)
|
||||
for ei in data.get('evening', []):
|
||||
mst = ei.get('mistake', '') if isinstance(ei, dict) else ''
|
||||
if mst:
|
||||
existing = {x.get('mistake', '') if isinstance(x, dict) else x for x in weekly[week_key]['evening']}
|
||||
if mst not in existing:
|
||||
weekly[week_key]['evening'].append(ei if isinstance(ei, dict) else {'mistake': ei, 'improvement': ''})
|
||||
existing_names = {}
|
||||
for si in weekly[week_key]['study']:
|
||||
nm = si.get('name', '') if isinstance(si, dict) else str(si)
|
||||
if nm:
|
||||
existing_names[nm] = si
|
||||
for si in data.get('study', []):
|
||||
nm = si.get('name', '') if isinstance(si, dict) else str(si)
|
||||
if nm and nm not in existing_names:
|
||||
weekly[week_key]['study'].append(si)
|
||||
existing_names[nm] = si
|
||||
now = _dt.now().isoformat()
|
||||
for week_key in sorted(weekly.keys()):
|
||||
conn.execute(
|
||||
'INSERT INTO checkins (date, data, created_at, updated_at) VALUES (?, ?, ?, ?)',
|
||||
(week_key, json.dumps(weekly[week_key], ensure_ascii=False), now, now)
|
||||
)
|
||||
|
||||
13
deploy.sh
13
deploy.sh
@@ -1,6 +1,9 @@
|
||||
#!/bin/bash
|
||||
# ziwei-power 一键部署脚本
|
||||
# 用法: bash deploy.sh [port]
|
||||
#
|
||||
# 首次运行: 自动生成 .env (SECRET_KEY),之后不变
|
||||
# 多 worker 安全: 所有 worker 共享同一密钥
|
||||
|
||||
set -e
|
||||
|
||||
@@ -30,7 +33,15 @@ fi
|
||||
echo "安装依赖..."
|
||||
venv/bin/pip install -q -r requirements.txt
|
||||
|
||||
# 3. 自动建表(首次运行)
|
||||
# 3. 生成/读取固定 SECRET_KEY(多 worker 共享)
|
||||
if [ ! -f ".env" ]; then
|
||||
echo "生成 SECRET_KEY..."
|
||||
python3 -c "import os; print('SECRET_KEY=' + os.urandom(24).hex())" > .env
|
||||
fi
|
||||
set -a; source .env; set +a
|
||||
export SECRET_KEY
|
||||
|
||||
# 4. 自动建表(首次运行)
|
||||
echo "初始化数据库..."
|
||||
venv/bin/python -c "
|
||||
from database import init_db
|
||||
|
||||
821
static/app.js
821
static/app.js
File diff suppressed because it is too large
Load Diff
801
static/style.css
801
static/style.css
@@ -18,7 +18,7 @@
|
||||
--radius-sm: 8px;
|
||||
--shadow: 0 1px 2px rgba(0,0,0,0.04), 0 2px 8px rgba(74,108,247,0.05);
|
||||
--shadow-hover: 0 2px 6px rgba(0,0,0,0.04), 0 6px 18px rgba(74,108,247,0.08);
|
||||
--sidebar-w: 280px;
|
||||
--sidebar-w: 100px;
|
||||
}
|
||||
|
||||
* { margin:0; padding:0; box-sizing:border-box; }
|
||||
@@ -66,14 +66,29 @@ body {
|
||||
|
||||
.sidebar-user {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 20px 20px 16px;
|
||||
gap: 8px;
|
||||
padding: 24px 12px 16px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.sidebar-user .user-name {
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sidebar-user .btn-logout-icon {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
.user-avatar {
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 50%;
|
||||
background: var(--primary);
|
||||
color: #FFF;
|
||||
@@ -131,6 +146,10 @@ body {
|
||||
gap: 8px;
|
||||
padding: 0 20px 20px;
|
||||
}
|
||||
.daily-sidebar .sidebar-stats {
|
||||
padding: 0;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
background: var(--bg);
|
||||
@@ -155,6 +174,45 @@ body {
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
/* ═══════════════════════════════════════════
|
||||
Sidebar Dark Theme(左侧导航栏专属)
|
||||
═══════════════════════════════════════════ */
|
||||
.sidebar {
|
||||
background: linear-gradient(180deg, #1E293B 0%, #0F172A 100%);
|
||||
border-right: 1px solid #334155;
|
||||
}
|
||||
.sidebar .user-name {
|
||||
color: #94A3B8;
|
||||
}
|
||||
.sidebar .user-avatar {
|
||||
background: #4F46E5;
|
||||
color: #FFF;
|
||||
}
|
||||
.sidebar .btn-logout-icon {
|
||||
color: #64748B;
|
||||
}
|
||||
.sidebar .btn-logout-icon:hover {
|
||||
background: rgba(248,113,113,0.15);
|
||||
color: #FCA5A5;
|
||||
}
|
||||
.sidebar .nav-item {
|
||||
color: #94A3B8;
|
||||
}
|
||||
.sidebar .nav-item:hover {
|
||||
background: rgba(99,102,241,0.08);
|
||||
color: #E2E8F0;
|
||||
}
|
||||
.sidebar .nav-item .icon-md {
|
||||
color: #6366F1;
|
||||
}
|
||||
.sidebar .nav-item:hover .icon-md { color: #818CF8; }
|
||||
.sidebar .nav-item.active {
|
||||
background: rgba(99,102,241,0.15);
|
||||
color: #FFF;
|
||||
border: 1px solid rgba(99,102,241,0.3);
|
||||
}
|
||||
.sidebar .nav-item.active .icon-md { color: #818CF8; }
|
||||
|
||||
/* ═══════════════════════════════════════════
|
||||
Calendar Widget
|
||||
═══════════════════════════════════════════ */
|
||||
@@ -162,6 +220,73 @@ body {
|
||||
.calendar-widget {
|
||||
padding: 0 16px 12px;
|
||||
}
|
||||
.calendar-widget.inline {
|
||||
margin: 0 0 16px;
|
||||
padding: 12px 0;
|
||||
border: 1.5px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
background: var(--card);
|
||||
}
|
||||
.calendar-widget.inline .cal-header {
|
||||
padding: 0 14px 8px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.cal-nav-group { display: flex; gap: 4px; }
|
||||
.cal-nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
background: var(--card);
|
||||
cursor: pointer;
|
||||
color: var(--text-dim);
|
||||
}
|
||||
.cal-nav:hover { background: var(--bg); color: var(--text); }
|
||||
/* 月份翻页行 */
|
||||
.cal-month-header {
|
||||
padding: 4px 14px 8px;
|
||||
}
|
||||
.cal-month-header .cal-month-label {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
/* 周选择 */
|
||||
.cal-weeks {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 8px;
|
||||
padding: 8px 14px 10px;
|
||||
}
|
||||
.cal-week-cell {
|
||||
height: 42px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
border-radius: 8px;
|
||||
color: var(--text-dim);
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
border: 1.5px solid var(--border);
|
||||
background: var(--card);
|
||||
}
|
||||
.cal-week-cell:hover { border-color: var(--primary); color: var(--primary); }
|
||||
.cal-week-cell.pass { background: var(--success-light); border-color: var(--success); color: var(--success); }
|
||||
.cal-week-cell.fail { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }
|
||||
.cal-week-cell.today { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
|
||||
.cal-week-cell.selected { background: var(--primary); color: #FFF; border-color: var(--primary); }
|
||||
|
||||
/* 旧样式清理 */
|
||||
.cal-week-list { display: none; }
|
||||
.cal-week-cell .wk-num, .cal-week-cell .wk-dot { display: none; }
|
||||
|
||||
.cal-header {
|
||||
display: flex;
|
||||
@@ -207,59 +332,86 @@ body {
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.cal-grid {
|
||||
.cal-week-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(7, 1fr);
|
||||
gap: 3px;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 6px 4px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.cal-cell {
|
||||
aspect-ratio: 1;
|
||||
.cal-week-cell {
|
||||
aspect-ratio: 1.4;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 12px;
|
||||
font-size: 10px;
|
||||
font-weight: 500;
|
||||
border-radius: 6px;
|
||||
color: var(--text-dim);
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
border: 1.5px solid var(--border);
|
||||
background: var(--card);
|
||||
padding: 2px 0;
|
||||
position: relative;
|
||||
border: 1.5px solid transparent;
|
||||
}
|
||||
|
||||
.cal-cell:hover {
|
||||
.cal-week-cell:hover {
|
||||
background: var(--primary-light);
|
||||
color: var(--primary);
|
||||
border-color: var(--primary);
|
||||
}
|
||||
|
||||
.cal-cell.other-month {
|
||||
color: var(--border);
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.cal-cell.other-month:hover {
|
||||
.cal-week-cell .wk-num { font-weight: 600; line-height: 1; }
|
||||
.cal-week-cell .wk-dot {
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
border-radius: 50%;
|
||||
background: transparent;
|
||||
border-color: transparent;
|
||||
color: var(--border);
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.cal-cell.today {
|
||||
font-weight: 700;
|
||||
color: var(--primary);
|
||||
.cal-week-cell.pass {
|
||||
background: var(--success-light);
|
||||
border-color: var(--success);
|
||||
color: var(--success);
|
||||
}
|
||||
.cal-week-cell.pass .wk-dot { background: var(--success); }
|
||||
|
||||
.cal-week-cell.fail {
|
||||
background: var(--danger-light);
|
||||
border-color: var(--danger);
|
||||
color: var(--danger);
|
||||
}
|
||||
.cal-week-cell.fail .wk-dot { background: var(--danger); }
|
||||
|
||||
.cal-week-cell.today {
|
||||
border-color: var(--primary);
|
||||
background: var(--primary-light);
|
||||
font-weight: 700;
|
||||
box-shadow: 0 0 0 2px var(--primary-light);
|
||||
}
|
||||
|
||||
.cal-cell.selected {
|
||||
font-weight: 600;
|
||||
color: var(--primary-dark);
|
||||
border-color: var(--primary-dark);
|
||||
background: #DDE3FD;
|
||||
.cal-week-cell.selected {
|
||||
background: var(--primary);
|
||||
color: #FFF;
|
||||
border-color: var(--primary);
|
||||
}
|
||||
.cal-week-cell.selected .wk-dot { background: #FFF; }
|
||||
|
||||
/* 月份标识 */
|
||||
.cal-week-cell.month-start::before {
|
||||
content: attr(data-month);
|
||||
position: absolute;
|
||||
top: -10px;
|
||||
left: 0;
|
||||
font-size: 9px;
|
||||
color: var(--text-muted);
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.cal-cell.selected.today {
|
||||
/* 保留旧 cal-cell 样式(由月历代码生成,但现已不使用) */
|
||||
.cal-grid { display: none; }
|
||||
font-weight: 700;
|
||||
color: #FFF;
|
||||
border-color: var(--primary-dark);
|
||||
@@ -332,34 +484,45 @@ body {
|
||||
|
||||
.nav-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 14px;
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 13px;
|
||||
gap: 4px;
|
||||
padding: 10px 4px;
|
||||
border-radius: var(--radius);
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
color: var(--text-dim);
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
transition: all 0.15s;
|
||||
margin-bottom: 4px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.nav-label { line-height: 1.2; }
|
||||
|
||||
.nav-item:hover {
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.nav-item .icon-md {
|
||||
flex-shrink: 0;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
color: var(--text-muted);
|
||||
transition: color 0.15s;
|
||||
}
|
||||
.nav-item:hover .icon-md { color: var(--primary); }
|
||||
|
||||
.nav-item.active {
|
||||
background: var(--primary-light);
|
||||
color: var(--primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
.nav-item.active .icon-md { color: var(--primary); }
|
||||
|
||||
.nav-item .icon-sm {
|
||||
flex-shrink: 0;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
.icon-md { width: 20px; height: 20px; flex-shrink: 0; }
|
||||
|
||||
/* ── Sidebar Footer ── */
|
||||
|
||||
@@ -428,6 +591,12 @@ body {
|
||||
letter-spacing: -0.3px;
|
||||
}
|
||||
|
||||
.panel-header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.check-date-input {
|
||||
padding: 8px 14px;
|
||||
border: 1.5px solid var(--border);
|
||||
@@ -446,33 +615,78 @@ body {
|
||||
}
|
||||
|
||||
/* ═══════════════════════════════════════════
|
||||
Daily Grid — 三栏
|
||||
Daily Panel — 左右两栏布局
|
||||
═══════════════════════════════════════════ */
|
||||
|
||||
.daily-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
.daily-layout {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
/* 左侧栏 */
|
||||
.daily-sidebar {
|
||||
width: 200px;
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.daily-sidebar .sidebar-stats {
|
||||
padding: 0;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.daily-sidebar .stat-item {
|
||||
background: var(--card);
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.daily-sidebar .calendar-widget.inline {
|
||||
margin: 0;
|
||||
padding: 14px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
background: var(--card);
|
||||
}
|
||||
|
||||
/* 右侧主区 */
|
||||
.daily-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* 立志 — 左上 */
|
||||
.card-morning {
|
||||
grid-column: 1;
|
||||
grid-row: 1;
|
||||
.daily-tabs {
|
||||
display: flex;
|
||||
gap: 0;
|
||||
border-bottom: 1.5px solid var(--border);
|
||||
}
|
||||
.daily-tab {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 8px 18px;
|
||||
border: none;
|
||||
background: none;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: var(--text-dim);
|
||||
cursor: pointer;
|
||||
border-bottom: 2px solid transparent;
|
||||
margin-bottom: -1.5px;
|
||||
transition: all 0.15s;
|
||||
font-family: inherit;
|
||||
}
|
||||
.daily-tab:hover { color: var(--text); }
|
||||
.daily-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
|
||||
|
||||
/* 改过 — 左下 */
|
||||
.card-evening {
|
||||
grid-column: 1;
|
||||
grid-row: 2;
|
||||
}
|
||||
|
||||
/* 勤学 — 右列跨2行 */
|
||||
.card-study {
|
||||
grid-column: 2;
|
||||
grid-row: 1 / 3;
|
||||
}
|
||||
.daily-grid { display: block; }
|
||||
.card.daily-card { display: none; }
|
||||
.card.daily-card.active { display: flex; }
|
||||
|
||||
/* ── Cards ── */
|
||||
|
||||
@@ -535,6 +749,29 @@ body {
|
||||
color: var(--primary);
|
||||
}
|
||||
|
||||
/* 日历同步按钮 */
|
||||
.btn-cal-sync {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 8px 14px;
|
||||
border: 1.5px solid var(--border);
|
||||
background: var(--card);
|
||||
color: var(--text-dim);
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
flex-shrink: 0;
|
||||
font-family: inherit;
|
||||
}
|
||||
.btn-cal-sync:hover {
|
||||
border-color: var(--primary);
|
||||
color: var(--primary);
|
||||
background: var(--primary-light);
|
||||
}
|
||||
|
||||
/* 编辑模式下才显示的元素 */
|
||||
.edit-only { display: none; }
|
||||
.card.editing .edit-only { display: flex; }
|
||||
@@ -615,9 +852,13 @@ body {
|
||||
.btn-del:hover { background: var(--danger-light); }
|
||||
.btn-del .icon-sm { width: 16px; height: 16px; }
|
||||
|
||||
/* 责善改过 横排双输入 */
|
||||
/* 责善改过 — 简洁分割线风格 */
|
||||
|
||||
.evening-row {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 0 0 12px;
|
||||
margin-bottom: 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
@@ -626,42 +867,17 @@ body {
|
||||
.evening-row:last-child {
|
||||
border-bottom: none;
|
||||
margin-bottom: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.evening-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 8px;
|
||||
.evening-row .btn-del {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.evening-header .idx {
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.mistake-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.mistake-row .col {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.mistake-row .col label {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
font-weight: 500;
|
||||
padding-left: 2px;
|
||||
}
|
||||
|
||||
.mistake-row input[type="text"] {
|
||||
.evening-row input[type="text"] {
|
||||
width: 100%;
|
||||
padding: 9px 12px;
|
||||
border: 1.5px solid var(--border);
|
||||
@@ -671,8 +887,10 @@ body {
|
||||
color: var(--text);
|
||||
background: var(--bg);
|
||||
transition: border-color 0.2s, background 0.2s;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.mistake-row input[type="text"]:focus {
|
||||
|
||||
.evening-row input[type="text"]:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary);
|
||||
background: var(--card);
|
||||
@@ -1080,6 +1298,304 @@ body {
|
||||
.toast.error { background: var(--danger); color: #FFF; }
|
||||
.toast.info { background: var(--primary); color: #FFF; }
|
||||
|
||||
/* ═══════════════════════════════════════════
|
||||
Sync Modal
|
||||
═══════════════════════════════════════════ */
|
||||
|
||||
.sync-modal-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0,0,0,0.4);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 9998;
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
.sync-modal {
|
||||
background: var(--card);
|
||||
border-radius: var(--radius);
|
||||
width: 90%;
|
||||
max-width: 560px;
|
||||
max-height: 80vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow: 0 8px 40px rgba(0,0,0,0.15);
|
||||
overflow: hidden;
|
||||
}
|
||||
.sync-modal-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.sync-modal-header h3 {
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
}
|
||||
.sync-modal-close {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 22px;
|
||||
color: var(--text-muted);
|
||||
cursor: pointer;
|
||||
padding: 0 4px;
|
||||
line-height: 1;
|
||||
}
|
||||
.sync-modal-loading {
|
||||
padding: 40px 20px;
|
||||
text-align: center;
|
||||
color: var(--text-dim);
|
||||
font-size: 14px;
|
||||
}
|
||||
.sync-spinner {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border: 3px solid var(--border);
|
||||
border-top-color: var(--primary);
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
margin: 0 auto 14px;
|
||||
}
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
.sync-modal-results {
|
||||
padding: 16px 20px;
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
}
|
||||
.sync-summary {
|
||||
font-size: 14px;
|
||||
color: var(--text);
|
||||
margin-bottom: 14px;
|
||||
padding: 10px 14px;
|
||||
background: var(--primary-light);
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
.sync-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
.sync-day {
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-sm);
|
||||
overflow: hidden;
|
||||
}
|
||||
.sync-day-header {
|
||||
background: var(--bg);
|
||||
padding: 6px 12px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--text-dim);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.sync-event {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
font-size: 13px;
|
||||
color: var(--text);
|
||||
}
|
||||
.sync-event + .sync-event { border-top: 1px solid var(--bg); }
|
||||
.sync-event-icon { flex-shrink: 0; }
|
||||
.sync-event-text { flex: 1; }
|
||||
.sync-event-time { font-size: 11px; color: var(--text-muted); margin-left: 6px; }
|
||||
.sync-modal-footer {
|
||||
padding: 12px 20px;
|
||||
border-top: 1px solid var(--border);
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.sync-modal-footer .btn-wish-save {
|
||||
width: auto;
|
||||
padding: 8px 24px;
|
||||
}
|
||||
|
||||
/* ═══════════════════════════════════════════
|
||||
Wishes — 四象限
|
||||
═══════════════════════════════════════════ */
|
||||
|
||||
#panel-wishes.editing .edit-only { display: inline-flex; }
|
||||
#panel-wishes.editing .wish-del { display: inline-flex; }
|
||||
|
||||
.wish-form {
|
||||
background: var(--bg);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 10px 12px;
|
||||
margin-bottom: 12px;
|
||||
max-width: 480px;
|
||||
}
|
||||
.wish-form input[type="text"],
|
||||
.wish-form input[type="date"],
|
||||
.wish-form select {
|
||||
width: 100%;
|
||||
padding: 8px 10px;
|
||||
border: 1.5px solid var(--border);
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
color: var(--text);
|
||||
margin-bottom: 8px;
|
||||
box-sizing: border-box;
|
||||
background: var(--card);
|
||||
}
|
||||
.wish-form input:focus, .wish-form select:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary);
|
||||
box-shadow: 0 0 0 3px rgba(74,108,247,0.08);
|
||||
}
|
||||
.wish-form-row { display: flex; gap: 8px; }
|
||||
.wish-form-row select, .wish-form-row input { flex: 1; }
|
||||
.wish-form-actions { display: flex; gap: 8px; }
|
||||
.btn-wish-save {
|
||||
flex: 1; padding: 8px; border: none; background: var(--primary); color: #FFF;
|
||||
border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
|
||||
cursor: pointer; font-family: inherit;
|
||||
}
|
||||
.btn-wish-save:hover { background: var(--primary-dark); }
|
||||
.btn-wish-cancel {
|
||||
flex: 1; padding: 8px; border: 1.5px solid var(--border); background: var(--card);
|
||||
color: var(--text-dim); border-radius: var(--radius-sm); font-size: 13px;
|
||||
cursor: pointer; font-family: inherit;
|
||||
}
|
||||
|
||||
/* 四象限网格 */
|
||||
.quad-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-template-rows: 1fr 1fr;
|
||||
gap: 12px;
|
||||
min-height: 400px;
|
||||
}
|
||||
|
||||
.quad-cell {
|
||||
background: var(--card);
|
||||
border: 1.5px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 12px 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 180px;
|
||||
transition: border-color 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
.quad-cell.drag-over {
|
||||
border-color: var(--primary);
|
||||
box-shadow: 0 0 0 3px rgba(74,108,247,0.10);
|
||||
background: var(--primary-light);
|
||||
}
|
||||
|
||||
.quad-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
margin-bottom: 10px;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.quad-list {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
min-height: 40px;
|
||||
}
|
||||
|
||||
.wish-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 7px 10px;
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--bg);
|
||||
transition: opacity 0.15s, box-shadow 0.15s;
|
||||
}
|
||||
.wish-item:hover { box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
|
||||
.wish-item.dragging { opacity: 0.3; }
|
||||
.wish-item.drag-over {
|
||||
box-shadow: inset 0 0 0 2px var(--primary);
|
||||
background: var(--card);
|
||||
}
|
||||
|
||||
.wish-drag-handle {
|
||||
color: var(--text-muted); cursor: grab; flex-shrink: 0;
|
||||
display: flex; align-items: center;
|
||||
}
|
||||
.wish-drag-handle:active { cursor: grabbing; }
|
||||
|
||||
.wish-check {
|
||||
width: 15px; height: 15px; accent-color: var(--success);
|
||||
flex-shrink: 0; cursor: pointer;
|
||||
}
|
||||
|
||||
.wish-name {
|
||||
flex: 1; font-size: 13px; color: var(--text); min-width: 0;
|
||||
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
}
|
||||
.wish-item.done .wish-name { text-decoration: line-through; color: var(--text-muted); }
|
||||
|
||||
.wish-deadline {
|
||||
font-size: 11px; color: var(--text-dim); white-space: nowrap; flex-shrink: 0;
|
||||
}
|
||||
|
||||
.wish-del { display: none; }
|
||||
.wish-del .icon-xs { width: 13px; height: 13px; }
|
||||
|
||||
/* 内联编辑 */
|
||||
.wish-item.editing {
|
||||
background: var(--card);
|
||||
padding: 8px 10px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.wish-edit-form {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
.wish-edit-form input[type="text"],
|
||||
.wish-edit-form input[type="date"],
|
||||
.wish-edit-form select {
|
||||
width: 100%;
|
||||
padding: 6px 8px;
|
||||
border: 1.5px solid var(--border);
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 12px;
|
||||
font-family: inherit;
|
||||
color: var(--text);
|
||||
background: var(--card);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.wish-edit-form input:focus,
|
||||
.wish-edit-form select:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary);
|
||||
box-shadow: 0 0 0 2px rgba(74,108,247,0.08);
|
||||
}
|
||||
.wish-edit-name { font-weight: 500; }
|
||||
.wish-edit-row { display: flex; gap: 6px; }
|
||||
.wish-edit-row select,
|
||||
.wish-edit-row input { flex: 1; }
|
||||
.wish-edit-actions { display: flex; gap: 6px; }
|
||||
.wish-edit-actions .btn-wish-save,
|
||||
.wish-edit-actions .btn-wish-cancel {
|
||||
flex: 1; padding: 6px; font-size: 12px;
|
||||
}
|
||||
|
||||
.wishes-empty {
|
||||
font-size: 13px; color: var(--text-muted); text-align: center; padding: 32px 0;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.quad-grid { grid-template-columns: 1fr; grid-template-rows: auto; }
|
||||
}
|
||||
|
||||
/* ═══════════════════════════════════════════
|
||||
SVG icons helpers
|
||||
═══════════════════════════════════════════ */
|
||||
@@ -1093,11 +1609,9 @@ body {
|
||||
═══════════════════════════════════════════ */
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.sidebar { width: 240px; min-width: 240px; }
|
||||
:root { --sidebar-w: 240px; }
|
||||
.main-content { padding: 20px 24px; }
|
||||
.daily-grid { grid-template-columns: 1fr; }
|
||||
.card-morning, .card-evening, .card-study { grid-column: 1; grid-row: auto; }
|
||||
.weekly-overview { flex-direction: column; gap: 16px; text-align: center; }
|
||||
.week-days-grid { grid-template-columns: repeat(4, 1fr); }
|
||||
.history-grid { grid-template-columns: 1fr; }
|
||||
@@ -1115,3 +1629,98 @@ body {
|
||||
}
|
||||
.main-content { height: auto; overflow: visible; padding: 16px; }
|
||||
}
|
||||
|
||||
/* ═══════════════════════════════════════════
|
||||
Blueprint Panel
|
||||
═══════════════════════════════════════════ */
|
||||
|
||||
/* Tab 筛选 */
|
||||
.bp-tabs {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
margin-bottom: 20px;
|
||||
border-bottom: 1.5px solid var(--border);
|
||||
padding-bottom: 0;
|
||||
}
|
||||
.bp-tab {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 8px 16px;
|
||||
border: none;
|
||||
background: none;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: var(--text-dim);
|
||||
cursor: pointer;
|
||||
border-bottom: 2px solid transparent;
|
||||
margin-bottom: -1.5px;
|
||||
transition: all 0.15s;
|
||||
font-family: inherit;
|
||||
}
|
||||
.bp-tab .icon-sm { opacity: 0.6; }
|
||||
.bp-tab:hover { color: var(--text); }
|
||||
.bp-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
|
||||
.bp-tab.active .icon-sm { opacity: 1; }
|
||||
|
||||
/* 明细列表 */
|
||||
.bp-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1px;
|
||||
}
|
||||
.bp-list-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 14px;
|
||||
background: var(--card);
|
||||
border-bottom: 0.5px solid var(--border);
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.bp-list-item:hover { background: var(--bg); }
|
||||
.bp-pillar-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.bp-item-pillar {
|
||||
font-size: 12px;
|
||||
color: var(--text-dim);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.bp-item-type {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
padding: 2px 8px;
|
||||
border-radius: 8px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.bp-item-type.morning { background: var(--warning-light); color: #D97706; }
|
||||
.bp-item-type.evening { background: var(--danger-light); color: var(--danger); }
|
||||
.bp-item-type.study { background: var(--success-light); color: var(--success); }
|
||||
.bp-item-text {
|
||||
font-size: 13px;
|
||||
color: var(--text);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.bp-item-note {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
margin-left: 4px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.bp-item-note.evening { color: var(--danger); }
|
||||
.bp-list-empty {
|
||||
font-size: 13px;
|
||||
color: var(--text-muted);
|
||||
text-align: center;
|
||||
padding: 32px 0;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.quad-grid { grid-template-columns: 1fr; grid-template-rows: auto; }
|
||||
}
|
||||
|
||||
@@ -67,4 +67,8 @@
|
||||
<symbol id="icon-pencil" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125"/>
|
||||
</symbol>
|
||||
<!-- 星星 -->
|
||||
<symbol id="icon-star" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M11.48 3.499a.562.562 0 0 1 1.04 0l2.125 5.111a.563.563 0 0 0 .475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 0 0-.182.557l1.285 5.385a.562.562 0 0 1-.84.61l-4.725-2.885a.563.563 0 0 0-.586 0L6.982 20.54a.562.562 0 0 1-.84-.61l1.285-5.386a.562.562 0 0 0-.182-.557l-4.204-3.602a.563.563 0 0 1 .321-.988l5.518-.442a.563.563 0 0 0 .475-.345L11.48 3.5Z"/>
|
||||
</symbol>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 6.3 KiB |
@@ -6,12 +6,34 @@
|
||||
<title>紫微 · 磁场管理</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||
<script>window.__INITIAL_STATS__ = {{ initial_stats | safe }};</script>
|
||||
<script>window.__INITIAL_WISHES__ = {{ initial_wishes | safe }};</script>
|
||||
</head>
|
||||
<body>
|
||||
{% include "icons.html" %}
|
||||
|
||||
<div id="toast" class="toast"></div>
|
||||
|
||||
<!-- 日历同步弹窗 -->
|
||||
<div class="sync-modal-overlay" id="sync-modal-overlay" style="display:none">
|
||||
<div class="sync-modal">
|
||||
<div class="sync-modal-header">
|
||||
<h3>📅 日历同步</h3>
|
||||
<button class="sync-modal-close" onclick="closeSyncModal()">×</button>
|
||||
</div>
|
||||
<div class="sync-modal-loading" id="sync-loading">
|
||||
<div class="sync-spinner"></div>
|
||||
<p>正在从钉钉同步过去4周~未来4周日程…</p>
|
||||
</div>
|
||||
<div class="sync-modal-results" id="sync-results" style="display:none">
|
||||
<div class="sync-summary" id="sync-summary"></div>
|
||||
<div class="sync-list" id="sync-list"></div>
|
||||
</div>
|
||||
<div class="sync-modal-footer">
|
||||
<button class="btn-wish-save" onclick="closeSyncModal()">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="app-layout">
|
||||
|
||||
<!-- ═══ 左侧边栏 ═══ -->
|
||||
@@ -20,89 +42,105 @@
|
||||
<!-- 用户信息 -->
|
||||
<div class="sidebar-user">
|
||||
<div class="user-avatar">{{ username[0] }}</div>
|
||||
<div class="user-info">
|
||||
<span class="user-name">{{ username }}</span>
|
||||
<span class="user-tag">道阁 · 紫微</span>
|
||||
</div>
|
||||
<span class="user-name">{{ username }}</span>
|
||||
<a href="/logout" class="btn-logout-icon" title="退出登录" onclick="return confirm('确定退出登录?')">
|
||||
<svg class="icon-sm"><use href="#icon-logout"/></svg>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- 统计信息 -->
|
||||
<div class="sidebar-stats" id="sidebar-stats">
|
||||
<div class="stat-item">
|
||||
<span class="stat-num" id="stat-days">--</span>
|
||||
<span class="stat-label">打卡天</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span class="stat-num" id="stat-morning">--</span>
|
||||
<span class="stat-label">立志</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span class="stat-num" id="stat-study">--</span>
|
||||
<span class="stat-label">勤学</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 日历 -->
|
||||
<div class="calendar-widget">
|
||||
<div class="cal-header">
|
||||
<button class="cal-nav" onclick="changeCalMonth(-1)">
|
||||
<svg class="icon-sm"><use href="#icon-chevron-left"/></svg>
|
||||
</button>
|
||||
<span class="cal-month-label" id="cal-month-label">2026年 6月</span>
|
||||
<button class="cal-nav" onclick="changeCalMonth(1)">
|
||||
<svg class="icon-sm"><use href="#icon-chevron-right"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="cal-weekdays">
|
||||
<span>日</span><span>一</span><span>二</span><span>三</span><span>四</span><span>五</span><span>六</span>
|
||||
</div>
|
||||
<div class="cal-grid" id="cal-grid"></div>
|
||||
<div class="cal-legend">
|
||||
<span class="legend-dot pass"></span> 达标
|
||||
<span class="legend-dot fail"></span> 未达标
|
||||
<span class="legend-dot empty"></span> 未打卡
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 功能入口 -->
|
||||
<nav class="sidebar-nav">
|
||||
<a class="nav-item active" data-panel="daily" onclick="switchPanel('daily')">
|
||||
<svg class="icon-sm"><use href="#icon-calendar"/></svg>
|
||||
每日打卡
|
||||
<svg class="icon-md"><use href="#icon-calendar"/></svg>
|
||||
<span class="nav-label">打卡</span>
|
||||
</a>
|
||||
<a class="nav-item" data-panel="weekly" onclick="switchPanel('weekly')">
|
||||
<svg class="icon-sm"><use href="#icon-chart-bar"/></svg>
|
||||
每周评分
|
||||
<svg class="icon-md"><use href="#icon-chart-bar"/></svg>
|
||||
<span class="nav-label">评分</span>
|
||||
</a>
|
||||
<a class="nav-item" data-panel="wishes" onclick="switchPanel('wishes')">
|
||||
<svg class="icon-md"><use href="#icon-star"/></svg>
|
||||
<span class="nav-label">心愿</span>
|
||||
</a>
|
||||
<a class="nav-item" data-panel="history" onclick="switchPanel('history')">
|
||||
<svg class="icon-sm"><use href="#icon-list-bullet"/></svg>
|
||||
历史记录
|
||||
<svg class="icon-md"><use href="#icon-list-bullet"/></svg>
|
||||
<span class="nav-label">记录</span>
|
||||
</a>
|
||||
<a class="nav-item" data-panel="blueprint" onclick="switchPanel('blueprint')">
|
||||
<svg class="icon-md"><use href="#icon-sun"/></svg>
|
||||
<span class="nav-label">蓝图</span>
|
||||
</a>
|
||||
</nav>
|
||||
|
||||
<!-- 底部新建按钮 -->
|
||||
<div class="sidebar-footer">
|
||||
<button class="btn-new-day" onclick="goToday()">
|
||||
<svg class="icon-sm"><use href="#icon-sun"/></svg>
|
||||
回到今天
|
||||
</button>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<!-- ═══ 右侧主内容区 ═══ -->
|
||||
<main class="main-content">
|
||||
|
||||
<!-- ── 每日打卡面板 ── -->
|
||||
<!-- ── 每周打卡面板 ── -->
|
||||
<section class="panel active" id="panel-daily">
|
||||
<div class="panel-header">
|
||||
<h2>每日打卡</h2>
|
||||
<input type="date" id="check-date" class="check-date-input" onchange="loadCheckin()">
|
||||
<h2>每周打卡</h2>
|
||||
<div class="panel-header-right">
|
||||
<input type="week" id="check-date" class="check-date-input" onchange="loadCheckin()">
|
||||
<button class="btn-cal-sync" onclick="syncCalendar()" title="同步钉钉日历">
|
||||
<svg class="icon-sm"><use href="#icon-calendar"/></svg> 日历同步
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="daily-grid">
|
||||
<div class="card card-morning">
|
||||
<div class="daily-layout">
|
||||
<!-- 左侧:统计 + 日历 -->
|
||||
<div class="daily-sidebar">
|
||||
<div class="sidebar-stats" id="sidebar-stats">
|
||||
<div class="stat-item">
|
||||
<span class="stat-num" id="stat-days">--</span>
|
||||
<span class="stat-label">打卡周</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span class="stat-num" id="stat-morning">--</span>
|
||||
<span class="stat-label">立志</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span class="stat-num" id="stat-study">--</span>
|
||||
<span class="stat-label">勤学</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="calendar-widget inline">
|
||||
<div class="cal-header">
|
||||
<button class="cal-nav" onclick="changeCalYear(-1)">
|
||||
<svg class="icon-sm"><use href="#icon-chevron-left"/></svg>
|
||||
</button>
|
||||
<span class="cal-month-label" id="cal-year-label">2026年</span>
|
||||
<button class="cal-nav" onclick="changeCalYear(1)">
|
||||
<svg class="icon-sm"><use href="#icon-chevron-right"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="cal-header cal-month-header">
|
||||
<button class="cal-nav" onclick="changeCalMonth(-1)">
|
||||
<svg class="icon-sm"><use href="#icon-chevron-left"/></svg>
|
||||
</button>
|
||||
<span class="cal-month-label" id="cal-month-label">7月</span>
|
||||
<button class="cal-nav" onclick="changeCalMonth(1)">
|
||||
<svg class="icon-sm"><use href="#icon-chevron-right"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="cal-weeks" id="cal-weeks"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 右侧:Tab + 内容 -->
|
||||
<div class="daily-main">
|
||||
<div class="daily-tabs">
|
||||
<button class="daily-tab active" data-tab="morning" onclick="switchDailyTab(this)">
|
||||
<svg class="icon-sm"><use href="#icon-sun"/></svg> 早间立志
|
||||
</button>
|
||||
<button class="daily-tab" data-tab="evening" onclick="switchDailyTab(this)">
|
||||
<svg class="icon-sm"><use href="#icon-magnifying-glass"/></svg> 责善改过
|
||||
</button>
|
||||
<button class="daily-tab" data-tab="study" onclick="switchDailyTab(this)">
|
||||
<svg class="icon-sm"><use href="#icon-book-open"/></svg> 勤学打卡
|
||||
</button>
|
||||
</div>
|
||||
<div class="daily-grid">
|
||||
<div class="card card-morning daily-card active" data-card="morning">
|
||||
<div class="card-head">
|
||||
<div class="card-head-left">
|
||||
<svg class="icon-h2"><use href="#icon-sun"/></svg>
|
||||
@@ -112,13 +150,13 @@
|
||||
<svg class="icon-sm"><use href="#icon-pencil"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
<p class="card-desc">今天最重要的 1~3 件事</p>
|
||||
<p class="card-desc">本周最重要的 1~3 件事</p>
|
||||
<div id="morning-list"></div>
|
||||
<button class="btn-add edit-only" onclick="addMorning()">
|
||||
<svg class="icon-sm"><use href="#icon-plus"/></svg> 增加一条
|
||||
</button>
|
||||
</div>
|
||||
<div class="card card-evening">
|
||||
<div class="card card-evening daily-card" data-card="evening">
|
||||
<div class="card-head">
|
||||
<div class="card-head-left">
|
||||
<svg class="icon-h2"><use href="#icon-magnifying-glass"/></svg>
|
||||
@@ -128,21 +166,23 @@
|
||||
<svg class="icon-sm"><use href="#icon-pencil"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
<p class="card-desc">今天犯的错 & 改进方案(最多5条)</p>
|
||||
<p class="card-desc">本周反思改正(最多5条)</p>
|
||||
<div id="evening-list"></div>
|
||||
<button class="btn-add edit-only" onclick="addEvening()">
|
||||
<svg class="icon-sm"><use href="#icon-plus"/></svg> 增加一条
|
||||
</button>
|
||||
</div>
|
||||
<div class="card card-study">
|
||||
<div class="card card-study daily-card" data-card="study">
|
||||
<div class="card-head">
|
||||
<svg class="icon-h2"><use href="#icon-book-open"/></svg>
|
||||
<h3>勤学打卡</h3>
|
||||
</div>
|
||||
<p class="card-desc">今日修行清单</p>
|
||||
<p class="card-desc">本周修行清单</p>
|
||||
<div id="study-list"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /daily-main -->
|
||||
</div><!-- /daily-layout -->
|
||||
</section>
|
||||
|
||||
<!-- ── 每周评分面板 ── -->
|
||||
@@ -188,6 +228,81 @@
|
||||
<div id="history-grid" class="history-grid"></div>
|
||||
</section>
|
||||
|
||||
<!-- ── 心愿清单面板 ── -->
|
||||
<section class="panel" id="panel-wishes">
|
||||
<div class="panel-header">
|
||||
<h2>心愿清单</h2>
|
||||
<button class="btn-edit-toggle" id="wishes-edit-toggle" onclick="toggleWishesEdit(this)" title="编辑">
|
||||
<svg class="icon-sm"><use href="#icon-pencil"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
<!-- 新增表单 -->
|
||||
<div class="wish-form" id="wish-form" style="display:none">
|
||||
<input type="text" id="wish-name" placeholder="心愿名称…" maxlength="50">
|
||||
<div class="wish-form-row">
|
||||
<select id="wish-quadrant">
|
||||
<option value="重要紧急">重要紧急</option>
|
||||
<option value="重要不紧急" selected>重要不紧急</option>
|
||||
<option value="紧急不重要">紧急不重要</option>
|
||||
<option value="不紧急不重要">不紧急不重要</option>
|
||||
</select>
|
||||
<input type="date" id="wish-deadline">
|
||||
</div>
|
||||
<div class="wish-form-actions">
|
||||
<button class="btn-wish-save" onclick="addWish()">添加</button>
|
||||
<button class="btn-wish-cancel" onclick="hideWishForm()">取消</button>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn-add edit-only" id="wishes-add-btn" onclick="showWishForm()" style="margin-bottom:16px">
|
||||
<svg class="icon-sm"><use href="#icon-plus"/></svg> 新增心愿
|
||||
</button>
|
||||
<!-- 四象限网格 -->
|
||||
<div class="quad-grid">
|
||||
<div class="quad-cell" data-quadrant="重要紧急" id="quad-重要紧急">
|
||||
<div class="quad-title">重要 & 紧急</div>
|
||||
<div class="quad-list" id="quad-list-重要紧急"></div>
|
||||
</div>
|
||||
<div class="quad-cell" data-quadrant="重要不紧急" id="quad-重要不紧急">
|
||||
<div class="quad-title">重要 & 不紧急</div>
|
||||
<div class="quad-list" id="quad-list-重要不紧急"></div>
|
||||
</div>
|
||||
<div class="quad-cell" data-quadrant="紧急不重要" id="quad-紧急不重要">
|
||||
<div class="quad-title">紧急 & 不重要</div>
|
||||
<div class="quad-list" id="quad-list-紧急不重要"></div>
|
||||
</div>
|
||||
<div class="quad-cell" data-quadrant="不紧急不重要" id="quad-不紧急不重要">
|
||||
<div class="quad-title">不紧急 & 不重要</div>
|
||||
<div class="quad-list" id="quad-list-不紧急不重要"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wishes-empty" id="wishes-empty" style="display:none">暂无心愿,点击上方按钮添加</div>
|
||||
</section>
|
||||
|
||||
<!-- ── 蓝图面板 ── -->
|
||||
<section class="panel" id="panel-blueprint">
|
||||
<div class="panel-header">
|
||||
<h2>人生蓝图</h2>
|
||||
</div>
|
||||
<!-- Tab 筛选 -->
|
||||
<div class="bp-tabs">
|
||||
<button class="bp-tab active" data-filter="all" onclick="filterBlueprint(this)">
|
||||
<svg class="icon-sm"><use href="#icon-list-bullet"/></svg> 全部
|
||||
</button>
|
||||
<button class="bp-tab" data-filter="morning" onclick="filterBlueprint(this)">
|
||||
<svg class="icon-sm"><use href="#icon-bolt"/></svg> 立志
|
||||
</button>
|
||||
<button class="bp-tab" data-filter="evening" onclick="filterBlueprint(this)">
|
||||
<svg class="icon-sm"><use href="#icon-magnifying-glass"/></svg> 责善
|
||||
</button>
|
||||
<button class="bp-tab" data-filter="study" onclick="filterBlueprint(this)">
|
||||
<svg class="icon-sm"><use href="#icon-book-open"/></svg> 勤学
|
||||
</button>
|
||||
</div>
|
||||
<!-- 明细列表 -->
|
||||
<div class="bp-list" id="bp-list"></div>
|
||||
<div class="bp-list-empty" id="bp-list-empty" style="display:none">暂无记录</div>
|
||||
</section>
|
||||
|
||||
</main>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user