2 Commits

Author SHA1 Message Date
mac
7b4134a72c v1.2.3 — 修复象限分类刷新丢失
- normalizeQuadrant(): priority→quadrant 回退映射
- 拖拽跨象限 API 调用增加错误提示
- loadWishes 加载时自动规范化 quadrant 字段
2026-06-03 14:55:54 +08:00
mac
13a0e12b34 v1.2.2 — 修复编辑取消按钮无响应
- renderWishes 挂到 window 供内联 onclick 调用
2026-06-03 14:51:03 +08:00

View File

@@ -644,10 +644,19 @@
var wishesLoaded = false;
var QUADRANTS = ['重要紧急', '重要不紧急', '紧急不重要', '不紧急不重要'];
function normalizeQuadrant(w) {
if (QUADRANTS.indexOf(w.quadrant) >= 0) return w.quadrant;
// 老数据回退: priority → quadrant
var map = {'高': '重要紧急', '中': '重要不紧急', '低': '不紧急不重要'};
return map[w.priority] || '重要不紧急';
}
function loadWishes() {
if (wishesLoaded) { renderWishes(); return; }
if (window.__INITIAL_WISHES__) {
wishes = window.__INITIAL_WISHES__;
// 规范化 quadrant
wishes.forEach(function(w){ w.quadrant = normalizeQuadrant(w); });
wishesLoaded = true;
renderWishes();
return;
@@ -670,7 +679,7 @@
QUADRANTS.forEach(function(quadrant) {
var list = document.getElementById('quad-list-' + quadrant);
if (!list) return;
var items = wishes.filter(function(w){ return (w.quadrant || w.priority || '重要不紧急') === quadrant; });
var items = wishes.filter(function(w){ return normalizeQuadrant(w) === quadrant; });
var html = '';
for (var i = 0; i < items.length; i++) {
var w = items[i];
@@ -711,7 +720,7 @@
el.classList.add('editing');
var deadline = w.deadline || '';
var quadOpts = QUADRANTS.map(function(q){
return '<option value="' + q + '"' + (q === (w.quadrant || w.priority || '重要不紧急') ? ' selected' : '') + '>' + q + '</option>';
return '<option value="' + q + '"' + (q === normalizeQuadrant(w) ? ' selected' : '') + '>' + q + '</option>';
}).join('');
el.innerHTML =
'<div class="wish-edit-form">' +
@@ -722,7 +731,7 @@
'</div>' +
'<div class="wish-edit-actions">' +
'<button class="btn-wish-save" onclick="event.stopPropagation();saveEditWish(' + w.id + ', this)">保存</button>' +
'<button class="btn-wish-cancel" onclick="event.stopPropagation();renderWishes()">取消</button>' +
'<button class="btn-wish-cancel" onclick="event.stopPropagation();window.renderWishes()">取消</button>' +
'</div>' +
'</div>';
}
@@ -794,7 +803,7 @@
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({quadrant: targetQuadrant})
});
}).catch(function(){ showToast('保存失败', 'error'); });
}
renderWishes();
saveWishOrder();
@@ -822,7 +831,7 @@
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({quadrant: q})
});
}).catch(function(){ showToast('保存失败', 'error'); });
renderWishes();
}
});
@@ -896,6 +905,8 @@
btn.classList.toggle('active', editing);
};
window.renderWishes = renderWishes;
/* ================================================================
Init
================================================================ */