diff --git a/app.py b/app.py index 8188f03..ec195b2 100644 --- a/app.py +++ b/app.py @@ -136,8 +136,7 @@ def compute_stats(): 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 '', + 'count': si.get('count', 0) if isinstance(si, dict) else 0, 'pillar': pillar }) @@ -149,7 +148,7 @@ def compute_stats(): isinstance(x, str) and x.strip() or isinstance(x, dict) and (x.get('mistake', '') or '').strip() )) - study_count = sum(1 for x in study if x.get('done')) + study_count = sum(1 for x in study if x.get('count', 0) > 0) total_morning += morning_count total_evening += evening_count diff --git a/static/app.js b/static/app.js index d48919e..458af88 100644 --- a/static/app.js +++ b/static/app.js @@ -257,17 +257,13 @@ } var studyItems = []; - var pItems = document.querySelectorAll('#study-list .preset-item'); - for (var k=0; k 0 ? ' checked' : ''); div.innerHTML = - '' + - ''; + '
' + + '' + esc(name) + '' + + '' + count + '' + + '
' + + ''; container.appendChild(div); } - window.togglePresetNote = function(cb) { - var item = cb.closest('.preset-item'); - if (item) { - if (cb.checked) item.classList.add('active'); - else { item.classList.remove('active'); item.querySelector('.preset-note').value = ''; } - } + window.checkinStudy = function(btn) { + var card = btn.closest('.study-card'); + var countEl = card.querySelector('.study-card-count'); + var count = parseInt(countEl.textContent) + 1; + countEl.textContent = count; + if (count > 0) card.classList.add('checked'); triggerAutoSave(); }; function initStudyPresets() { - document.getElementById('study-list').innerHTML = ''; + document.getElementById('study-cards').innerHTML = ''; for (var i=0; i= 3) { showToast('最多 3 条立志', 'error'); return; } addMorningRow(''); }; window.addEvening = function() { @@ -499,7 +492,7 @@ if (lastSavedWeek && lastSavedData !== null && currentStr !== lastSavedData) { var hasContent = currentData.morning.some(function(x){return x && x.trim();}) || currentData.evening.some(function(x){return (x.mistake||'').trim() || (x.improvement||'').trim();}) || - currentData.study.some(function(x){return x.done;}); + currentData.study.some(function(x){return x.count > 0;}); if (hasContent) { apiSaveCheckin(lastSavedWeek, currentData, function(){}); } @@ -1019,7 +1012,7 @@ (info.evening_items || []).forEach(function(ei){ items.push({pillar: p, text: ei.mistake || ei.improvement, improvement: ei.improvement, type: 'evening'}); }); } if (blueprintFilter === 'all' || blueprintFilter === 'study') { - (info.study_items || []).forEach(function(si){ items.push({pillar: p, text: si.name, type: 'study', done: si.done, note: si.note}); }); + (info.study_items || []).forEach(function(si){ items.push({pillar: p, text: si.name, type: 'study', count: si.count}); }); } }); if (items.length === 0) { @@ -1037,7 +1030,7 @@ items.forEach(function(item){ var dot = ''; var extra = ''; - if (item.type === 'study' && item.note) extra = '' + esc(item.note) + ''; + if (item.type === 'study' && item.count > 0) extra = '打卡 ' + item.count + ' 次'; if (item.type === 'evening' && item.improvement) extra = '→ ' + esc(item.improvement) + ''; html += '
' + dot + diff --git a/static/style.css b/static/style.css index 412cebf..2e1f41c 100644 --- a/static/style.css +++ b/static/style.css @@ -1783,3 +1783,13 @@ body { @media (max-width: 900px) { .quad-grid { grid-template-columns: 1fr; grid-template-rows: auto; } } + +/* 勤学打卡卡片 */ +.study-card { display:flex; align-items:center; gap:12px; padding:10px 14px; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--card); margin-bottom:8px; transition:all 0.15s; } +.study-card.checked { border-color:var(--success); background:var(--success-light); } +.study-card-info { flex:1; display:flex; align-items:center; justify-content:space-between; gap:8px; } +.study-card-name { font-size:13px; color:var(--text); font-weight:500; } +.study-card-count { font-size:12px; color:var(--text-muted); font-weight:600; background:var(--bg); border-radius:50%; width:24px; height:24px; display:flex; align-items:center; justify-content:center; } +.study-card.checked .study-card-count { background:var(--success); color:#FFF; } +.study-card-btn { padding:6px 14px; border:1px solid var(--primary); border-radius:var(--radius-sm); background:transparent; color:var(--primary); font-size:12px; font-weight:500; cursor:pointer; transition:all 0.15s; font-family:inherit; white-space:nowrap; } +.study-card-btn:hover { background:var(--primary); color:#FFF; } diff --git a/templates/index.html b/templates/index.html index 59ffc12..db19ddb 100644 --- a/templates/index.html +++ b/templates/index.html @@ -152,7 +152,7 @@
-

本周最重要的 1~3 件事

+

本周最重要的事