diff --git a/webui/src/components/monitor/CommentsFeed.tsx b/webui/src/components/monitor/CommentsFeed.tsx index d066c6b..af0b199 100644 --- a/webui/src/components/monitor/CommentsFeed.tsx +++ b/webui/src/components/monitor/CommentsFeed.tsx @@ -27,6 +27,8 @@ import { monitorApi } from '@/lib/api' import { formatRelative } from '@/lib/monitorFormat' import type { CommentBucket, MonitorComment } from '@/types/monitor' +import { NoteCover } from './NoteCover' + interface CommentsFeedProps { taskId: number | null } @@ -49,22 +51,7 @@ function NoteBadge({ }) { return (
- {cover ? ( - - ) : ( -
- )} + {title || noteId} diff --git a/webui/src/components/monitor/NoteCover.tsx b/webui/src/components/monitor/NoteCover.tsx new file mode 100644 index 0000000..7968292 --- /dev/null +++ b/webui/src/components/monitor/NoteCover.tsx @@ -0,0 +1,38 @@ +/** + * 作品封面缩略图。 + * + * `referrerPolicy="no-referrer"` 是功能性的,不是装饰。小红书的图床对带**外部 + * Referer** 的请求一律返回 403,而浏览器对跨域 `` 默认就会带上本站的源作为 + * Referer —— 于是封面全都显示成破图,而 URL 本身完全正常。实测同一张图: + * + * 无 Referer -> 200, 67968 B, image/webp + * Referer 为本站 -> 403, 0 B + * + * 放在一个组件里,是为了让下一个要显示封面的页面不会漏掉这个属性。 + */ + +const SIZES = { + sm: 'w-6 h-8', + md: 'w-8 h-10', + lg: 'w-12 h-16', +} as const + +export function NoteCover({ + src, + size = 'md', + className = '', +}: { + src?: string + size?: keyof typeof SIZES + className?: string +}) { + const base = `rounded object-cover bg-cyber-bg-tertiary flex-shrink-0 ${SIZES[size]} ${className}` + + // 占位块是必要的:作品在首轮采集前没有封面,若此时不占位,行高会随着封面陆续 + // 到达而跳动。 + if (!src) return
+ + return ( + + ) +} diff --git a/webui/src/components/monitor/NotesTable.tsx b/webui/src/components/monitor/NotesTable.tsx index 12e614a..c3a0373 100644 --- a/webui/src/components/monitor/NotesTable.tsx +++ b/webui/src/components/monitor/NotesTable.tsx @@ -5,6 +5,7 @@ import { Badge } from '@/components/ui/badge' import { useMonitorNotes } from '@/hooks/useMonitor' import { formatCount, formatDelta, formatRelative } from '@/lib/monitorFormat' import type { MonitorNote, NoteMetrics } from '@/types/monitor' +import { NoteCover } from './NoteCover' import { NoteTrendChart } from './NoteTrendChart' interface NotesTableProps { @@ -89,18 +90,24 @@ export function NotesTable({ taskId, onlyNew }: NotesTableProps) { {open ? : } -
- {note.is_new && ( - - NEW - - )} - - {note.title || note.note_id} - -
-
- {note.note_id} · {note.snapshot_count} 次快照 +
+ + {/* min-w-0 so the title can actually truncate inside the flex row */} +
+
+ {note.is_new && ( + + NEW + + )} + + {note.title || note.note_id} + +
+
+ {note.note_id} · {note.snapshot_count} 次快照 +
+
{METRIC_COLUMNS.map((column) => (