mirror of
https://github.com/czm15053/write-notes-like-deepseek
synced 2026-11-24 16:14:17 +08:00
fix: 看板小节提取截断、抽屉滚动与同日期排序抖动
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -519,6 +519,10 @@
|
||||
|
||||
.console-body { flex: 1; overflow-y: auto; padding: 36px 44px 80px; }
|
||||
|
||||
/* 抽屉打开时锁住背景滚动,避免内外双层滚动条 */
|
||||
body:has(#drawer-console.open),
|
||||
html:has(#drawer-console.open) { overflow: hidden; }
|
||||
|
||||
/* 代码反向注释定位板 */
|
||||
.anchor-terminal {
|
||||
background: #F8FAFC; border: 1px dashed #BFDBFE;
|
||||
@@ -840,6 +844,10 @@ const Core = {
|
||||
drawerId: null,
|
||||
};
|
||||
|
||||
// 全序日期比较器:date 相同时以唯一 id 兜底,保证任意刷新顺序一致
|
||||
const byDateDesc = (a, b) => (b.date || '').localeCompare(a.date || '') || a.id.localeCompare(b.id);
|
||||
const byDateAsc = (a, b) => (a.date || '').localeCompare(b.date || '') || a.id.localeCompare(b.id);
|
||||
|
||||
function getDB() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const req = indexedDB.open(DB_NAME, 1);
|
||||
@@ -1043,7 +1051,7 @@ function ingestDataset(notes) {
|
||||
});
|
||||
});
|
||||
|
||||
Core.nodes.sort((a, b) => (b.date || '0000').localeCompare(a.date || '0000'));
|
||||
Core.nodes.sort(byDateDesc);
|
||||
|
||||
document.getElementById('chip-total-count').textContent = `${notes.length} 项`;
|
||||
document.getElementById('deck-onboarding').style.display = notes.length ? 'none' : 'flex';
|
||||
@@ -1153,7 +1161,7 @@ function renderBaseline() {
|
||||
}
|
||||
|
||||
function renderTimeline() {
|
||||
const allDatedNodes = [...Core.nodes].filter(n => n.date).sort((a, b) => b.date.localeCompare(a.date));
|
||||
const allDatedNodes = [...Core.nodes].filter(n => n.date).sort(byDateDesc);
|
||||
|
||||
// 1. 统计全部月份
|
||||
const monthsMap = new Map();
|
||||
@@ -1345,8 +1353,8 @@ function renderDirectory() {
|
||||
return true;
|
||||
});
|
||||
|
||||
if (Core.sortMode === 'new') list.sort((a, b) => (b.date || '').localeCompare(a.date || ''));
|
||||
else if (Core.sortMode === 'old') list.sort((a, b) => (a.date || '').localeCompare(b.date || ''));
|
||||
if (Core.sortMode === 'new') list.sort(byDateDesc);
|
||||
else if (Core.sortMode === 'old') list.sort(byDateAsc);
|
||||
else if (Core.sortMode === 'cites') list.sort((a, b) => (Core.inCount.get(b.id) || 0) - (Core.inCount.get(a.id) || 0));
|
||||
|
||||
document.getElementById('matrix-matched-count').textContent = `匹配 ${list.length} 条`;
|
||||
@@ -1432,6 +1440,9 @@ function openConsole(id) {
|
||||
}
|
||||
document.getElementById('dr-lineage-stream').innerHTML = lineageHtml;
|
||||
|
||||
// 打开新笔记前重置滚动位置,避免从上一篇的底部开始显示
|
||||
document.querySelector('#drawer-console .console-body').scrollTop = 0;
|
||||
|
||||
document.getElementById('drawer-curtain').classList.add('open');
|
||||
document.getElementById('drawer-console').classList.add('open');
|
||||
history.replaceState(null, '', '#note=' + encodeURIComponent(id));
|
||||
|
||||
@@ -98,7 +98,7 @@ function parseNoteContent(raw: string, relPath: string, slugToId: Map<string, st
|
||||
if (h1Match) title = h1Match[1].trim();
|
||||
|
||||
function extractSection(secNamePattern: string) {
|
||||
const re = new RegExp(`^## (?:${secNamePattern})\\s*\\n+([\\s\\S]*?)(?=^## |\\s*$)`, 'm');
|
||||
const re = new RegExp(`^## (?:${secNamePattern})\\s*\\n+([\\s\\S]*?)(?=^## |(?![\\s\\S]))`, 'm');
|
||||
const m = re.exec(parseable);
|
||||
return m ? m[1].trim() : '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user