v1.4.2 — 自动归类取代手动选择板块
- 后端关键词自动归类立志/责善/勤学到六板块 - 移除DOM板块选择器,简化UI - 蓝图面板展示各板块立志·责善·勤学统计+详情列表 - 旧数据自动兼容、新数据无需手动选分类
This commit is contained in:
@@ -242,11 +242,7 @@
|
||||
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) {
|
||||
var row = mEls[i].closest('.item-row');
|
||||
var sel = row ? row.querySelector('.morning-pillar') : null;
|
||||
morningItems.push({ text: v, pillar: sel ? sel.value : '' });
|
||||
}
|
||||
if (v) morningItems.push(v);
|
||||
}
|
||||
|
||||
var eveningItems = [];
|
||||
@@ -281,14 +277,12 @@
|
||||
var evening = data.evening || [];
|
||||
var study = data.study || [];
|
||||
|
||||
// 早间立志 (兼容旧纯字符串和新 {text, pillar} 格式)
|
||||
// 早间立志
|
||||
document.getElementById('morning-list').innerHTML = '';
|
||||
if (morning.length === 0) morning = [{text: '', pillar: ''}];
|
||||
if (morning.length === 0) morning = [''];
|
||||
for (var m=0; m<morning.length; m++) {
|
||||
var mi = morning[m];
|
||||
var txt = typeof mi === 'string' ? mi : (mi.text || '');
|
||||
var pil = typeof mi === 'string' ? '' : (mi.pillar || '');
|
||||
addMorningRow(txt, pil);
|
||||
var txt = typeof morning[m] === 'string' ? morning[m] : (morning[m].text || '');
|
||||
addMorningRow(txt);
|
||||
}
|
||||
|
||||
// 责善改过
|
||||
@@ -316,21 +310,15 @@
|
||||
Dynamic Rows
|
||||
================================================================ */
|
||||
|
||||
function addMorningRow(val, pillar) {
|
||||
function addMorningRow(val) {
|
||||
var container = document.getElementById('morning-list');
|
||||
var idx = container.children.length;
|
||||
var text = typeof val === 'string' ? val : (val && val.text ? val.text : '');
|
||||
var pil = pillar || (val && val.pillar ? val.pillar : '');
|
||||
text = text || '';
|
||||
var pillOpts = '<option value="">-- 板块 --</option>';
|
||||
PILLARS.forEach(function(p){
|
||||
pillOpts += '<option value="' + p.name + '"' + (pil === p.name ? ' selected' : '') + '>' + p.emoji + ' ' + p.name + '</option>';
|
||||
});
|
||||
var div = document.createElement('div');
|
||||
div.className = 'item-row';
|
||||
div.innerHTML = '<span class="idx">' + (idx+1) + '.</span>' +
|
||||
'<input type="text" value="' + esc(text) + '" placeholder="今天最重要的一件事…">' +
|
||||
'<select class="morning-pillar">' + pillOpts + '</select>' +
|
||||
'<button class="btn-del" onclick="this.parentElement.remove();renumberMorning()"><svg class="icon-sm"><use href="#icon-x"/></svg></button>';
|
||||
container.appendChild(div);
|
||||
renumberMorning();
|
||||
@@ -1023,17 +1011,28 @@
|
||||
|
||||
function loadBlueprint() {
|
||||
apiGetStats(function(err, data) {
|
||||
if (err || !data || !data.morning_items) return;
|
||||
var counts = {};
|
||||
PILLARS.forEach(function(p){ counts[p.name] = 0; });
|
||||
var total = 0;
|
||||
(data.morning_items || []).forEach(function(item){
|
||||
var name = (typeof item === 'string') ? '' : (item.pillar || '');
|
||||
if (counts[name] !== undefined) { counts[name]++; total++; }
|
||||
});
|
||||
if (err || !data || !data.pillar_breakdown) return;
|
||||
var pb = data.pillar_breakdown;
|
||||
PILLARS.forEach(function(p){
|
||||
var el = document.getElementById('bp-count-' + p.name);
|
||||
if (el) el.textContent = counts[p.name] + ' 条';
|
||||
var info = pb[p.name] || {};
|
||||
var m = info.morning || 0, e = info.evening || 0, s = info.study || 0;
|
||||
if (el) el.textContent = '立志' + m + ' · 责善' + e + ' · 勤学' + s;
|
||||
// 显示详情列表
|
||||
var detailEl = document.getElementById('bp-detail-' + p.name);
|
||||
if (detailEl) {
|
||||
var html = '';
|
||||
(info.morning_items || []).forEach(function(mi){
|
||||
html += '<div class="bp-item" data-type="morning">🥼 ' + esc(mi.text) + '</div>';
|
||||
});
|
||||
(info.evening_items || []).forEach(function(ei){
|
||||
html += '<div class="bp-item" data-type="evening">🔍 ' + esc(ei.mistake || ei.improvement) + '</div>';
|
||||
});
|
||||
(info.study_items || []).forEach(function(si){
|
||||
html += '<div class="bp-item" data-type="study">📚 ' + esc(si.name) + '</div>';
|
||||
});
|
||||
detailEl.innerHTML = html || '<div class="bp-empty">暂无记录</div>';
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1463,19 +1463,23 @@ body {
|
||||
.bp-desc { font-size: 11px; color: var(--text-muted); margin-bottom: 10px; line-height: 1.5; }
|
||||
.bp-count { font-size: 13px; font-weight: 600; color: var(--primary); }
|
||||
|
||||
/* 立志板块选择器 */
|
||||
.morning-pillar {
|
||||
padding: 4px 8px;
|
||||
border: 1.5px solid var(--border);
|
||||
border-radius: var(--radius-sm);
|
||||
.bp-detail {
|
||||
margin-top: 10px;
|
||||
text-align: left;
|
||||
font-size: 11px;
|
||||
font-family: inherit;
|
||||
color: var(--text-dim);
|
||||
background: var(--card);
|
||||
min-width: 100px;
|
||||
cursor: pointer;
|
||||
max-height: 120px;
|
||||
overflow-y: auto;
|
||||
border-top: 1px solid var(--border);
|
||||
padding-top: 8px;
|
||||
}
|
||||
.morning-pillar:hover { border-color: var(--primary); }
|
||||
.bp-item {
|
||||
padding: 2px 0;
|
||||
color: var(--text-dim);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.bp-empty { color: var(--text-muted); text-align: center; padding: 6px 0; }
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.blueprint-pillars { grid-template-columns: repeat(2, 1fr); }
|
||||
|
||||
Reference in New Issue
Block a user