Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30904723d2 | ||
|
|
07fa69478f | ||
|
|
377d1ba2cf | ||
|
|
f674bb4c66 | ||
|
|
e5d416f89f | ||
|
|
e09883a33f | ||
|
|
55dc83ce83 | ||
|
|
ae817fe8f9 | ||
|
|
9e296e59e6 | ||
|
|
3f1becd374 | ||
|
|
b5d7720e52 | ||
|
|
caec0196bb |
15
app.py
15
app.py
@@ -427,7 +427,20 @@ def api_calendar_sync_all():
|
||||
summary = (evt.get('summary') or '').strip()
|
||||
if not summary:
|
||||
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', '')
|
||||
if loc:
|
||||
text += f" @{loc}"
|
||||
|
||||
129
static/app.js
129
static/app.js
@@ -241,10 +241,19 @@
|
||||
|
||||
function buildData() {
|
||||
var morningItems = [];
|
||||
var mEls = document.querySelectorAll('#morning-list .item-row input');
|
||||
for (var i=0; i<mEls.length; i++) {
|
||||
var v = mEls[i].value.trim();
|
||||
if (v) morningItems.push(v);
|
||||
var mRows = document.querySelectorAll('#morning-list .item-row');
|
||||
for (var i=0; i<mRows.length; i++) {
|
||||
var input = mRows[i].querySelector('input[type="text"]');
|
||||
var noteEl = mRows[i].querySelector('.item-note-val');
|
||||
var v = input ? input.value.trim() : '';
|
||||
var n = noteEl ? noteEl.value.trim() : '';
|
||||
if (v) morningItems.push(n ? {text: v, note: n} : v);
|
||||
}
|
||||
// 收集日历日程
|
||||
var calEls = document.querySelectorAll('#morning-calendar-list .cal-task-item span:last-child');
|
||||
for (var ci=0; ci<calEls.length; ci++) {
|
||||
var txt = calEls[ci].textContent.trim();
|
||||
if (txt) { morningItems.push(txt); }
|
||||
}
|
||||
|
||||
var eveningItems = [];
|
||||
@@ -275,12 +284,29 @@
|
||||
var evening = data.evening || [];
|
||||
var study = data.study || [];
|
||||
|
||||
// 早间立志
|
||||
// 本周重点:拆分手动任务 vs 日历日程
|
||||
document.getElementById('morning-list').innerHTML = '';
|
||||
document.getElementById('morning-calendar-list').innerHTML = '';
|
||||
var manualItems = [];
|
||||
var calItems = [];
|
||||
if (morning.length === 0) morning = [''];
|
||||
for (var m=0; m<morning.length; m++) {
|
||||
var txt = typeof morning[m] === 'string' ? morning[m] : (morning[m].text || '');
|
||||
addMorningRow(txt);
|
||||
if (txt && txt.trim().startsWith('【')) { calItems.push(txt); }
|
||||
else { manualItems.push(txt); }
|
||||
}
|
||||
if (manualItems.length === 0) manualItems = [''];
|
||||
for (var a=0; a<manualItems.length; a++) { addMorningRow(manualItems[a]); }
|
||||
if (calItems.length > 0) {
|
||||
document.getElementById('morning-calendar').style.display = 'block';
|
||||
for (var b=0; b<calItems.length; b++) {
|
||||
var div = document.createElement('div');
|
||||
div.className = 'cal-task-item';
|
||||
div.innerHTML = '<span class="cal-task-dot">📅</span><span>' + esc(calItems[b]) + '</span>';
|
||||
document.getElementById('morning-calendar-list').appendChild(div);
|
||||
}
|
||||
} else {
|
||||
document.getElementById('morning-calendar').style.display = 'none';
|
||||
}
|
||||
|
||||
// 责善改过
|
||||
@@ -322,15 +348,57 @@
|
||||
var idx = container.children.length;
|
||||
var text = typeof val === 'string' ? val : (val && val.text ? val.text : '');
|
||||
text = text || '';
|
||||
var note = (val && val.note) ? val.note : '';
|
||||
var hasNote = !!note;
|
||||
var div = document.createElement('div');
|
||||
div.className = 'item-row';
|
||||
div.innerHTML = '<span class="idx">' + (idx+1) + '.</span>' +
|
||||
div.draggable = true;
|
||||
div.innerHTML = '<span class="drag-handle" title="拖动排序">⋮⋮</span>' +
|
||||
'<span class="idx">' + (idx+1) + '.</span>' +
|
||||
'<input type="text" value="' + esc(text) + '" placeholder="本周最重要的一件事…">' +
|
||||
'<button class="btn-note-toggle' + (hasNote ? ' has-note' : '') + '" onclick="openNoteModal(this)" title="备注">💬</button>' +
|
||||
'<button class="btn-del" onclick="this.parentElement.remove();renumberMorning()"><svg class="icon-sm"><use href="#icon-x"/></svg></button>';
|
||||
// 隐藏存储备注
|
||||
var noteHidden = document.createElement('input');
|
||||
noteHidden.type = 'hidden';
|
||||
noteHidden.className = 'item-note-val';
|
||||
noteHidden.value = note;
|
||||
div.appendChild(noteHidden);
|
||||
div.addEventListener('dragstart', dragStart);
|
||||
div.addEventListener('dragover', dragOver);
|
||||
div.addEventListener('drop', function(e){ dragDrop.call(this, e, 'morning-list'); });
|
||||
div.addEventListener('dragend', dragEnd);
|
||||
container.appendChild(div);
|
||||
renumberMorning();
|
||||
}
|
||||
|
||||
window.openNoteModal = function(btn) {
|
||||
var row = btn.closest('.item-row');
|
||||
var noteEl = row.querySelector('.item-note-val');
|
||||
var input = row.querySelector('input[type="text"]');
|
||||
var title = input ? input.value.trim() || '未命名任务' : '备注';
|
||||
document.getElementById('note-modal-title').textContent = title;
|
||||
document.getElementById('note-modal-textarea').value = noteEl ? noteEl.value : '';
|
||||
document.getElementById('note-modal').style.display = 'flex';
|
||||
document.getElementById('note-modal').dataset.rowIndex = Array.prototype.indexOf.call(row.parentElement.children, row);
|
||||
};
|
||||
|
||||
window.saveNoteModal = function() {
|
||||
var modal = document.getElementById('note-modal');
|
||||
var row = document.querySelectorAll('#morning-list .item-row')[parseInt(modal.dataset.rowIndex)];
|
||||
var noteEl = row.querySelector('.item-note-val');
|
||||
var btn = row.querySelector('.btn-note-toggle');
|
||||
var val = document.getElementById('note-modal-textarea').value.trim();
|
||||
if (noteEl) noteEl.value = val;
|
||||
if (val) { btn.classList.add('has-note'); } else { btn.classList.remove('has-note'); }
|
||||
modal.style.display = 'none';
|
||||
triggerAutoSave();
|
||||
};
|
||||
|
||||
window.closeNoteModal = function() {
|
||||
document.getElementById('note-modal').style.display = 'none';
|
||||
};
|
||||
|
||||
function renumberMorning() {
|
||||
var rows = document.querySelectorAll('#morning-list .item-row');
|
||||
for (var i=0; i<rows.length; i++) {
|
||||
@@ -345,10 +413,16 @@
|
||||
improve = improve || '';
|
||||
var div = document.createElement('div');
|
||||
div.className = 'evening-row';
|
||||
div.draggable = true;
|
||||
div.innerHTML =
|
||||
'<span class="drag-handle evening-drag" title="拖动排序">⋮⋮</span>' +
|
||||
'<button class="btn-del" onclick="this.parentElement.remove()"><svg class="icon-sm"><use href="#icon-x"/></svg></button>' +
|
||||
'<input type="text" value="' + esc(mistake) + '" placeholder="犯的错误…">' +
|
||||
'<input type="text" value="' + esc(improve) + '" placeholder="改进方案…">';
|
||||
div.addEventListener('dragstart', dragStart);
|
||||
div.addEventListener('dragover', dragOver);
|
||||
div.addEventListener('drop', function(e){ dragDrop.call(this, e, 'evening-list'); });
|
||||
div.addEventListener('dragend', dragEnd);
|
||||
container.appendChild(div);
|
||||
}
|
||||
|
||||
@@ -381,6 +455,41 @@
|
||||
btn.classList.toggle('active', editing);
|
||||
};
|
||||
|
||||
/* ── 拖拽排序 ── */
|
||||
var dragSrc = null;
|
||||
|
||||
function dragStart(e) {
|
||||
dragSrc = this;
|
||||
this.classList.add('dragging');
|
||||
e.dataTransfer.effectAllowed = 'move';
|
||||
}
|
||||
|
||||
function dragOver(e) {
|
||||
e.preventDefault();
|
||||
e.dataTransfer.dropEffect = 'move';
|
||||
if (this !== dragSrc) this.classList.add('drag-over');
|
||||
}
|
||||
|
||||
function dragDrop(e, listId) {
|
||||
e.preventDefault();
|
||||
this.classList.remove('drag-over');
|
||||
if (dragSrc === this) return;
|
||||
var container = document.getElementById(listId);
|
||||
var items = container.querySelectorAll('.' + (dragSrc.classList.contains('evening-row') ? 'evening-row' : 'item-row'));
|
||||
var from = Array.prototype.indexOf.call(items, dragSrc);
|
||||
var to = Array.prototype.indexOf.call(items, this);
|
||||
if (from < to) { container.insertBefore(dragSrc, this.nextSibling); }
|
||||
else { container.insertBefore(dragSrc, this); }
|
||||
if (listId === 'morning-list') renumberMorning();
|
||||
triggerAutoSave();
|
||||
}
|
||||
|
||||
function dragEnd() {
|
||||
this.classList.remove('dragging');
|
||||
document.querySelectorAll('.drag-over').forEach(function(el){ el.classList.remove('drag-over'); });
|
||||
dragSrc = null;
|
||||
}
|
||||
|
||||
window.addStudyItem = function() {
|
||||
var name = prompt('请输入新习惯名称:');
|
||||
if (!name || !name.trim()) return;
|
||||
@@ -458,10 +567,12 @@
|
||||
html += '<div class="sync-day">';
|
||||
html += '<div class="sync-day-header"><span>' + day.date + '</span></div>';
|
||||
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">' +
|
||||
'<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>';
|
||||
});
|
||||
html += '</div>';
|
||||
|
||||
@@ -833,7 +833,6 @@ body {
|
||||
|
||||
/* 编辑模式下才显示的元素 */
|
||||
.edit-only { display: flex; }
|
||||
.btn-edit-toggle:not(#study-edit-toggle) { display: none; }
|
||||
|
||||
/* 默认隐藏删除按钮 */
|
||||
.btn-del { display: none; }
|
||||
@@ -1029,7 +1028,7 @@ body {
|
||||
gap: 5px;
|
||||
width: 100%;
|
||||
padding: 9px;
|
||||
margin-top: auto;
|
||||
margin-top: 12px;
|
||||
border: 1.5px dashed var(--primary);
|
||||
background: var(--primary-light);
|
||||
color: var(--primary);
|
||||
@@ -1461,7 +1460,7 @@ body {
|
||||
.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-event-meta { font-size: 11px; color: var(--text-muted); }
|
||||
.sync-modal-footer {
|
||||
padding: 12px 20px;
|
||||
border-top: 1px solid var(--border);
|
||||
@@ -1800,3 +1799,29 @@ body {
|
||||
#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; }
|
||||
|
||||
/* 编辑模式下显示删除按钮 */
|
||||
.btn-del { display: none; }
|
||||
.card.editing .btn-del { display: inline-flex; }
|
||||
|
||||
/* 本周日程 */
|
||||
.morning-calendar { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
|
||||
.morning-calendar-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
|
||||
.cal-task-item { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; font-size: 13px; color: var(--text-dim); line-height: 1.5; border-bottom: 1px solid var(--bg); }
|
||||
.cal-task-item:last-child { border-bottom: none; }
|
||||
.cal-task-dot { flex-shrink: 0; font-size: 14px; margin-top: 1px; }
|
||||
|
||||
/* 拖拽排序 */
|
||||
.drag-handle { display: none; cursor: grab; color: var(--text-muted); font-size: 14px; user-select: none; padding: 0 4px; line-height: 1; letter-spacing: -2px; }
|
||||
.card.editing .drag-handle { display: block; }
|
||||
.item-row.dragging, .evening-row.dragging { opacity: 0.5; }
|
||||
.item-row.drag-over, .evening-row.drag-over { border-color: var(--primary) !important; background: var(--primary-light); }
|
||||
.evening-drag { position: absolute; left: 6px; top: 8px; }
|
||||
|
||||
/* 任务备注 */
|
||||
.btn-note-toggle { display: inline-flex; background: none; border: none; cursor: pointer; font-size: 14px; padding: 2px 4px; border-radius: 4px; transition: all 0.15s; flex-shrink: 0; }
|
||||
.btn-note-toggle:hover { background: var(--bg); }
|
||||
.btn-note-toggle.has-note { color: var(--primary); }
|
||||
.item-note { display: none; width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; font-family: inherit; color: var(--text); background: var(--bg); resize: vertical; min-height: 28px; box-sizing: border-box; margin-top: 6px; }
|
||||
.item-note:focus { outline: none; border-color: var(--primary); }
|
||||
.item-row { flex-wrap: wrap; }
|
||||
|
||||
@@ -34,6 +34,23 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 备注编辑弹窗 -->
|
||||
<div class="sync-modal-overlay" id="note-modal" style="display:none">
|
||||
<div class="sync-modal" style="max-width:720px">
|
||||
<div class="sync-modal-header">
|
||||
<h3 id="note-modal-title">备注</h3>
|
||||
<button class="sync-modal-close" onclick="closeNoteModal()">×</button>
|
||||
</div>
|
||||
<div style="padding:16px">
|
||||
<textarea id="note-modal-textarea" style="width:100%; min-height:300px; padding:12px; border:1px solid var(--border); border-radius:8px; font-size:14px; font-family:inherit; line-height:1.6; resize:vertical; box-sizing:border-box" placeholder="写点备注…"></textarea>
|
||||
</div>
|
||||
<div class="sync-modal-footer">
|
||||
<button class="btn-wish-cancel" onclick="closeNoteModal()">取消</button>
|
||||
<button class="btn-wish-save" onclick="saveNoteModal()">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="app-layout">
|
||||
|
||||
<!-- ═══ 左侧边栏 ═══ -->
|
||||
@@ -157,6 +174,13 @@
|
||||
<button class="btn-add edit-only" onclick="addMorning()">
|
||||
<svg class="icon-sm"><use href="#icon-plus"/></svg> 增加一条
|
||||
</button>
|
||||
<div class="morning-calendar" id="morning-calendar" style="display:none">
|
||||
<div class="morning-calendar-head">
|
||||
<svg class="icon-sm"><use href="#icon-calendar"/></svg>
|
||||
<span>本周日程</span>
|
||||
</div>
|
||||
<div id="morning-calendar-list"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card card-evening daily-card" data-card="evening">
|
||||
<div class="card-head">
|
||||
|
||||
Reference in New Issue
Block a user