Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e296e59e6 | ||
|
|
3f1becd374 | ||
|
|
b5d7720e52 | ||
|
|
caec0196bb | ||
|
|
d1404765d2 | ||
|
|
e2c97ca1fb | ||
|
|
8188364813 | ||
|
|
b50d8e17e2 | ||
|
|
c70aeff2ed |
15
app.py
15
app.py
@@ -427,7 +427,20 @@ def api_calendar_sync_all():
|
|||||||
summary = (evt.get('summary') or '').strip()
|
summary = (evt.get('summary') or '').strip()
|
||||||
if not summary:
|
if not summary:
|
||||||
continue
|
continue
|
||||||
text = f"【{evt['time']}】{summary}" if evt.get('time') else summary
|
date_str = evt.get('date', '')
|
||||||
|
if date_str:
|
||||||
|
try:
|
||||||
|
parts = date_str.split('-')
|
||||||
|
date_label = f"{int(parts[1])}月{int(parts[2])}日"
|
||||||
|
except:
|
||||||
|
date_label = date_str
|
||||||
|
else:
|
||||||
|
date_label = ''
|
||||||
|
time_str = evt.get('time', '')
|
||||||
|
prefix = f"【{date_label} {time_str}】" if date_label and time_str else \
|
||||||
|
(f"【{date_label}】" if date_label else \
|
||||||
|
(f"【{time_str}】" if time_str else ''))
|
||||||
|
text = f"{prefix}{summary}" if prefix else summary
|
||||||
loc = evt.get('location', '')
|
loc = evt.get('location', '')
|
||||||
if loc:
|
if loc:
|
||||||
text += f" @{loc}"
|
text += f" @{loc}"
|
||||||
|
|||||||
@@ -291,16 +291,25 @@
|
|||||||
addEveningRow(item.mistake || '', item.improvement || '');
|
addEveningRow(item.mistake || '', item.improvement || '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 勤学 — 渲染预设项目并回填状态
|
// 勤学 — 渲染已保存习惯 + 未渲染预设
|
||||||
var studyMap = {};
|
var studyMap = {};
|
||||||
for (var si=0; si<study.length; si++) {
|
for (var si=0; si<study.length; si++) {
|
||||||
studyMap[study[si].name] = study[si];
|
studyMap[study[si].name] = study[si];
|
||||||
}
|
}
|
||||||
|
var rendered = {};
|
||||||
document.getElementById('study-cards').innerHTML = '';
|
document.getElementById('study-cards').innerHTML = '';
|
||||||
|
for (var sk=0; sk<study.length; sk++) {
|
||||||
|
var item = study[sk];
|
||||||
|
if (item.name) {
|
||||||
|
renderStudyCard(item.name, item.count || 0, item.last_checkin_date || '');
|
||||||
|
rendered[item.name] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (var sp=0; sp<PRESET_STUDY_ITEMS.length; sp++) {
|
for (var sp=0; sp<PRESET_STUDY_ITEMS.length; sp++) {
|
||||||
var sName = PRESET_STUDY_ITEMS[sp];
|
var sName = PRESET_STUDY_ITEMS[sp];
|
||||||
var saved = studyMap[sName] || { count: 0 };
|
if (!rendered[sName]) {
|
||||||
renderStudyCard(sName, saved.count || 0, saved.last_checkin_date || '');
|
renderStudyCard(sName, 0, '');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,6 +364,7 @@
|
|||||||
div.className = 'study-card' + (checked ? ' checked' : '');
|
div.className = 'study-card' + (checked ? ' checked' : '');
|
||||||
div.setAttribute('data-last-date', lastDate || '');
|
div.setAttribute('data-last-date', lastDate || '');
|
||||||
div.innerHTML =
|
div.innerHTML =
|
||||||
|
'<button class="study-card-del" onclick="deleteStudyItem(this)" title="删除">×</button>' +
|
||||||
'<div class="study-card-info">' +
|
'<div class="study-card-info">' +
|
||||||
'<span class="study-card-name">' + esc(name) + '</span>' +
|
'<span class="study-card-name">' + esc(name) + '</span>' +
|
||||||
'<span class="study-card-count">' + count + '</span>' +
|
'<span class="study-card-count">' + count + '</span>' +
|
||||||
@@ -363,6 +373,29 @@
|
|||||||
container.appendChild(div);
|
container.appendChild(div);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.toggleStudyEdit = function() {
|
||||||
|
var panel = document.getElementById('panel-daily');
|
||||||
|
var btn = document.getElementById('study-edit-toggle');
|
||||||
|
if (!panel || !btn) return;
|
||||||
|
var editing = panel.classList.toggle('editing-study');
|
||||||
|
btn.classList.toggle('active', editing);
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addStudyItem = function() {
|
||||||
|
var name = prompt('请输入新习惯名称:');
|
||||||
|
if (!name || !name.trim()) return;
|
||||||
|
renderStudyCard(name.trim(), 0, '');
|
||||||
|
triggerAutoSave();
|
||||||
|
};
|
||||||
|
|
||||||
|
window.deleteStudyItem = function(btn) {
|
||||||
|
var card = btn.closest('.study-card');
|
||||||
|
var nameEl = card.querySelector('.study-card-name');
|
||||||
|
if (nameEl && !confirm('确定删除「' + nameEl.textContent + '」?')) return;
|
||||||
|
card.remove();
|
||||||
|
triggerAutoSave();
|
||||||
|
};
|
||||||
|
|
||||||
window.checkinStudy = function(btn) {
|
window.checkinStudy = function(btn) {
|
||||||
var card = btn.closest('.study-card');
|
var card = btn.closest('.study-card');
|
||||||
var today = fmtDate(new Date());
|
var today = fmtDate(new Date());
|
||||||
@@ -425,10 +458,12 @@
|
|||||||
html += '<div class="sync-day">';
|
html += '<div class="sync-day">';
|
||||||
html += '<div class="sync-day-header"><span>' + day.date + '</span></div>';
|
html += '<div class="sync-day-header"><span>' + day.date + '</span></div>';
|
||||||
day.events.forEach(function(e) {
|
day.events.forEach(function(e) {
|
||||||
var timeStr = e.time ? ' (' + e.time + ')' : '';
|
var timeStr = e.time ? e.time : '';
|
||||||
|
var dateStr = e.date || '';
|
||||||
html += '<div class="sync-event">' +
|
html += '<div class="sync-event">' +
|
||||||
'<span class="sync-event-icon">📌</span>' +
|
'<span class="sync-event-icon">📌</span>' +
|
||||||
'<span class="sync-event-text">' + esc(e.summary) + '<span class="sync-event-time">' + esc(timeStr) + '</span></span>' +
|
'<span class="sync-event-text">' + esc(e.summary) + '</span>' +
|
||||||
|
'<span class="sync-event-meta">' + esc(dateStr) + (timeStr ? ' ' + esc(timeStr) : '') + '</span>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
});
|
});
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
|
|||||||
@@ -832,9 +832,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 编辑模式下才显示的元素 */
|
/* 编辑模式下才显示的元素 */
|
||||||
.edit-only { display: none; }
|
.edit-only { display: flex; }
|
||||||
.card.editing .edit-only { display: flex; }
|
|
||||||
.card.editing .btn-del { display: inline-flex; }
|
|
||||||
|
|
||||||
/* 默认隐藏删除按钮 */
|
/* 默认隐藏删除按钮 */
|
||||||
.btn-del { display: none; }
|
.btn-del { display: none; }
|
||||||
@@ -1030,7 +1028,7 @@ body {
|
|||||||
gap: 5px;
|
gap: 5px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 9px;
|
padding: 9px;
|
||||||
margin-top: auto;
|
margin-top: 12px;
|
||||||
border: 1.5px dashed var(--primary);
|
border: 1.5px dashed var(--primary);
|
||||||
background: var(--primary-light);
|
background: var(--primary-light);
|
||||||
color: var(--primary);
|
color: var(--primary);
|
||||||
@@ -1462,7 +1460,7 @@ body {
|
|||||||
.sync-event + .sync-event { border-top: 1px solid var(--bg); }
|
.sync-event + .sync-event { border-top: 1px solid var(--bg); }
|
||||||
.sync-event-icon { flex-shrink: 0; }
|
.sync-event-icon { flex-shrink: 0; }
|
||||||
.sync-event-text { flex: 1; }
|
.sync-event-text { flex: 1; }
|
||||||
.sync-event-time { font-size: 11px; color: var(--text-muted); margin-left: 6px; }
|
.sync-event-meta { font-size: 11px; color: var(--text-muted); }
|
||||||
.sync-modal-footer {
|
.sync-modal-footer {
|
||||||
padding: 12px 20px;
|
padding: 12px 20px;
|
||||||
border-top: 1px solid var(--border);
|
border-top: 1px solid var(--border);
|
||||||
@@ -1784,13 +1782,20 @@ body {
|
|||||||
.quad-grid { grid-template-columns: 1fr; grid-template-rows: auto; }
|
.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-cards { display: flex; flex-direction: column; gap: 8px; }
|
||||||
|
.study-card { position:relative; display:flex; align-items:center; gap:12px; padding:10px 14px; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--card); transition:all 0.15s; }
|
||||||
|
.study-card:hover { border-color:var(--primary); box-shadow:var(--shadow); }
|
||||||
.study-card.checked { border-color:var(--success); background:var(--success-light); }
|
.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-info { display:flex; align-items:center; gap:8px; flex:1; }
|
||||||
.study-card-name { font-size:13px; color:var(--text); font-weight:500; }
|
.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-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; flex-shrink:0; }
|
||||||
.study-card.checked .study-card-count { background:var(--success); color:#FFF; }
|
.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 { padding:5px 12px; 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; }
|
.study-card-btn:hover { background:var(--primary); color:#FFF; }
|
||||||
.study-card-btn.done { background:var(--success-light); color:var(--success); border-color:var(--success); cursor:default; }
|
.study-card-btn.done { background:var(--success-light); color:var(--success); border-color:var(--success); cursor:default; }
|
||||||
|
.study-card-del { display:none; }
|
||||||
|
#panel-daily.editing-study .study-card-del { display:flex; align-items:center; justify-content:center; position:absolute; top:50%; transform:translateY(-50%); right:54px; border:none; background:var(--danger-light); color:var(--danger); cursor:pointer; font-size:14px; width:22px; height:22px; border-radius:50%; line-height:1; }
|
||||||
|
#panel-daily.editing-study .study-card-del:hover { background:var(--danger); color:#FFF; }
|
||||||
|
.edit-only-study { display: none; }
|
||||||
|
#panel-daily.editing-study .edit-only-study { display: flex; }
|
||||||
|
|||||||
@@ -176,11 +176,19 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card card-study daily-card" data-card="study">
|
<div class="card card-study daily-card" data-card="study">
|
||||||
<div class="card-head">
|
<div class="card-head">
|
||||||
<svg class="icon-h2"><use href="#icon-book-open"/></svg>
|
<div class="card-head-left">
|
||||||
<h3>勤学打卡</h3>
|
<svg class="icon-h2"><use href="#icon-book-open"/></svg>
|
||||||
|
<h3>勤学打卡</h3>
|
||||||
|
</div>
|
||||||
|
<button class="btn-edit-toggle" id="study-edit-toggle" onclick="toggleStudyEdit()" title="编辑">
|
||||||
|
<svg class="icon-sm"><use href="#icon-pencil"/></svg>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<p class="card-desc">本周修行清单</p>
|
<p class="card-desc">本周修行清单</p>
|
||||||
<div id="study-cards"></div>
|
<div id="study-cards"></div>
|
||||||
|
<button class="btn-add edit-only-study" onclick="addStudyItem()" style="margin-top:10px">
|
||||||
|
<svg class="icon-sm"><use href="#icon-plus"/></svg> 增加习惯
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div><!-- /daily-main -->
|
</div><!-- /daily-main -->
|
||||||
|
|||||||
Reference in New Issue
Block a user