From 2e6fa955b0b4e04704d5285dd1389b4ebaec9342 Mon Sep 17 00:00:00 2001 From: butubb <1422726308@qq.com> Date: Thu, 8 Oct 2026 13:57:44 +0800 Subject: [PATCH] =?UTF-8?q?feat(monitor):=20=E5=8D=9A=E4=B8=BB=E7=BB=84?= =?UTF-8?q?=E5=A4=B4=E8=A1=A5=E4=B8=8A=E6=8C=87=E6=A0=87=E5=90=88=E8=AE=A1?= =?UTF-8?q?=E4=B8=8E=E6=9C=AC=E8=BD=AE=E5=A2=9E=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 折叠之后组头只有「N 篇」,等于把信息藏了起来 —— 折叠应该意味着「收起来但仍可一眼读到」, 而不是「看不见」。现在组头与数据行列对齐,每个指标列给出该博主的合计,下面再带本轮增量 (那才是监控真正要看的)。 合计口径与项目一致:某个指标在所有作品上都是 null 时,合计是 null 而不是 0 —— 「0」是真实值、「null」是不知道,合计成 0 会让「还没采到」看起来像「互动为零」。 --- webui/src/components/monitor/NotesTable.tsx | 53 +++++++++++++++++++-- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/webui/src/components/monitor/NotesTable.tsx b/webui/src/components/monitor/NotesTable.tsx index c4464d9..1d15828 100644 --- a/webui/src/components/monitor/NotesTable.tsx +++ b/webui/src/components/monitor/NotesTable.tsx @@ -39,6 +39,41 @@ const METRIC_COLUMNS: Array<{ key: keyof NoteMetrics; label: string }> = [ { key: 'share_count', label: '分享' }, ] +/** + * 一个博主名下所有作品的指标合计。 + * + * **全为 null 时结果是 null 而不是 0** —— 与项目一贯的口径一致:「0」是真实值, + * 「null」是不知道。合计成 0 会让"还没采到"看起来像"互动为零"。 + */ +function sumMetrics(notes: MonitorNote[]) { + const values: Record = {} + const deltas: Record = {} + + for (const column of METRIC_COLUMNS) { + let sum = 0 + let sawValue = false + let deltaSum = 0 + let sawDelta = false + + for (const note of notes) { + const value = note.metrics[column.key] + if (value !== null && value !== undefined) { + sum += value + sawValue = true + } + const delta = note.deltas[column.key] + if (delta !== null && delta !== undefined) { + deltaSum += delta + sawDelta = true + } + } + + values[column.key] = sawValue ? sum : null + deltas[column.key] = sawDelta ? deltaSum : null + } + return { values, deltas } +} + // 多出来的那个空列给展开箭头;分组表头会跨掉整行。 const COLUMN_COUNT = METRIC_COLUMNS.length + 4 @@ -112,8 +147,11 @@ export function NotesTable({ taskId, onlyNew }: NotesTableProps) { {groups.map((group) => { const isCollapsed = collapsed.has(group.key) + const totals = sumMetrics(group.notes) return ( + {/* 组头与数据行**列对齐**:每个指标列给出该博主的合计,下面再带本轮增量。 + 折叠之后如果什么都看不到,那折叠就只是把信息藏起来了。 */} toggleCreator(group.key)} className="border-t border-cyber-border-subtle bg-cyber-bg-tertiary/50 cursor-pointer hover:bg-cyber-bg-elevated/50" @@ -125,18 +163,25 @@ export function NotesTable({ taskId, onlyNew }: NotesTableProps) { )} - + {group.name || '未知博主'} {group.notes.length} 篇 - {isCollapsed && ( - (已折叠) - )} + {METRIC_COLUMNS.map((column) => ( + + + + ))} + + {!isCollapsed &&