()
+
+ // **先放博主,不是先放作品。** 「一条作品都没有的博主」在作品里根本推不出来 ——
+ // 目标加了、资料也采到了、粉丝数就躺在库里,可界面上什么都看不见。而他恰恰是最该
+ // 看见的一个:还在涨粉,只是最近没发东西。
+ for (const creator of creators ?? []) {
+ const key = creator.creator_hash || '__unknown__'
+ const existing = byCreator.get(key)
+ if (existing) {
+ // 同一个博主可能挂在多个任务下(服务端按 任务×博主 给),合并成一组。
+ existing.totalNotes += creator.note_count
+ if (!existing.stats?.creator_stats_at && creator.creator_stats_at) {
+ existing.stats = creator
+ }
+ existing.name ||= creator.creator_name
+ // 备注按 (platform, creator_hash) 存,所以跨任务就是同一条,取到即可。
+ existing.alias ||= creator.creator_alias
+ continue
+ }
+ byCreator.set(key, {
+ key,
+ name: creator.creator_name || '',
+ alias: creator.creator_alias || '',
+ totalNotes: creator.note_count,
+ stats: creator,
+ notes: [],
+ })
+ }
+
for (const note of notes ?? []) {
// 作品模式下每条作品都会带 creator_hash;真丢了也要有个兜底分组,
// 否则那些作品会凭空消失。
const key = note.creator_hash || '__unknown__'
- if (!byCreator.has(key)) {
- byCreator.set(key, {
+ let group = byCreator.get(key)
+ if (!group) {
+ group = {
key,
name: note.creator_name || '',
alias: note.creator_alias || '',
+ totalNotes: 0,
+ stats: null,
notes: [],
- })
+ }
+ byCreator.set(key, group)
}
- byCreator.get(key)!.notes.push(note)
+ group.notes.push(note)
+ group.name ||= note.creator_name || ''
+ group.alias ||= note.creator_alias || ''
}
+
return [...byCreator.values()]
- }, [notes])
+ }, [notes, creators])
if (isLoading) {
return 加载中…
}
- if (!notes || notes.length === 0) {
+ // 博主有、作品没有也是**要画**的:那正是「这个号还没被删,只是没发东西」。
+ if (groups.length === 0) {
return (
{taskId === null
@@ -266,17 +321,18 @@ export function NotesTable({ taskId, onlyNew }: NotesTableProps) {
{group.name}
)}
- {group.notes.length} 篇
+ {/* 被 onlyNew 滤过时,把「显示了几篇 / 一共几篇」都说出来,
+ 否则「1 篇」会让人以为这个号只发过一条。 */}
+ {group.notes.length}
+ {group.totalNotes > group.notes.length && `/${group.totalNotes}`} 篇
- {/* 账号级指标是按 (任务, 博主) 存的,而分组只按博主 —— 同一个博主
- 被两个任务监控时,组里可能只有一部分作品带指标。优先挑带指标的那条,
- 否则「第一个任务还没采过」会让整组看起来没有指标。 */}
- note.creator_stats_at !== null) ??
- group.notes[0]
- }
- />
+ {group.stats && }
+ {/* 博主在、作品一条都没有 —— 说清楚,别让人以为列表挂了。 */}
+ {group.notes.length === 0 && (
+
+ 暂无作品
+
+ )}