Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ea81b3086 | ||
|
|
bafac0bc12 | ||
|
|
1d86d7f736 |
4
app.py
4
app.py
@@ -193,9 +193,9 @@ def api_create_wish():
|
|||||||
name = body.get('name', '').strip()
|
name = body.get('name', '').strip()
|
||||||
if not name:
|
if not name:
|
||||||
return jsonify({'ok': False, 'error': '名称不能为空'}), 400
|
return jsonify({'ok': False, 'error': '名称不能为空'}), 400
|
||||||
priority = body.get('priority', '中')
|
quadrant = body.get('quadrant', '重要不紧急')
|
||||||
deadline = body.get('deadline', '')
|
deadline = body.get('deadline', '')
|
||||||
wid = save_wish(name, priority, deadline)
|
wid = save_wish(name, quadrant, deadline)
|
||||||
return jsonify({'ok': True, 'id': wid})
|
return jsonify({'ok': True, 'id': wid})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
15
database.py
15
database.py
@@ -11,7 +11,7 @@ os.makedirs(DB_DIR, exist_ok=True)
|
|||||||
DB_PATH = os.path.join(DB_DIR, 'ziwei_power.db')
|
DB_PATH = os.path.join(DB_DIR, 'ziwei_power.db')
|
||||||
|
|
||||||
# 当前数据库 schema 版本 —— 改表结构时必须 +1 并补迁移逻辑
|
# 当前数据库 schema 版本 —— 改表结构时必须 +1 并补迁移逻辑
|
||||||
CURRENT_SCHEMA_VERSION = 2
|
CURRENT_SCHEMA_VERSION = 3
|
||||||
|
|
||||||
|
|
||||||
def get_conn():
|
def get_conn():
|
||||||
@@ -69,6 +69,11 @@ def init_db():
|
|||||||
)
|
)
|
||||||
''')
|
''')
|
||||||
|
|
||||||
|
if current < 3:
|
||||||
|
# v3: 优先级改为四象限
|
||||||
|
conn.execute("ALTER TABLE wishes ADD COLUMN quadrant TEXT NOT NULL DEFAULT '重要不紧急'")
|
||||||
|
conn.execute("UPDATE wishes SET quadrant = CASE priority WHEN '高' THEN '重要紧急' WHEN '中' THEN '重要不紧急' WHEN '低' THEN '不紧急不重要' ELSE '重要不紧急' END WHERE quadrant = '重要不紧急'")
|
||||||
|
|
||||||
# ── 将来加字段/改表在此扩展 ──
|
# ── 将来加字段/改表在此扩展 ──
|
||||||
# if current < 2:
|
# if current < 2:
|
||||||
# conn.execute('ALTER TABLE checkins ADD COLUMN tags TEXT DEFAULT ""')
|
# conn.execute('ALTER TABLE checkins ADD COLUMN tags TEXT DEFAULT ""')
|
||||||
@@ -152,14 +157,14 @@ def get_wishes():
|
|||||||
return [dict(row) for row in rows]
|
return [dict(row) for row in rows]
|
||||||
|
|
||||||
|
|
||||||
def save_wish(name, priority, deadline):
|
def save_wish(name, quadrant, deadline):
|
||||||
"""新增一条心愿"""
|
"""新增一条心愿"""
|
||||||
now = datetime.now().isoformat()
|
now = datetime.now().isoformat()
|
||||||
conn = get_conn()
|
conn = get_conn()
|
||||||
max_order = conn.execute('SELECT COALESCE(MAX(sort_order), -1) + 1 AS n FROM wishes').fetchone()['n']
|
max_order = conn.execute('SELECT COALESCE(MAX(sort_order), -1) + 1 AS n FROM wishes').fetchone()['n']
|
||||||
conn.execute(
|
conn.execute(
|
||||||
'INSERT INTO wishes (name, priority, deadline, done, sort_order, created_at) VALUES (?, ?, ?, 0, ?, ?)',
|
'INSERT INTO wishes (name, quadrant, deadline, done, sort_order, created_at) VALUES (?, ?, ?, 0, ?, ?)',
|
||||||
(name, priority, deadline, max_order, now)
|
(name, quadrant, deadline, max_order, now)
|
||||||
)
|
)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
wish_id = conn.execute('SELECT last_insert_rowid()').fetchone()[0]
|
wish_id = conn.execute('SELECT last_insert_rowid()').fetchone()[0]
|
||||||
@@ -169,7 +174,7 @@ def save_wish(name, priority, deadline):
|
|||||||
|
|
||||||
def update_wish(wish_id, **kwargs):
|
def update_wish(wish_id, **kwargs):
|
||||||
"""更新心愿字段"""
|
"""更新心愿字段"""
|
||||||
allowed = ['name', 'priority', 'deadline', 'done']
|
allowed = ['name', 'quadrant', 'deadline', 'done']
|
||||||
updates = {k: v for k, v in kwargs.items() if k in allowed}
|
updates = {k: v for k, v in kwargs.items() if k in allowed}
|
||||||
if not updates:
|
if not updates:
|
||||||
return
|
return
|
||||||
|
|||||||
183
static/app.js
183
static/app.js
@@ -105,6 +105,7 @@
|
|||||||
|
|
||||||
if (name === 'weekly') loadWeekly();
|
if (name === 'weekly') loadWeekly();
|
||||||
if (name === 'history') loadHistory();
|
if (name === 'history') loadHistory();
|
||||||
|
if (name === 'wishes') loadWishes();
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ================================================================
|
/* ================================================================
|
||||||
@@ -635,67 +636,132 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* ================================================================
|
/* ================================================================
|
||||||
Wishes — 心愿清单
|
Wishes — 心愿清单(四象限)
|
||||||
================================================================ */
|
================================================================ */
|
||||||
var wishes = [];
|
var wishes = [];
|
||||||
var dragSourceId = null;
|
var dragSourceId = null;
|
||||||
|
var dragSourceQuadrant = null;
|
||||||
|
var wishesLoaded = false;
|
||||||
|
var QUADRANTS = ['重要紧急', '重要不紧急', '紧急不重要', '不紧急不重要'];
|
||||||
|
|
||||||
function loadWishes() {
|
function loadWishes() {
|
||||||
// 优先使用页面嵌入数据
|
if (wishesLoaded) { renderWishes(); return; }
|
||||||
if (window.__INITIAL_WISHES__) {
|
if (window.__INITIAL_WISHES__) {
|
||||||
wishes = window.__INITIAL_WISHES__;
|
wishes = window.__INITIAL_WISHES__;
|
||||||
|
wishesLoaded = true;
|
||||||
renderWishes();
|
renderWishes();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fetch('/api/wishes')
|
fetch('/api/wishes')
|
||||||
.then(function(r){ return r.json(); })
|
.then(function(r){ return r.json(); })
|
||||||
.then(function(res){ if (res.ok) { wishes = res.data; renderWishes(); } });
|
.then(function(res){ if (res.ok) { wishes = res.data; wishesLoaded = true; renderWishes(); } });
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderWishes() {
|
function renderWishes() {
|
||||||
var list = document.getElementById('wishes-list');
|
var emptyEl = document.getElementById('wishes-empty');
|
||||||
var empty = document.getElementById('wishes-empty');
|
if (!wishes.length) {
|
||||||
if (!list) return;
|
QUADRANTS.forEach(function(q){ document.getElementById('quad-list-' + q).innerHTML = ''; });
|
||||||
if (wishes.length === 0) {
|
if (emptyEl) emptyEl.style.display = 'block';
|
||||||
list.innerHTML = '';
|
|
||||||
if (empty) empty.style.display = 'block';
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (empty) empty.style.display = 'none';
|
if (emptyEl) emptyEl.style.display = 'none';
|
||||||
var html = '';
|
|
||||||
for (var i = 0; i < wishes.length; i++) {
|
// 按象限分组渲染
|
||||||
var w = wishes[i];
|
QUADRANTS.forEach(function(quadrant) {
|
||||||
var doneCls = w.done ? ' done' : '';
|
var list = document.getElementById('quad-list-' + quadrant);
|
||||||
var priCls = 'pri-' + (w.priority || '中');
|
if (!list) return;
|
||||||
var deadline = w.deadline ? w.deadline : '';
|
var items = wishes.filter(function(w){ return (w.quadrant || w.priority || '重要不紧急') === quadrant; });
|
||||||
html += '<div class="wish-item' + doneCls + '" draggable="true" data-id="' + w.id + '">' +
|
var html = '';
|
||||||
'<span class="wish-drag-handle"><svg class="icon-xs"><use href="#icon-list-bullet"/></svg></span>' +
|
for (var i = 0; i < items.length; i++) {
|
||||||
'<input type="checkbox" class="wish-check" ' + (w.done ? 'checked' : '') + ' onchange="toggleWish(' + w.id + ', this.checked)">' +
|
var w = items[i];
|
||||||
'<span class="wish-name" title="' + esc(w.name) + '">' + esc(w.name) + '</span>' +
|
var doneCls = w.done ? ' done' : '';
|
||||||
'<span class="wish-pri ' + priCls + '">' + esc(w.priority) + '</span>' +
|
var deadline = w.deadline ? w.deadline : '';
|
||||||
(deadline ? '<span class="wish-deadline">' + esc(deadline) + '</span>' : '') +
|
html += '<div class="wish-item' + doneCls + '" draggable="true" data-id="' + w.id + '" data-quadrant="' + quadrant + '">' +
|
||||||
'<button class="btn-del wish-del" onclick="deleteWishItem(' + w.id + ')"><svg class="icon-xs"><use href="#icon-x"/></svg></button>' +
|
'<span class="wish-drag-handle"><svg class="icon-xs"><use href="#icon-list-bullet"/></svg></span>' +
|
||||||
'</div>';
|
'<input type="checkbox" class="wish-check" ' + (w.done ? 'checked' : '') + ' onchange="toggleWish(' + w.id + ', this.checked)">' +
|
||||||
}
|
'<span class="wish-name" title="' + esc(w.name) + '">' + esc(w.name) + '</span>' +
|
||||||
list.innerHTML = html;
|
(deadline ? '<span class="wish-deadline">' + esc(deadline) + '</span>' : '') +
|
||||||
|
'<button class="btn-del wish-del" onclick="deleteWishItem(' + w.id + ')"><svg class="icon-xs"><use href="#icon-x"/></svg></button>' +
|
||||||
|
'</div>';
|
||||||
|
}
|
||||||
|
list.innerHTML = html;
|
||||||
|
});
|
||||||
|
|
||||||
bindDragEvents();
|
bindDragEvents();
|
||||||
|
bindEditClicks();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Drag & Drop ── */
|
/* ── 点击编辑 ── */
|
||||||
|
|
||||||
|
function bindEditClicks() {
|
||||||
|
document.querySelectorAll('#panel-wishes .wish-item').forEach(function(item) {
|
||||||
|
// 只在点击名称或日期区域时触发编辑(排除 checkbox / 拖拽手柄 / 删除按钮)
|
||||||
|
item.addEventListener('click', function(e) {
|
||||||
|
if (e.target.closest('.wish-check') || e.target.closest('.wish-drag-handle') ||
|
||||||
|
e.target.closest('.wish-del') || e.target.closest('.wish-edit-form')) return;
|
||||||
|
var id = parseInt(this.dataset.id);
|
||||||
|
var w = wishes.find(function(x){ return x.id === id; });
|
||||||
|
if (w) startEditWish(this, w);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function startEditWish(el, w) {
|
||||||
|
if (el.querySelector('.wish-edit-form')) return; // 已在编辑中
|
||||||
|
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>';
|
||||||
|
}).join('');
|
||||||
|
el.innerHTML =
|
||||||
|
'<div class="wish-edit-form">' +
|
||||||
|
'<input type="text" class="wish-edit-name" value="' + esc(w.name) + '" maxlength="50">' +
|
||||||
|
'<div class="wish-edit-row">' +
|
||||||
|
'<select class="wish-edit-quadrant">' + quadOpts + '</select>' +
|
||||||
|
'<input type="date" class="wish-edit-deadline" value="' + esc(deadline) + '">' +
|
||||||
|
'</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>' +
|
||||||
|
'</div>' +
|
||||||
|
'</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
window.saveEditWish = function(id, btn) {
|
||||||
|
var form = btn.closest('.wish-edit-form');
|
||||||
|
var name = form.querySelector('.wish-edit-name').value.trim();
|
||||||
|
if (!name) { showToast('名称不能为空', 'error'); return; }
|
||||||
|
var quadrant = form.querySelector('.wish-edit-quadrant').value;
|
||||||
|
var deadline = form.querySelector('.wish-edit-deadline').value;
|
||||||
|
fetch('/api/wishes/' + id, {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: {'Content-Type': 'application/json'},
|
||||||
|
body: JSON.stringify({name: name, quadrant: quadrant, deadline: deadline})
|
||||||
|
}).then(function(r){ return r.json(); })
|
||||||
|
.then(function(res) {
|
||||||
|
if (!res.ok) { showToast(res.error, 'error'); return; }
|
||||||
|
var w = wishes.find(function(x){ return x.id === id; });
|
||||||
|
if (w) { w.name = name; w.quadrant = quadrant; w.deadline = deadline; }
|
||||||
|
renderWishes();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ── Drag & Drop (跨象限) ── */
|
||||||
|
|
||||||
function bindDragEvents() {
|
function bindDragEvents() {
|
||||||
var items = document.querySelectorAll('#wishes-list .wish-item');
|
var items = document.querySelectorAll('#panel-wishes .wish-item');
|
||||||
items.forEach(function(item) {
|
items.forEach(function(item) {
|
||||||
item.addEventListener('dragstart', function(e) {
|
item.addEventListener('dragstart', function(e) {
|
||||||
dragSourceId = parseInt(this.dataset.id);
|
dragSourceId = parseInt(this.dataset.id);
|
||||||
|
dragSourceQuadrant = this.dataset.quadrant;
|
||||||
this.classList.add('dragging');
|
this.classList.add('dragging');
|
||||||
e.dataTransfer.effectAllowed = 'move';
|
e.dataTransfer.effectAllowed = 'move';
|
||||||
});
|
});
|
||||||
item.addEventListener('dragend', function(e) {
|
item.addEventListener('dragend', function() {
|
||||||
this.classList.remove('dragging');
|
this.classList.remove('dragging');
|
||||||
dragSourceId = null;
|
dragSourceId = null;
|
||||||
// 移除所有 over 状态
|
dragSourceQuadrant = null;
|
||||||
document.querySelectorAll('#wishes-list .wish-item').forEach(function(el){ el.classList.remove('drag-over'); });
|
document.querySelectorAll('.quad-cell, .wish-item').forEach(function(el){ el.classList.remove('drag-over'); });
|
||||||
});
|
});
|
||||||
item.addEventListener('dragover', function(e) {
|
item.addEventListener('dragover', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -707,23 +773,60 @@
|
|||||||
});
|
});
|
||||||
item.addEventListener('drop', function(e) {
|
item.addEventListener('drop', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
this.classList.remove('drag-over');
|
this.classList.remove('drag-over');
|
||||||
var targetId = parseInt(this.dataset.id);
|
var targetId = parseInt(this.dataset.id);
|
||||||
|
var targetQuadrant = this.dataset.quadrant;
|
||||||
if (dragSourceId === targetId) return;
|
if (dragSourceId === targetId) return;
|
||||||
// 更新本地顺序
|
|
||||||
var fromIdx = -1, toIdx = -1;
|
var fromIdx = -1, toIdx = -1;
|
||||||
for (var j = 0; j < wishes.length; j++) {
|
for (var j = 0; j < wishes.length; j++) {
|
||||||
if (wishes[j].id === dragSourceId) fromIdx = j;
|
if (wishes[j].id === dragSourceId) fromIdx = j;
|
||||||
if (wishes[j].id === targetId) toIdx = j;
|
if (wishes[j].id === targetId) toIdx = j;
|
||||||
}
|
}
|
||||||
if (fromIdx >= 0 && toIdx >= 0) {
|
if (fromIdx >= 0 && toIdx >= 0) {
|
||||||
var item = wishes.splice(fromIdx, 1)[0];
|
var moved = wishes.splice(fromIdx, 1)[0];
|
||||||
wishes.splice(toIdx, 0, item);
|
wishes.splice(toIdx, 0, moved);
|
||||||
|
// 更新象限
|
||||||
|
if (dragSourceQuadrant !== targetQuadrant) {
|
||||||
|
moved.quadrant = targetQuadrant;
|
||||||
|
fetch('/api/wishes/' + moved.id, {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: {'Content-Type': 'application/json'},
|
||||||
|
body: JSON.stringify({quadrant: targetQuadrant})
|
||||||
|
});
|
||||||
|
}
|
||||||
renderWishes();
|
renderWishes();
|
||||||
saveWishOrder();
|
saveWishOrder();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 象限空区域接受 drop
|
||||||
|
document.querySelectorAll('.quad-cell').forEach(function(cell) {
|
||||||
|
cell.addEventListener('dragover', function(e) {
|
||||||
|
if (this.querySelector('.wish-item')) return; // 有内容时让 item 处理
|
||||||
|
e.preventDefault();
|
||||||
|
this.classList.add('drag-over');
|
||||||
|
});
|
||||||
|
cell.addEventListener('dragleave', function() { this.classList.remove('drag-over'); });
|
||||||
|
cell.addEventListener('drop', function(e) {
|
||||||
|
this.classList.remove('drag-over');
|
||||||
|
if (this.querySelector('.wish-item')) return; // 已由 item 处理
|
||||||
|
e.preventDefault();
|
||||||
|
var q = this.dataset.quadrant;
|
||||||
|
var moved = wishes.find(function(w){ return w.id === dragSourceId; });
|
||||||
|
if (moved) {
|
||||||
|
moved.quadrant = q;
|
||||||
|
fetch('/api/wishes/' + moved.id, {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: {'Content-Type': 'application/json'},
|
||||||
|
body: JSON.stringify({quadrant: q})
|
||||||
|
});
|
||||||
|
renderWishes();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveWishOrder() {
|
function saveWishOrder() {
|
||||||
@@ -747,23 +850,24 @@
|
|||||||
if (form) form.style.display = 'none';
|
if (form) form.style.display = 'none';
|
||||||
document.getElementById('wish-name').value = '';
|
document.getElementById('wish-name').value = '';
|
||||||
document.getElementById('wish-deadline').value = '';
|
document.getElementById('wish-deadline').value = '';
|
||||||
document.getElementById('wish-priority').value = '中';
|
var sel = document.getElementById('wish-quadrant');
|
||||||
|
if (sel) sel.value = '重要不紧急';
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addWish = function() {
|
window.addWish = function() {
|
||||||
var name = document.getElementById('wish-name').value.trim();
|
var name = document.getElementById('wish-name').value.trim();
|
||||||
if (!name) { showToast('请输入心愿名称', 'error'); return; }
|
if (!name) { showToast('请输入心愿名称', 'error'); return; }
|
||||||
var priority = document.getElementById('wish-priority').value;
|
var quadrant = document.getElementById('wish-quadrant').value;
|
||||||
var deadline = document.getElementById('wish-deadline').value;
|
var deadline = document.getElementById('wish-deadline').value;
|
||||||
fetch('/api/wishes', {
|
fetch('/api/wishes', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
body: JSON.stringify({name: name, priority: priority, deadline: deadline})
|
body: JSON.stringify({name: name, quadrant: quadrant, deadline: deadline})
|
||||||
}).then(function(r){ return r.json(); })
|
}).then(function(r){ return r.json(); })
|
||||||
.then(function(res){
|
.then(function(res){
|
||||||
if (!res.ok) { showToast(res.error, 'error'); return; }
|
if (!res.ok) { showToast(res.error, 'error'); return; }
|
||||||
hideWishForm();
|
hideWishForm();
|
||||||
wishes.push({id: res.id, name: name, priority: priority, deadline: deadline, done: 0});
|
wishes.push({id: res.id, name: name, quadrant: quadrant, deadline: deadline, done: 0});
|
||||||
renderWishes();
|
renderWishes();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -786,7 +890,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
window.toggleWishesEdit = function(btn) {
|
window.toggleWishesEdit = function(btn) {
|
||||||
var panel = document.getElementById('wishes-panel');
|
var panel = document.getElementById('panel-wishes');
|
||||||
if (!panel) return;
|
if (!panel) return;
|
||||||
var editing = panel.classList.toggle('editing');
|
var editing = panel.classList.toggle('editing');
|
||||||
btn.classList.toggle('active', editing);
|
btn.classList.toggle('active', editing);
|
||||||
@@ -807,7 +911,6 @@
|
|||||||
selectedDate = todayStr;
|
selectedDate = todayStr;
|
||||||
initStudyPresets();
|
initStudyPresets();
|
||||||
bindAutoSave();
|
bindAutoSave();
|
||||||
loadWishes();
|
|
||||||
lastSavedDate = todayStr;
|
lastSavedDate = todayStr;
|
||||||
|
|
||||||
// 从页面嵌入数据获取初始统计(0 延迟)
|
// 从页面嵌入数据获取初始统计(0 延迟)
|
||||||
|
|||||||
256
static/style.css
256
static/style.css
@@ -1081,178 +1081,184 @@ body {
|
|||||||
.toast.info { background: var(--primary); color: #FFF; }
|
.toast.info { background: var(--primary); color: #FFF; }
|
||||||
|
|
||||||
/* ═══════════════════════════════════════════
|
/* ═══════════════════════════════════════════
|
||||||
Wishes Panel
|
Wishes — 四象限
|
||||||
═══════════════════════════════════════════ */
|
═══════════════════════════════════════════ */
|
||||||
|
|
||||||
.wishes-panel {
|
#panel-wishes.editing .edit-only { display: inline-flex; }
|
||||||
padding: 0 16px 10px;
|
#panel-wishes.editing .wish-del { display: inline-flex; }
|
||||||
}
|
|
||||||
.wishes-panel.editing .edit-only { display: flex; }
|
|
||||||
.wishes-panel.editing .wish-del { display: inline-flex; }
|
|
||||||
|
|
||||||
.wishes-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text);
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wishes-add-btn {
|
|
||||||
display: none;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 22px;
|
|
||||||
height: 22px;
|
|
||||||
border: none;
|
|
||||||
background: var(--primary-light);
|
|
||||||
color: var(--primary);
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
margin-left: auto;
|
|
||||||
transition: background 0.2s;
|
|
||||||
}
|
|
||||||
.wishes-add-btn:hover { background: #DDE3FD; }
|
|
||||||
.wishes-panel.editing .wishes-add-btn { display: flex; }
|
|
||||||
|
|
||||||
.wish-form {
|
.wish-form {
|
||||||
background: var(--bg);
|
background: var(--bg);
|
||||||
border-radius: var(--radius-sm);
|
border-radius: var(--radius-sm);
|
||||||
padding: 8px;
|
padding: 10px 12px;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 12px;
|
||||||
|
max-width: 480px;
|
||||||
}
|
}
|
||||||
.wish-form input[type="text"],
|
.wish-form input[type="text"],
|
||||||
.wish-form input[type="date"],
|
.wish-form input[type="date"],
|
||||||
.wish-form select {
|
.wish-form select {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 6px 8px;
|
padding: 8px 10px;
|
||||||
border: 1px solid var(--border);
|
border: 1.5px solid var(--border);
|
||||||
border-radius: 6px;
|
border-radius: var(--radius-sm);
|
||||||
font-size: 12px;
|
font-size: 13px;
|
||||||
font-family: inherit;
|
font-family: inherit;
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
margin-bottom: 6px;
|
margin-bottom: 8px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
background: var(--card);
|
||||||
}
|
}
|
||||||
.wish-form-row {
|
.wish-form input:focus, .wish-form select:focus {
|
||||||
display: flex;
|
outline: none;
|
||||||
gap: 6px;
|
border-color: var(--primary);
|
||||||
}
|
box-shadow: 0 0 0 3px rgba(74,108,247,0.08);
|
||||||
.wish-form-row select,
|
|
||||||
.wish-form-row input { flex: 1; }
|
|
||||||
.wish-form-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 6px;
|
|
||||||
}
|
}
|
||||||
|
.wish-form-row { display: flex; gap: 8px; }
|
||||||
|
.wish-form-row select, .wish-form-row input { flex: 1; }
|
||||||
|
.wish-form-actions { display: flex; gap: 8px; }
|
||||||
.btn-wish-save {
|
.btn-wish-save {
|
||||||
flex: 1;
|
flex: 1; padding: 8px; border: none; background: var(--primary); color: #FFF;
|
||||||
padding: 6px;
|
border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
|
||||||
border: none;
|
cursor: pointer; font-family: inherit;
|
||||||
background: var(--primary);
|
|
||||||
color: #FFF;
|
|
||||||
border-radius: 6px;
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 500;
|
|
||||||
cursor: pointer;
|
|
||||||
font-family: inherit;
|
|
||||||
}
|
}
|
||||||
.btn-wish-save:hover { background: var(--primary-dark); }
|
.btn-wish-save:hover { background: var(--primary-dark); }
|
||||||
.btn-wish-cancel {
|
.btn-wish-cancel {
|
||||||
flex: 1;
|
flex: 1; padding: 8px; border: 1.5px solid var(--border); background: var(--card);
|
||||||
padding: 6px;
|
color: var(--text-dim); border-radius: var(--radius-sm); font-size: 13px;
|
||||||
border: 1px solid var(--border);
|
cursor: pointer; font-family: inherit;
|
||||||
background: var(--card);
|
|
||||||
color: var(--text-dim);
|
|
||||||
border-radius: 6px;
|
|
||||||
font-size: 12px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-family: inherit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.wishes-list {
|
/* 四象限网格 */
|
||||||
|
.quad-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
grid-template-rows: 1fr 1fr;
|
||||||
|
gap: 12px;
|
||||||
|
min-height: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quad-cell {
|
||||||
|
background: var(--card);
|
||||||
|
border: 1.5px solid var(--border);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
padding: 12px 14px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 2px;
|
min-height: 180px;
|
||||||
max-height: 240px;
|
transition: border-color 0.2s, box-shadow 0.2s;
|
||||||
overflow-y: auto;
|
}
|
||||||
|
.quad-cell.drag-over {
|
||||||
|
border-color: var(--primary);
|
||||||
|
box-shadow: 0 0 0 3px rgba(74,108,247,0.10);
|
||||||
|
background: var(--primary-light);
|
||||||
}
|
}
|
||||||
|
|
||||||
.wishes-empty {
|
.quad-title {
|
||||||
font-size: 11px;
|
font-size: 13px;
|
||||||
color: var(--text-muted);
|
font-weight: 600;
|
||||||
text-align: center;
|
color: var(--text);
|
||||||
padding: 12px 0;
|
margin-bottom: 10px;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quad-list {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
min-height: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wish-item {
|
.wish-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 6px;
|
gap: 8px;
|
||||||
padding: 5px 6px;
|
padding: 7px 10px;
|
||||||
border-radius: 6px;
|
border-radius: var(--radius-sm);
|
||||||
transition: background 0.15s;
|
background: var(--bg);
|
||||||
cursor: default;
|
transition: opacity 0.15s, box-shadow 0.15s;
|
||||||
|
}
|
||||||
|
.wish-item:hover { box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
|
||||||
|
.wish-item.dragging { opacity: 0.3; }
|
||||||
|
.wish-item.drag-over {
|
||||||
|
box-shadow: inset 0 0 0 2px var(--primary);
|
||||||
|
background: var(--card);
|
||||||
}
|
}
|
||||||
.wish-item:hover { background: var(--bg); }
|
|
||||||
.wish-item.dragging { opacity: 0.4; }
|
|
||||||
.wish-item.drag-over { background: var(--primary-light); box-shadow: inset 0 0 0 1.5px var(--primary); }
|
|
||||||
|
|
||||||
.wish-drag-handle {
|
.wish-drag-handle {
|
||||||
color: var(--text-muted);
|
color: var(--text-muted); cursor: grab; flex-shrink: 0;
|
||||||
cursor: grab;
|
display: flex; align-items: center;
|
||||||
flex-shrink: 0;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
}
|
||||||
.wish-drag-handle:active { cursor: grabbing; }
|
.wish-drag-handle:active { cursor: grabbing; }
|
||||||
|
|
||||||
.wish-check {
|
.wish-check {
|
||||||
width: 14px;
|
width: 15px; height: 15px; accent-color: var(--success);
|
||||||
height: 14px;
|
flex-shrink: 0; cursor: pointer;
|
||||||
accent-color: var(--success);
|
|
||||||
flex-shrink: 0;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.wish-name {
|
.wish-name {
|
||||||
flex: 1;
|
flex: 1; font-size: 13px; color: var(--text); min-width: 0;
|
||||||
font-size: 12px;
|
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||||
color: var(--text);
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
}
|
||||||
.wish-item.done .wish-name {
|
.wish-item.done .wish-name { text-decoration: line-through; color: var(--text-muted); }
|
||||||
text-decoration: line-through;
|
|
||||||
color: var(--text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wish-pri {
|
|
||||||
font-size: 10px;
|
|
||||||
font-weight: 600;
|
|
||||||
padding: 1px 6px;
|
|
||||||
border-radius: 8px;
|
|
||||||
white-space: nowrap;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
.wish-pri.pri-高 { background: var(--danger-light); color: var(--danger); }
|
|
||||||
.wish-pri.pri-中 { background: var(--warning-light); color: #D97706; }
|
|
||||||
.wish-pri.pri-低 { background: var(--bg); color: var(--text-muted); }
|
|
||||||
|
|
||||||
.wish-deadline {
|
.wish-deadline {
|
||||||
font-size: 10px;
|
font-size: 11px; color: var(--text-dim); white-space: nowrap; flex-shrink: 0;
|
||||||
color: var(--text-muted);
|
|
||||||
white-space: nowrap;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.wish-del {
|
.wish-del { display: none; }
|
||||||
display: none;
|
.wish-del .icon-xs { width: 13px; height: 13px; }
|
||||||
|
|
||||||
|
/* 内联编辑 */
|
||||||
|
.wish-item.editing {
|
||||||
|
background: var(--card);
|
||||||
|
padding: 8px 10px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.wish-edit-form {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
.wish-edit-form input[type="text"],
|
||||||
|
.wish-edit-form input[type="date"],
|
||||||
|
.wish-edit-form select {
|
||||||
|
width: 100%;
|
||||||
|
padding: 6px 8px;
|
||||||
|
border: 1.5px solid var(--border);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
font-size: 12px;
|
||||||
|
font-family: inherit;
|
||||||
|
color: var(--text);
|
||||||
|
background: var(--card);
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.wish-edit-form input:focus,
|
||||||
|
.wish-edit-form select:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: var(--primary);
|
||||||
|
box-shadow: 0 0 0 2px rgba(74,108,247,0.08);
|
||||||
|
}
|
||||||
|
.wish-edit-name { font-weight: 500; }
|
||||||
|
.wish-edit-row { display: flex; gap: 6px; }
|
||||||
|
.wish-edit-row select,
|
||||||
|
.wish-edit-row input { flex: 1; }
|
||||||
|
.wish-edit-actions { display: flex; gap: 6px; }
|
||||||
|
.wish-edit-actions .btn-wish-save,
|
||||||
|
.wish-edit-actions .btn-wish-cancel {
|
||||||
|
flex: 1; padding: 6px; font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wishes-empty {
|
||||||
|
font-size: 13px; color: var(--text-muted); text-align: center; padding: 32px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.quad-grid { grid-template-columns: 1fr; grid-template-rows: auto; }
|
||||||
}
|
}
|
||||||
.wish-del .icon-xs { width: 12px; height: 12px; }
|
|
||||||
|
|
||||||
/* ═══════════════════════════════════════════
|
/* ═══════════════════════════════════════════
|
||||||
SVG icons helpers
|
SVG icons helpers
|
||||||
|
|||||||
@@ -68,39 +68,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 心愿清单 -->
|
|
||||||
<div class="wishes-panel" id="wishes-panel">
|
|
||||||
<div class="wishes-header">
|
|
||||||
<svg class="icon-sm" style="color:var(--primary)"><use href="#icon-star"/></svg>
|
|
||||||
<span>心愿清单</span>
|
|
||||||
<button class="wishes-add-btn edit-only" id="wishes-add-btn" onclick="showWishForm()">
|
|
||||||
<svg class="icon-sm"><use href="#icon-plus"/></svg>
|
|
||||||
</button>
|
|
||||||
<button class="btn-edit-toggle" onclick="toggleWishesEdit(this)" title="编辑">
|
|
||||||
<svg class="icon-sm"><use href="#icon-pencil"/></svg>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<!-- 新增表单 -->
|
|
||||||
<div class="wish-form" id="wish-form" style="display:none">
|
|
||||||
<input type="text" id="wish-name" placeholder="心愿名称…" maxlength="50">
|
|
||||||
<div class="wish-form-row">
|
|
||||||
<select id="wish-priority">
|
|
||||||
<option value="高">高优先</option>
|
|
||||||
<option value="中" selected>中优先</option>
|
|
||||||
<option value="低">低优先</option>
|
|
||||||
</select>
|
|
||||||
<input type="date" id="wish-deadline">
|
|
||||||
</div>
|
|
||||||
<div class="wish-form-actions">
|
|
||||||
<button class="btn-wish-save" onclick="addWish()">添加</button>
|
|
||||||
<button class="btn-wish-cancel" onclick="hideWishForm()">取消</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- 列表 -->
|
|
||||||
<div class="wishes-list" id="wishes-list"></div>
|
|
||||||
<div class="wishes-empty" id="wishes-empty">暂无心愿,点击 + 添加</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 功能入口 -->
|
<!-- 功能入口 -->
|
||||||
<nav class="sidebar-nav">
|
<nav class="sidebar-nav">
|
||||||
<a class="nav-item active" data-panel="daily" onclick="switchPanel('daily')">
|
<a class="nav-item active" data-panel="daily" onclick="switchPanel('daily')">
|
||||||
@@ -111,6 +78,10 @@
|
|||||||
<svg class="icon-sm"><use href="#icon-chart-bar"/></svg>
|
<svg class="icon-sm"><use href="#icon-chart-bar"/></svg>
|
||||||
每周评分
|
每周评分
|
||||||
</a>
|
</a>
|
||||||
|
<a class="nav-item" data-panel="wishes" onclick="switchPanel('wishes')">
|
||||||
|
<svg class="icon-sm"><use href="#icon-star"/></svg>
|
||||||
|
心愿清单
|
||||||
|
</a>
|
||||||
<a class="nav-item" data-panel="history" onclick="switchPanel('history')">
|
<a class="nav-item" data-panel="history" onclick="switchPanel('history')">
|
||||||
<svg class="icon-sm"><use href="#icon-list-bullet"/></svg>
|
<svg class="icon-sm"><use href="#icon-list-bullet"/></svg>
|
||||||
历史记录
|
历史记录
|
||||||
@@ -222,6 +193,56 @@
|
|||||||
<div id="history-grid" class="history-grid"></div>
|
<div id="history-grid" class="history-grid"></div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<!-- ── 心愿清单面板 ── -->
|
||||||
|
<section class="panel" id="panel-wishes">
|
||||||
|
<div class="panel-header">
|
||||||
|
<h2>心愿清单</h2>
|
||||||
|
<button class="btn-edit-toggle" id="wishes-edit-toggle" onclick="toggleWishesEdit(this)" title="编辑">
|
||||||
|
<svg class="icon-sm"><use href="#icon-pencil"/></svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<!-- 新增表单 -->
|
||||||
|
<div class="wish-form" id="wish-form" style="display:none">
|
||||||
|
<input type="text" id="wish-name" placeholder="心愿名称…" maxlength="50">
|
||||||
|
<div class="wish-form-row">
|
||||||
|
<select id="wish-quadrant">
|
||||||
|
<option value="重要紧急">重要紧急</option>
|
||||||
|
<option value="重要不紧急" selected>重要不紧急</option>
|
||||||
|
<option value="紧急不重要">紧急不重要</option>
|
||||||
|
<option value="不紧急不重要">不紧急不重要</option>
|
||||||
|
</select>
|
||||||
|
<input type="date" id="wish-deadline">
|
||||||
|
</div>
|
||||||
|
<div class="wish-form-actions">
|
||||||
|
<button class="btn-wish-save" onclick="addWish()">添加</button>
|
||||||
|
<button class="btn-wish-cancel" onclick="hideWishForm()">取消</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button class="btn-add edit-only" id="wishes-add-btn" onclick="showWishForm()" style="margin-bottom:16px">
|
||||||
|
<svg class="icon-sm"><use href="#icon-plus"/></svg> 新增心愿
|
||||||
|
</button>
|
||||||
|
<!-- 四象限网格 -->
|
||||||
|
<div class="quad-grid">
|
||||||
|
<div class="quad-cell" data-quadrant="重要紧急" id="quad-重要紧急">
|
||||||
|
<div class="quad-title">重要 & 紧急</div>
|
||||||
|
<div class="quad-list" id="quad-list-重要紧急"></div>
|
||||||
|
</div>
|
||||||
|
<div class="quad-cell" data-quadrant="重要不紧急" id="quad-重要不紧急">
|
||||||
|
<div class="quad-title">重要 & 不紧急</div>
|
||||||
|
<div class="quad-list" id="quad-list-重要不紧急"></div>
|
||||||
|
</div>
|
||||||
|
<div class="quad-cell" data-quadrant="紧急不重要" id="quad-紧急不重要">
|
||||||
|
<div class="quad-title">紧急 & 不重要</div>
|
||||||
|
<div class="quad-list" id="quad-list-紧急不重要"></div>
|
||||||
|
</div>
|
||||||
|
<div class="quad-cell" data-quadrant="不紧急不重要" id="quad-不紧急不重要">
|
||||||
|
<div class="quad-title">不紧急 & 不重要</div>
|
||||||
|
<div class="quad-list" id="quad-list-不紧急不重要"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="wishes-empty" id="wishes-empty" style="display:none">暂无心愿,点击上方按钮添加</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user