diff --git a/src/renderer/ui/panels/ChroniclePanel.tsx b/src/renderer/ui/panels/ChroniclePanel.tsx index 911a213..265b2e7 100644 --- a/src/renderer/ui/panels/ChroniclePanel.tsx +++ b/src/renderer/ui/panels/ChroniclePanel.tsx @@ -16,6 +16,36 @@ const CAT_NAME: Record = { misc: '家常' } +interface ChEntry { + id: string + year: number + month: number + category: string + important: boolean + text: string +} + +function grouped(entries: ChEntry[]): { year: number; items: ChEntry[] }[] { + const map = new Map() + for (const e of entries) { + const g = map.get(e.year) ?? [] + g.push(e) + map.set(e.year, g) + } + return [...map.entries()].sort((a, b) => b[0] - a[0]).map(([year, items]) => ({ year, items })) +} + +function statOf(g: { items: { category: string }[] }): string { + const births = g.items.filter((i) => i.category === 'birth').length + const deaths = g.items.filter((i) => i.category === 'death').length + const bt = g.items.filter((i) => i.category === 'breakthrough').length + const parts: string[] = [] + if (births) parts.push(`生${births}`) + if (deaths) parts.push(`殇${deaths}`) + if (bt) parts.push(`突破${bt}`) + return parts.join(' · ') +} + export default function ChroniclePanel() { const world = useGameStore((s) => s.world) const revision = useGameStore((s) => s.revision) @@ -46,13 +76,18 @@ export default function ChroniclePanel() { ))}
- {entries.map((e) => ( -
- {e.year}年{e.month}月 - - {CAT_NAME[e.category] ?? e.category} - {e.text} - + {grouped(entries).map((g) => ( +
+
{g.year}年 {g.items.length}条 · {statOf(g)}
+ {g.items.map((e) => ( +
+ {e.month}月 + + {CAT_NAME[e.category] ?? e.category} + {e.text} + +
+ ))}
))} {entries.length === 0 &&
暂无记载。
} @@ -60,7 +95,7 @@ export default function ChroniclePanel() {
战报匣(全文留存)
{battle ? ( -
+
{battle.title} @@ -85,9 +120,9 @@ export default function ChroniclePanel() { ) : battles.length === 0 ? (
尚无战事可录。
) : ( -
+
{battles.map((b) => ( -
+
{b.year}年{b.month}月 {b.title} diff --git a/src/renderer/ui/panels/GenealogyPanel.tsx b/src/renderer/ui/panels/GenealogyPanel.tsx index 96bdb37..9b77ca1 100644 --- a/src/renderer/ui/panels/GenealogyPanel.tsx +++ b/src/renderer/ui/panels/GenealogyPanel.tsx @@ -77,7 +77,7 @@ export default function GenealogyPanel() { {deceasedTab && deceased.map((c) => ( -
+
殁于{c.deathYear}年 {c.name} · {c.gender === 'male' ? '男' : '女'} · 第{c.generation}代 diff --git a/src/renderer/ui/styles.css b/src/renderer/ui/styles.css index 95ba226..ffd7cb4 100644 --- a/src/renderer/ui/styles.css +++ b/src/renderer/ui/styles.css @@ -1029,7 +1029,7 @@ body { 史书 ============================================================ */ .chronicle-list { - max-width: 760px; + max-width: 100%; background: linear-gradient(180deg, #f4ecd9, #e9dabc); color: var(--ink); border: 1px solid #b9a77e; @@ -1049,6 +1049,22 @@ body { .ch-item:last-child { border-bottom: none; } +.ch-yearbar { + display: flex; + align-items: baseline; + gap: 10px; + padding: 12px 4px 4px; + border-bottom: 1px solid rgba(140, 110, 60, 0.45); + color: #a04b33; + font-size: 1.04rem; + letter-spacing: 3px; + font-weight: 700; +} +.ch-month { + color: #8a7c5e; + min-width: 40px; + white-space: nowrap; +} .ch-year { color: #a04b33; white-space: nowrap;