Peach: Local-first video metadata scraper and media manager.
fix(web): 关注页、详情与关注管理在极端内容下不撑宽、不失控
longmeidao1ece55430b6e
diff --git a/frontend/e2e/design-fixture.ts b/frontend/e2e/design-fixture.tsindex dad508ed8..d3084e5a6 100644--- a/frontend/e2e/design-fixture.ts+++ b/frontend/e2e/design-fixture.ts@@ -443,16 +443,17 @@ export const followCredential = (provider: string, requirement: string, present:/** 关注管理页按一份造好的来源与凭据打开:演示库没有关注来源,也凑不齐四种凭据处境。* 站标同 `openScraping`:造出来的来源取不到图标,给一张能加载完的图。 */-export async function openFollowManage(browser: Browser, viewport = DESKTOP): Promise<Visit> {+export async function openFollowManage(browser: Browser, viewport = DESKTOP, counts?: Record<string, number>): Promise<Visit> {const opened = await visit(browser, '/follow-manage', viewport);- await stubFollowManage(opened.page);+ await stubFollowManage(opened.page, counts);await opened.page.reload({ waitUntil: 'load' });await opened.page.locator('section[aria-label="kou 的关注来源"]').waitFor({ timeout: 15_000 });await settle(opened.page);return opened;}-export async function stubFollowManage(page: Page): Promise<void> {+export async function stubFollowManage(page: Page,+ counts: Record<string, number> = { new: 0, seen: 0, saved: 0, ignored: 0 }): Promise<void> {const json = (body: unknown) => ({ status: 200, contentType: 'application/json', body: JSON.stringify(body) });await page.route('**/api/follow?summary=1', (route) => route.fulfill(json({sources: [@@ -460,7 +461,7 @@ export async function stubFollowManage(page: Page): Promise<void> {followSource(2, 'kou', 'Pawchive', 'kou · Pawchive'),followSource(3, 'mira', 'Kemono', 'mira · Kemono', 'error'),],- counts: { new: 0, seen: 0, saved: 0, ignored: 0 },+ counts,author_aliases: [{ canonical_key: 'kou', canonical_name: 'kou', aliases: [{ key: 'kou_art', name: 'kou_art' }] }],alias_suggestions: [],suggestions: [],diff --git a/frontend/e2e/design-manage.test.ts b/frontend/e2e/design-manage.test.tsindex 778a06090..150bf5e10 100644--- a/frontend/e2e/design-manage.test.ts+++ b/frontend/e2e/design-manage.test.ts@@ -753,6 +753,31 @@ describe('设计决定:数据管理、索引页与资料页头', () => {});}+ for (const viewport of [DESKTOP, { ...MOBILE, name: 'narrow', width: 320 }]) {+ it(`七位数的读数留在卡里,来源行的时间、开关与操作键不越出行(${viewport.name})`, { timeout: 60_000 }, async () => {+ const opened = await openFollowManage(browser, viewport, { new: 1284000, seen: 22000, saved: 0, ignored: 0 });+ try {+ const spill = await opened.page.evaluate(() => {+ const out = (node: Element, frame: Element) => node.getBoundingClientRect().right > frame.getBoundingClientRect().right + 1;+ const readings = [...document.querySelectorAll('[data-follow-reading]')]+ .filter((node) => [...node.children].some((part) => out(part, node.parentElement!)))+ .map((node) => node.textContent);+ const rows = [...document.querySelectorAll('[data-follow-source-row]')]+ .filter((row) => row.scrollWidth > row.clientWidth + 1 || [...row.querySelectorAll('button, [role="switch"], input')]+ .some((control) => out(control, row)))+ .map((row) => row.textContent);+ return { readings, rows, text: document.querySelector('[data-follow-reading]')?.parentElement?.parentElement?.textContent };+ });+ assert.ok(spill.text?.includes('1,284,000'), `读数没有用上七位数:${spill.text}`);+ assert.deepEqual(spill.readings, [], '读数越出了卡片');+ assert.deepEqual(spill.rows, [], '来源行的控件越出了行');+ assert.deepEqual(opened.problems, []);+ } finally {+ await opened.close();+ }+ });+ }+it('凭据的四种处境四副底色:待办和完成一眼分得开', { timeout: 60_000 }, async () => {const opened = await openFollowManage(browser);try {diff --git a/frontend/e2e/follow-detail.test.ts b/frontend/e2e/follow-detail.test.tsindex 6f5661e28..ecdbc0bd3 100644--- a/frontend/e2e/follow-detail.test.ts+++ b/frontend/e2e/follow-detail.test.ts@@ -316,4 +316,36 @@ describe('关注详情岛', () => {await opened.close();}});++ for (const viewport of [DESKTOP, MOBILE]) {+ it(`长摘要收在八行内、不被侧栏压扁,长串标题与媒体报错不撑宽侧栏(${viewport.name})`, { timeout: 60_000 }, async () => {+ const opened = await openDetail(browser, DETAIL.long, viewport);+ try {+ const page = opened.page;+ const measure = () => page.evaluate(() => {+ const side = document.querySelector('#stage [data-stage-side-content]')!;+ const summary = document.querySelector<HTMLElement>('#stage [data-follow-detail-summary]')!;+ const lineHeight = parseFloat(getComputedStyle(summary).lineHeight);+ const right = side.getBoundingClientRect().right;+ const inside = ['[data-follow-detail-name]', '[data-follow-detail-summary]', '[data-follow-media-issue]']+ .map((selector) => document.querySelector(`#stage ${selector}`)!.getBoundingClientRect().right)+ .every((edge) => edge <= right + 1);+ return { lines: summary.clientHeight / lineHeight, inside, scroll: side.scrollWidth, width: side.clientWidth };+ });+ const folded = await measure();+ assert.ok(folded.lines >= 7.5 && folded.lines <= 8.5, `收起的摘要不是八行:${JSON.stringify(folded)}`);+ assert.ok(folded.inside && folded.scroll <= folded.width, `侧栏被撑宽:${JSON.stringify(folded)}`);+ const toggle = page.locator('#stage [data-follow-summary-toggle]');+ assert.equal((await toggle.innerText()).trim(), '展开');+ await toggle.click();+ const open = await measure();+ assert.ok(open.lines > 20, `展开后摘要没有全部露出:${JSON.stringify(open)}`);+ assert.ok(open.inside && open.scroll <= open.width, `展开后侧栏被撑宽:${JSON.stringify(open)}`);+ assert.deepEqual((await layout(page)).offenders, [], '详情里有元素越出视口右边');+ assert.deepEqual(withoutPlayer(opened.problems), []);+ } finally {+ await opened.close();+ }+ });+ }});diff --git a/frontend/e2e/follow-fixture.ts b/frontend/e2e/follow-fixture.tsindex 727d62a20..166d0f3fa 100644--- a/frontend/e2e/follow-fixture.ts+++ b/frontend/e2e/follow-fixture.ts@@ -70,9 +70,10 @@ const gallery = (id: number, count: number, title: string) => item(id, 1, {title, media_kind: 'image', thumb_url: `/stub-thumb/${id}-0`, duration: null, media_type: 'image/jpeg', width: 600,height: 800, media_items: Array.from({ length: count }, (_, index) => still(id, index)),});-/** 多图轮播、视频合集(另一版加另一站的同一条)、一帖多媒体、带两张已隐藏图的帖子,以及一条- * 没有任何预览、标签六种类型各一枚的帖子。 */-export const DETAIL = { gallery: 5001, collection: 5101, media: 5201, hidden: 5301, bare: 5401 } as const;+/** 多图轮播、视频合集(另一版加另一站的同一条)、一帖多媒体、带两张已隐藏图的帖子、一条+ * 没有任何预览、标签六种类型各一枚的帖子,以及摘要、标题与媒体报错都是不换行长串的帖子。 */+export const DETAIL = { gallery: 5001, collection: 5101, media: 5201, hidden: 5301, bare: 5401, long: 5501 } as const;+const UNBROKEN = 'abcdef0123456789'.repeat(12);const TYPED_TAGS = { ow: 'copyright', tracer: 'character', kou: 'artist', solo: 'general', animated: 'metadata', odd: 'unknown' };const DETAIL_GROUPS = [group(gallery(5001, 3, '三张图的帖子 5001')),@@ -89,6 +90,11 @@ const DETAIL_GROUPS = [media_type: null, duration: null, tags: Object.keys(TYPED_TAGS), detail_tags: Object.keys(TYPED_TAGS),tag_types: TYPED_TAGS,})),+ group(item(5501, 0, {+ title: `长串帖子_${UNBROKEN}`,+ summary: [...Array.from({ length: 20 }, (_, at) => `第 ${at + 1} 段说明文字。`), `下载:https://example.invalid/${UNBROKEN}`].join('\n'),+ media_error: `403 Forbidden: https://n1.example.invalid/data/${UNBROKEN}.mp4`,+ })),];const members = (row: (typeof DETAIL_GROUPS)[number]) => [row.primary, ...row.variants, ...row.duplicates];const detailMediaKind = (id: number, index: number) => DETAIL_GROUPS.flatMap(members)diff --git a/frontend/src/board-skeleton.ts b/frontend/src/board-skeleton.tsindex c3b31408f..acd8b74ae 100644--- a/frontend/src/board-skeleton.ts+++ b/frontend/src/board-skeleton.ts@@ -9,7 +9,7 @@ const lines = () => `${line('80%')}${line('48%')}`;const repeat = (html: string, count: number) => html.repeat(count);const metrics = (labels: string[], className = 'metricstrip') => `<div class="${className}">${labels.map(label => `<div class="tastesummary"><span class="board-stat-label">${label}</span><b class="board-stat-value">${line('45%')}</b><small class="board-stat-footer">${line('60%')}</small></div>`).join('')}</div>`;const segments = (labels: string[], className: string) => `<div class="${className} skeleton-segments" data-board-segments="true">${labels.map((label,index) => `<span${index===0?' class="skeleton-segment-selected"':''}>${label}</span>`).join('')}</div>`;-const panel = (title: string) => `<section class="ui-insightpanel"><header>${title}</header><div class="ui-insightpanelbody ui-skeleton-lines">${repeat(lines(), 3)}</div></section>`;+const panel = (title: string) => `<section class="insightpanel"><header>${title}</header><div class="insightpanelbody skeleton-lines">${repeat(lines(), 3)}</div></section>`;/* 关注管理整页归 React,骨架整块画在 `.peach-react` 里,容器与按键都取 React 那侧渲染出的同一串类名(`react/follow-manage/`、`react/components/` 与 `island-skeleton.ts`):页面那一列、读数带、分段控件、关注列表那张填充卡、创作者卡、来源行和表格外框。只有等数据的读数画占位条。@@ -22,7 +22,10 @@ const block = (width: number, height: number, round = false) =>`<span class="skeleton" style="width:${width}px;height:${height}px;flex:none${round ? ';border-radius:50%' : ''}"></span>`;const STAT = 'min-w-0 bg-background-secondary-default rounded-2xl shadow-card flex flex-col gap-3 px-6 py-5 max-sm:gap-2 max-sm:p-4';const followReadings = () => `<div class="inline-grid w-full grid-cols-2 gap-3 sm:grid-cols-3 sm:gap-4 xl:grid-cols-6">${['关注创作者', '启用来源', '检查失败', '未看更新', 'JAV 订阅', '未看新作'].map(term => `<div class="${STAT}"><span class="text-body-medium text-text-secondary">${term}</span><b class="text-title-1-medium tabular-nums text-text-primary">${text('3em')}</b></div>`).join('')}</div>`;-const followTabs = () => `<div data-section-nav data-section-items class="flex max-w-full flex-nowrap overflow-x-auto">${['关注列表', '添加关注', 'JAV 订阅源', '想要', '来源和凭证'].map((name, at) => `<span class="whitespace-nowrap" aria-selected="${at === 0}">${name}</span>`).join('')}</div>`;+/** 页签与 React `follow-manage-page.tsx` 的 `TABS` 同名同序;选中的是地址栏 `?tab=` 那一枚,认不出时是第一枚。 */+const FOLLOW_TABS = [['list', '关注列表'], ['add', '添加关注'], ['feeds', 'JAV 订阅源'], ['wants', 'JAV 入库'], ['source', '来源和凭证']] as const;+const followTabKey = (tab = '') => (FOLLOW_TABS.some(([key]) => key === tab) ? tab : 'list');+const followTabs = (tab: string) => `<div data-section-nav data-section-items class="flex max-w-full flex-nowrap overflow-x-auto">${FOLLOW_TABS.map(([key, name]) => `<span class="whitespace-nowrap" aria-selected="${key === tab}">${name}</span>`).join('')}</div>`;/** Board UI `Checkbox` 的未勾静止态;给了字就是「全选本页」那种带标签的一枚。 */const followCheck = (label = '') => `<span class="group inline-flex items-center select-none gap-2"><span class="flex shrink-0 items-center justify-center rounded-sm size-4 border bg-background-primary-default shadow-xs border-border-checkbox-default"></span>${label ? `<span class="text-body-medium text-text-primary">${label}</span>` : ''}</span>`;@@ -32,14 +35,14 @@ const followCheck = (label = '') => `<span class="group inline-flex items-centerinterface FollowToolbar { table: boolean; sort: SortKey; dir: SortDir }const followToolbar = ({ table, sort, dir }: FollowToolbar) => {const name = SORT_OPTIONS.find(([key]) => key === sort)![1];- return `<div class="flex flex-wrap items-center gap-2 ui-follow-skeleton-toolbar"><h3 class="mr-auto text-title-2-medium text-text-primary">关注列表</h3><span class="text-body-2-regular text-text-secondary">${text('132px')}</span>${islandButton({ glyph: 'refresh-cw', label: '检查全部', compact: true, attrs: WAITING })}<span data-button-group role="group">${islandButton({ variant: 'ghost', glyph: 'layout-grid', attrs: `aria-pressed="${!table}"` })}${islandButton({ variant: 'ghost', glyph: 'table', attrs: `aria-pressed="${table}"` })}</span>${islandSelect(name)}${islandButton({ variant: 'secondary', glyph: dir === 'asc' ? 'arrow-up' : 'arrow-down' })}${table ? '' : islandButton({ variant: 'secondary', glyph: 'chevron-up', label: '全部收起', compact: true, attrs: WAITING })}</div>`;+ return `<div class="flex flex-wrap items-center gap-2 follow-skeleton-toolbar"><span class="contents max-sm:flex max-sm:min-w-0 max-sm:flex-1 max-sm:flex-col"><h3 class="mr-auto text-title-2-medium text-text-primary">关注列表</h3><span class="text-body-2-regular text-text-secondary">${text('132px')}</span></span>${islandButton({ glyph: 'refresh-cw', label: '检查全部', compact: true, attrs: WAITING })}<span class="contents max-sm:flex max-sm:w-full max-sm:items-center max-sm:gap-2"><span data-button-group role="group">${islandButton({ variant: 'ghost', glyph: 'layout-grid', attrs: `aria-pressed="${!table}"` })}${islandButton({ variant: 'ghost', glyph: 'table', attrs: `aria-pressed="${table}"` })}</span>${islandSelect(name)}${islandButton({ variant: 'secondary', glyph: dir === 'asc' ? 'arrow-up' : 'arrow-down' })}${table ? '' : islandButton({ variant: 'secondary', glyph: 'chevron-up', label: '全部收起', compact: true, attrs: WAITING })}</span></div>`;};/** 行尾那对动作键:检查这一条的更新、移除这一条,与 React `SourceRow` 同为小号次级纯图标键。 */const followRowActions = () => `<span class="flex shrink-0 items-center gap-1">${islandButton({ variant: 'secondary', size: 'small', glyph: 'refresh-cw', attrs: WAITING })}${islandButton({ variant: 'secondary', size: 'small', glyph: 'trash', attrs: WAITING })}</span>`;/** 一条来源:勾选、名字、站点图标、状态徽章、上次检查、动作,与 React `SourceRow` 同一串类名。 */-const followRow = () => `<div class="flex min-h-16 flex-wrap items-center gap-3 px-2 py-3 follow-skeleton-source">${followCheck()}<span class="flex min-w-0 grow flex-col gap-0.5"><span class="text-body-medium">${text('8em')}</span></span><span class="flex shrink-0 items-center gap-1.5">${block(14, 14)}</span>${block(48, 24)}<span class="shrink-0 text-body-2-regular whitespace-nowrap text-text-secondary">${text('113px')}</span>${followRowActions()}</div>`;+const followRow = () => `<div class="flex min-h-16 flex-wrap items-center gap-3 px-2 py-3 max-sm:gap-x-2 follow-skeleton-source">${followCheck()}<span class="flex min-w-0 grow flex-col gap-0.5"><span class="text-body-medium">${text('8em')}</span></span><span class="flex shrink-0 items-center gap-1.5">${block(14, 14)}</span>${block(48, 24)}<span class="contents max-sm:flex max-sm:w-full max-sm:flex-wrap max-sm:items-center max-sm:gap-1.5"><span class="shrink-0 text-body-2-regular whitespace-nowrap text-text-secondary max-sm:mr-auto max-sm:text-caption-1-regular">${text('113px')}</span>${followRowActions()}</span></div>`;/** 一位创作者一张 raised 卡:头行是头像、名字、检查、站点图标、全选、收起,底下是来源行。 */-const followAuthor = (rows: number) => `<section class="min-w-0 bg-background-primary-default rounded-2xl shadow-card flex flex-col overflow-hidden p-2 follow-skeleton-author"><div class="flex flex-wrap items-center gap-3 px-2 py-2.5" data-follow-author-header data-open>${block(32, 32, true)}<b class="min-w-0 grow text-body-medium break-words text-text-primary">${text('92px')}</b>${islandButton({ variant: 'secondary', size: 'small', glyph: 'refresh-cw', attrs: WAITING })}<span class="flex shrink-0 items-center gap-1">${block(14, 14)}${block(14, 14)}</span>${islandButton({ variant: 'secondary', size: 'small', glyph: 'check-check', label: '全选', attrs: WAITING })}${islandButton({ variant: 'secondary', size: 'small', glyph: 'chevron-up', label: '收起', attrs: WAITING })}</div><div data-source-divider>${repeat(followRow(), rows)}</div></section>`;+const followAuthor = (rows: number) => `<section class="min-w-0 bg-background-primary-default rounded-2xl shadow-card flex flex-col overflow-hidden p-2 follow-skeleton-author"><div class="flex flex-wrap items-center gap-3 px-2 py-2.5" data-follow-author-header data-open>${block(32, 32, true)}<b class="min-w-0 grow text-body-medium wrap-anywhere text-text-primary max-sm:basis-0">${text('92px')}</b>${islandButton({ variant: 'secondary', size: 'small', glyph: 'refresh-cw', attrs: WAITING })}<span class="contents max-sm:flex max-sm:w-full max-sm:items-center max-sm:gap-2"><span class="flex shrink-0 items-center gap-1 max-sm:mr-auto">${block(14, 14)}${block(14, 14)}</span>${islandButton({ variant: 'secondary', size: 'small', glyph: 'check-check', label: '全选', attrs: WAITING })}${islandButton({ variant: 'secondary', size: 'small', glyph: 'chevron-up', label: '收起', attrs: WAITING })}</span></div><div data-source-divider>${repeat(followRow(), rows)}</div></section>`;/** 表格骨架画多少行由每页条数决定,写死一个数会在别的页大小上多留或少留一屏。* 偏好存在旧层那份 `peach.settings.v1` 里,直接读它:骨架跑在 island 挂载之前,* 这时候页面自己的状态还不存在。 */@@ -64,20 +67,25 @@ const followTable = (rows: number, { sort, dir }: { sort: SortKey; dir: SortDir};/** 分页行:条数与页码要等数据,每页几条是这台浏览器的偏好,照最终的字样写出来。 */const followPager = (table: boolean, size: number) => `<div class="flex flex-wrap items-center justify-between gap-3"><span class="text-body-2-regular text-text-secondary">${text('111px')}</span>${islandSelect(`每页 ${size} ${table ? '条' : '位'}`, { size: 'sm' })}${block(204, 32)}</div>`;-const followList = (options: { followLayout?: string; followPageSize?: number; followSort?: string; followDir?: string }) => {+/** 关注列表以外的页签:内容各不相同、要等数据才知道长什么样,只画那张填充卡和几行占位。 */+const followPanel = () => `<div class="min-w-0 bg-background-secondary-default rounded-2xl shadow-card flex flex-col gap-4 px-6 py-5 max-sm:px-4 follow-skeleton-surface"><h3 class="text-title-2-medium text-text-primary">${text('120px')}</h3>${['72%', '56%', '64%', '40%'].map((width) => `<span class="text-body-medium">${text(width)}</span>`).join('')}</div>`;+type FollowSkeletonOptions = { followLayout?: string; followPageSize?: number; followSort?: string; followDir?: string; followTab?: string };+const followList = (options: FollowSkeletonOptions) => {+ const tab = followTabKey(options.followTab);+ if (tab !== 'list') return `<div class="peach-react"><div class="mx-auto flex w-full max-w-board flex-col gap-8">${followReadings()}<div class="flex flex-col gap-6">${followTabs(tab)}<div class="flex flex-col gap-4">${followPanel()}</div></div></div></div>`;const table = options.followLayout === 'table';const order = resolveFollowSort(options.followSort, options.followDir);const size = options.followPageSize || followPageSize();const content = table? followTable(size, order): `${followCheck('全选本页')}<div class="flex flex-col gap-3">${followAuthor(3)}${followAuthor(4)}${followAuthor(3)}</div>`;- return `<div class="peach-react"><div class="mx-auto flex w-full max-w-board flex-col gap-8">${followReadings()}<div class="flex flex-col gap-6">${followTabs()}<div class="flex flex-col gap-4"><div class="min-w-0 bg-background-secondary-default rounded-2xl shadow-card flex flex-col gap-4 px-6 py-5 max-sm:px-4 ui-follow-skeleton-surface" data-layout="${table ? 'table' : 'default'}">${followToolbar({ table, ...order })}${content}${followPager(table, size)}</div></div></div></div></div>`;+ return `<div class="peach-react"><div class="mx-auto flex w-full max-w-board flex-col gap-8">${followReadings()}<div class="flex flex-col gap-6">${followTabs(tab)}<div class="flex flex-col gap-4"><div class="min-w-0 bg-background-secondary-default rounded-2xl shadow-card flex flex-col gap-4 px-6 py-5 max-sm:px-4 follow-skeleton-surface" data-layout="${table ? 'table' : 'default'}">${followToolbar({ table, ...order })}${content}${followPager(table, size)}</div></div></div></div></div>`;};/** 详情骨架外层 `[data-skeleton="detail"]` 里面那一格:舞台岛自己画外层,里面照这一份写。格子与详情栏* 的几何是舞台的(`react/stage/stage.css`),骨架的底色与行距是壳的 `skeleton` 一族。 */export function detailSkeletonBody(): string {- return `<div data-stage-grid="" aria-hidden="true"><div data-stage-media="" class="ui-skeleton-detail-media skeleton"></div><aside data-stage-side=""><div data-stage-side-content="" class="ui-skeleton-lines">${line('85%')}${line('65%')}${repeat(lines(), 4)}</div></aside></div>`;+ return `<div data-stage-grid="" aria-hidden="true"><div data-stage-media="" class="skeleton-detail-media skeleton"></div><aside data-stage-side=""><div data-stage-side-content="" class="skeleton-lines">${line('85%')}${line('65%')}${repeat(lines(), 4)}</div></aside></div>`;}export function detailSkeletonHtml(): string {@@ -85,25 +93,25 @@ export function detailSkeletonHtml(): string {}export function boardPageSkeleton(- path: string, options: {followLayout?: string; followPageSize?: number; followSort?: string; followDir?: string} = {},+ path: string, options: FollowSkeletonOptions = {},): string {let body = '';if (path === '/stats') {body = statsSkeleton();} else if (path === '/taste') {- body = `<div class="tastepage"><header class="ui-tastehead">${segments(['浏览器记录', 'Peach 内部'], 'insightswitch')}${line('24%')}</header><div class="ui-tastestate"></div>${metrics(['浏览记录', '口味维度', '浏览候选', '私有导出'], 'ui-tastesummaries')}<section class="ui-tastehero"><div class="insightcopy"><span>浏览器画像</span><div class="skeleton ui-skeleton-radar"></div></div><div class="ui-tastebars ui-skeleton-lines">${repeat(lines(), 4)}</div></section>${panel('口味分析')}<div class="ui-board-activity-charts">${panel('浏览活动')}${panel('时间分布')}</div>${panel('标签')}</div>`;+ body = `<div class="tastepage"><header class="tastehead">${segments(['浏览器记录', 'Peach 内部'], 'insightswitch')}${line('24%')}</header><div class="tastestate"></div>${metrics(['浏览记录', '口味维度', '浏览候选', '私有导出'], 'tastesummaries')}<section class="tastehero"><div class="insightcopy"><span>浏览器画像</span><div class="skeleton skeleton-radar"></div></div><div class="tastebars skeleton-lines">${repeat(lines(), 4)}</div></section>${panel('口味分析')}<div class="board-activity-charts">${panel('浏览活动')}${panel('时间分布')}</div>${panel('标签')}</div>`;} else if (path === '/follow-manage') {body = followList(options);} else if (path === '/configuration') {body = configurationSkeleton();} else if (path === '/activity') {- body = `<div class="ui-activitypage">${['正在进行', '被挡下的', '最近完成'].map(title => `<section class="activitysection"><h3 class="geist-fieldset-title">${title}</h3><div class="ui-activity-runs"><article class="cleanupfieldset activity-run"><div class="geist-fieldset-content ui-skeleton-lines">${line('35%')}${lines()}</div></article></div></section>`).join('')}</div>`;+ body = `<div class="activitypage">${['正在进行', '被挡下的', '最近完成'].map(title => `<section class="activitysection"><h3 class="geist-fieldset-title">${title}</h3><div class="activity-runs"><article class="cleanupfieldset activity-run"><div class="geist-fieldset-content skeleton-lines">${line('35%')}${lines()}</div></article></div></section>`).join('')}</div>`;} else if (path === '/duplicates') {body = duplicatesSkeleton();} else if (path === '/quality-goals') {body = qualityGoalsSkeleton();} else if (path === '/playlists') {- body = `<section class="ui-playlistpage"><header><div><h2>播放列表</h2><p>保存 Mix,按自己的顺序继续播放。</p></div><div class="playlistcreate ui-skeleton-lines"><span>新播放列表</span>${line('200px')}</div></header><div class="ui-playlistcards">${repeat(`<article class="card playlistcard"><div class="mixstack"><div class="pic skeleton"></div></div><div class="mixmeta"><span class="mav skeleton"></span><div class="mixcopy ui-skeleton-lines">${lines()}</div></div></article>`, 6)}</div></section>`;+ body = `<section class="playlistpage"><header><div><h2>播放列表</h2><p>保存 Mix,按自己的顺序继续播放。</p></div><div class="playlistcreate skeleton-lines"><span>新播放列表</span>${line('200px')}</div></header><div class="playlistcards">${repeat(`<article class="card playlistcard"><div class="mixstack"><div class="pic skeleton"></div></div><div class="mixmeta"><span class="mav skeleton"></span><div class="mixcopy skeleton-lines">${lines()}</div></div></article>`, 6)}</div></section>`;} else return '';return `<div class="board-page-skeleton" data-skeleton="board${path}" role="status" aria-label="正在读取页面"><div aria-hidden="true" inert>${body}</div></div>`;}diff --git a/frontend/src/react/follow-detail/follow-detail-page.tsx b/frontend/src/react/follow-detail/follow-detail-page.tsxindex 1b4b693ec..f3a02265b 100644--- a/frontend/src/react/follow-detail/follow-detail-page.tsx+++ b/frontend/src/react/follow-detail/follow-detail-page.tsx@@ -10,8 +10,11 @@import { useCallback, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';import { useMutation, useQuery } from '@tanstack/react-query';import { esc, fmtDur, foldName, icon, requestErrorMessage } from '@peach/legacy/core';+import { noteHtml } from '@peach/legacy/ui';-import { apiSend } from '../../api';+import { Button } from '@/components/base/buttons/button';++import { ApiError, apiSend } from '../../api';import { RetryNote } from '../components/grid-reveal';import { MixGroupLabel, MixQueue, MixQueueRow } from '../components/mix-queue';import {@@ -19,20 +22,22 @@ import {type FollowContext, type FollowFeedHelpers, type FollowGroup,} from '../follow-feed/follow-feed';import {- followBadges, followIdentity, followMediaIssue, followTitleMarks, followWhen, sourceIcon,+ followBadges, followIdentity, followMediaIssue, followTitle, followTitleMarks, followWhen, sourceIcon,} from '../follow-feed/follow-marks';import { FOLLOW_STATUS_URL } from '../follow-manage/follow-manage';import { openPhotoLightbox } from '../photo-lightbox/photo-lightbox-dialog';import { queryClient } from '../query';import { addWant, fetchFollowWant, invalidateWants, removeWants, wantFollowKey, type Want } from '../wants/wants';import {- FOLLOW_MEDIA_HIDE_URL, FOLLOW_SAVE_URL, authorSources, collectionCopy, detailContext, detailMedia, detailSlides,+ FOLLOW_MEDIA_HIDE_URL, FOLLOW_SAVE_URL, FollowItemGone, authorSources, collectionCopy, detailContext, detailMedia, detailSlides,detailTags, fetchFollowItem, followItemKey, groupedMediaOwner, mediaName, resourceLabel, statusReceipt, tagCategory,type DetailMedia, type FollowDetailActions, type FollowDetailData, type FollowDetailItem, type FollowDetailMedia,type FollowDetailProps,} from './follow-detail';const realDuration = (value: unknown) => Number(value) > 0;+/** 轮播张数多于它时,圆点条换成「当前 / 总数」:1280 宽下四十来个点就碰到画框边了。 */+export const FOLLOW_DOTS_MAX = 20;/** 字形原样取壳那一份 `icon()`:骨架与遗留详情画的就是它,换成别的字形接管那一拍会跳。 */const Glyph = ({ name }: { name: string }) => (@@ -58,7 +63,9 @@ export function FollowDetailPage(props: FollowDetailProps) {<CloseStage onClose={actions.close} /><div data-follow-detail-placeholder="">{result.isError- ? <RetryNote message={requestErrorMessage(result.error)} onRetry={() => void result.refetch()} />+ ? gone(result.error)+ ? <GoneNote onBack={actions.close} />+ : <RetryNote message={requestErrorMessage(result.error)} onRetry={() => void result.refetch()} />: null}</div></div>@@ -71,6 +78,17 @@ export function FollowDetailPage(props: FollowDetailProps) {);}+const gone = (error: unknown) => error instanceof FollowItemGone || (error instanceof ApiError && error.status === 404);++/** 条目已经不在了:重试取不回来,只给一条回到关注页的路。 */+function GoneNote({ onBack }: { onBack(): void }) {+ return (+ <div data-follow-detail-gone="" onClick={(event) => {+ if ((event.target as HTMLElement).closest('[data-note-action]')) onBack();+ }} dangerouslySetInnerHTML={{ __html: noteHtml('这条关注内容已不存在,可能已被来源删除或已清理。', { actionLabel: '回到关注' }) }} />+ );+}+/** 关闭键。`id` 留着:Escape、点浮窗外面与壳的兜底都按 `#closeStage` 找它再点一下。 */const CloseStage = ({ onClose }: { onClose(): void }) => (<button type="button" data-stage-close="" id="closeStage" title="关闭" aria-label="关闭" onClick={onClose}@@ -190,14 +208,20 @@ function MediaFrame({ item, media, actions, onMedia, issues }: {onClick={() => step(-1)} dangerouslySetInnerHTML={{ __html: icon('chevron-left') }} /><button type="button" data-follow-image-step="1" data-follow-image-arrow="next" aria-label="下一张图片" title="下一张"onClick={() => step(1)} dangerouslySetInnerHTML={{ __html: icon('chevron-right') }} />- <div data-follow-image-dots="" role="group" aria-label={`${images.length} 张图片`}>- {images.map((image, index) => (- <button type="button" key={image.index} data-follow-image-item={image.index}- aria-current={index === position ? 'true' : 'false'}- aria-label={`第 ${index + 1} 张,共 ${images.length} 张`} title={`第 ${index + 1} 张`}- onClick={() => onMedia(image.index)} />- ))}- </div>+ {images.length > FOLLOW_DOTS_MAX ? (+ <span data-follow-image-count="" aria-live="polite" aria-label={`第 ${position + 1} 张,共 ${images.length} 张`}>+ {`${(position + 1).toLocaleString()} / ${images.length.toLocaleString()}`}+ </span>+ ) : (+ <div data-follow-image-dots="" role="group" aria-label={`${images.length} 张图片`}>+ {images.map((image, index) => (+ <button type="button" key={image.index} data-follow-image-item={image.index}+ aria-current={index === position ? 'true' : 'false'}+ aria-label={`第 ${index + 1} 张,共 ${images.length} 张`} title={`第 ${index + 1} 张`}+ onClick={() => onMedia(image.index)} />+ ))}+ </div>+ )}</>) : null}</div>@@ -230,7 +254,7 @@ function CollectionQueue({ group, itemId, helpers, actions }: {const listRef = useDragRow(helpers);return (<MixQueue kind="collection" data-follow-queue="" title="视频合集" onClose={actions.close} listRef={listRef}- summary={`${group.primary.title || '未命名合集'} · ${items.length} 个视频`}>+ summary={`${followTitle(group.primary)} · ${items.length} 个视频`}>{items.map((member) => {const duplicate = group.duplicates.includes(member);const copy = collectionCopy(group, member, duplicate ? member.provider_label : '');@@ -275,7 +299,7 @@ function MediaQueue({ item, current, currentId = item.id, helpers, actions, onMeconst pick = (media: FollowDetailMedia) => (item.id === currentId ? onMedia(media.index) : actions.openItem(item.id, media.index));return (<MixQueue kind="media" data-follow-queue="" title="多媒体" onClose={actions.close} listRef={listRef}- summary={`${item.title || '未命名内容'} · ${items.length} 个媒体`}>+ summary={`${followTitle(item)} · ${items.length} 个媒体`}>{groups.map((row) => [row.label ? <MixGroupLabel key={`label:${row.key}`} label={row.label} count={row.items.length} /> : null,...row.items.map((media) => (@@ -313,7 +337,7 @@ function Side({ item, data, context, media, write, issue, helpers, actions }: {<div data-stage-side-content=""><div data-follow-detail-title=""><div data-stage-title="" data-follow-detail-name="" data-reveal-line=""- dangerouslySetInnerHTML={{ __html: followTitleMarks(single, item) + esc(item.title) }} />+ dangerouslySetInnerHTML={{ __html: followTitleMarks(single, item) + esc(followTitle(item)) }} />{item.url ? (<a data-follow-origin="" href={item.url} target="_blank" rel="noreferrer noopener"title="打开来源页面" aria-label="打开来源页面"@@ -333,7 +357,7 @@ function Side({ item, data, context, media, write, issue, helpers, actions }: {{realDuration(item.duration) ? <span>{fmtDur(item.duration)}</span> : null}{badges ? <span data-follow-badges="" dangerouslySetInnerHTML={{ __html: badges }} /> : null}</div>- {item.summary ? <p data-follow-detail-summary="">{item.summary}</p> : null}+ {item.summary ? <Summary key={item.id} text={item.summary} /> : null}{mediaIssue ? <p data-follow-media-issue="">{mediaIssue}</p> : null}{/* 上游没给出媒体时,代理只会回一个不含缘由的失败。有缩略图就换上缩略图并说明这是缩略图;连缩略图也取不到,才说「这次没取到、多半是限流」——别让人对着一块空画布猜。 */}@@ -411,6 +435,32 @@ function Side({ item, data, context, media, write, issue, helpers, actions }: {);}+/** 摘要默认收在八行内,量出来确实被截了才给「展开」;展开后同一枚键收回。 */+function Summary({ text }: { text: string }) {+ const node = useRef<HTMLParagraphElement>(null);+ const [open, setOpen] = useState(false);+ const [overflows, setOverflows] = useState(false);+ useLayoutEffect(() => {+ const box = node.current;+ if (!box || open) return undefined;+ const measure = () => setOverflows(box.scrollHeight > box.clientHeight + 1);+ measure();+ const observer = new ResizeObserver(measure);+ observer.observe(box);+ return () => observer.disconnect();+ }, [text, open]);+ return (+ <>+ <p ref={node} data-follow-detail-summary="" data-clamped={open ? undefined : ''}>{text}</p>+ {overflows || open ? (+ <Button variant="ghost" size="small" data-follow-summary-toggle="" aria-expanded={open} onClick={() => setOpen(!open)}>+ {open ? '收起' : '展开'}+ </Button>+ ) : null}+ </>+ );+}+/* ── 写操作 ──* 保存、状态、想要、隐藏与恢复这张图都在岛里发。状态与保存成功后在两处缓存里换同一条(详情这条与* 关注页列表里那一条,卡面状态一起变),不重读列表:关掉详情回列表不该再等一个网络往返。diff --git a/frontend/src/react/follow-detail/follow-detail.css b/frontend/src/react/follow-detail/follow-detail.cssindex 3485ca238..97692789e 100644--- a/frontend/src/react/follow-detail/follow-detail.css+++ b/frontend/src/react/follow-detail/follow-detail.css@@ -109,6 +109,22 @@border-radius: var(--pill-radius);background: #fff;}+/* 张数多于 `FOLLOW_DOTS_MAX` 时圆点条换成「当前 / 总数」:位置与底衬同圆点条。 */+.peach-react [data-follow-detail] [data-follow-image-count] {+ position: absolute;+ z-index: 4;+ left: 50%;+ bottom: 18px;+ transform: translateX(-50%);+ padding: 4px 11px;+ border-radius: var(--pill-radius);+ background: rgba(0, 0, 0, .5);+ color: #fff;+ font: 500 var(--fs-xs) / 16px var(--board-font);+ font-variant-numeric: tabular-nums;+ white-space: nowrap;+ pointer-events: none;+}/* ── 队列 ──合集队列卡的出处与时间:标记、站点图标和时间按盒子居中成一行,不靠基线偏移去凑。标记可收窄@@ -176,6 +192,7 @@gap: 10px;margin: 2px 0 12px;}+.peach-react [data-follow-detail] [data-follow-detail-identity] > div { min-width: 0; overflow-wrap: anywhere; }.peach-react [data-follow-detail] [data-follow-detail-identity] b,.peach-react [data-follow-detail] [data-follow-detail-identity] span { display: block; }.peach-react [data-follow-detail] [data-follow-detail-identity] > div > span {@@ -230,13 +247,27 @@line-height: 1.6;color: var(--ink-2);white-space: pre-line;+ overflow-wrap: anywhere;+}+/* 摘要默认收在八行内,操作键留在首屏;量出来确实超出时才在下面给一枚「展开」。+ 侧栏内容区是定高的纵向 flex,裁切后的摘要最小高度归零,不禁止收缩就会被压没。 */+.peach-react [data-follow-detail] [data-follow-detail-summary][data-clamped] {+ flex-shrink: 0;+ display: -webkit-box;+ -webkit-box-orient: vertical;+ -webkit-line-clamp: 8;+ line-clamp: 8;+ overflow: hidden;}+.peach-react [data-follow-detail] [data-follow-detail-summary]:has(+ [data-follow-summary-toggle]) { margin-bottom: 4px; }+.peach-react [data-follow-detail] [data-follow-summary-toggle] { flex-shrink: 0; align-self: flex-start; margin: 0 0 16px -8px; }/* 「媒体未取得」与两句取回失败的提示:小一档正文字号(`--fs-sm`)、1.7 行高,警示色。 */.peach-react [data-follow-detail] [data-follow-media-issue] {margin: 18px 0 8px;font-size: var(--fs-sm);line-height: 1.7;color: var(--drop);+ overflow-wrap: anywhere;}.peach-react [data-follow-detail] [data-follow-media-issue][hidden] { display: none; }.peach-react [data-follow-detail] [data-follow-resources] {diff --git a/frontend/src/react/follow-detail/follow-detail.ts b/frontend/src/react/follow-detail/follow-detail.tsindex 9163b95f2..6bf697ae6 100644--- a/frontend/src/react/follow-detail/follow-detail.ts+++ b/frontend/src/react/follow-detail/follow-detail.ts@@ -59,14 +59,19 @@ export const FOLLOW_ITEM_URL = (id: number) => `/api/follow?item=${encodeURICompexport const FOLLOW_SAVE_URL = '/api/follow/save';export const FOLLOW_MEDIA_HIDE_URL = '/api/follow/media/hide';-/** 单条取:响应只含这一条所在的组。条目已不存在时服务端回空组,这里报成一次失败。 */+/** 条目已不存在:重试也取不回来,详情给的是「回到关注」而不是重试。 */+export class FollowItemGone extends Error {+ constructor() { super('这条关注内容已不存在') }+}++/** 单条取:响应只含这一条所在的组。条目已不存在时服务端回空组,这里报成 `FollowItemGone`。 */export async function fetchFollowItem(id: number, signal?: AbortSignal): Promise<FollowDetailData> {const page = await apiGet<FollowPage>(FOLLOW_ITEM_URL(id), signal);for (const group of page.groups || []) {const item = collectionItems(group).find((member) => member.id === id);if (item) return { item: item as FollowDetailItem, group, sources: page.sources || [], aliases: page.author_aliases || [] };}- throw new Error('这条关注内容已不存在');+ throw new FollowItemGone();}/** 首屏:列表缓存里有就直接用(关掉详情回列表也不重取),没有才单条取;凭据没取过才取。 */diff --git a/frontend/src/react/follow-feed/follow-card.tsx b/frontend/src/react/follow-feed/follow-card.tsxindex d99157fbf..d6130c64a 100644--- a/frontend/src/react/follow-feed/follow-card.tsx+++ b/frontend/src/react/follow-feed/follow-card.tsx@@ -22,18 +22,13 @@ import {type FollowGroup, type FollowMedia, type FollowSource,} from './follow-feed';import {- followBadges, followIdentity, followMediaIssue, followTitleMarks, followWhen, learnFollowDims, sourceIcon,+ followBadges, followCompactWhen, followIdentity, followMediaIssue, followTitle, followTitleMarks, followWhen,+ learnFollowDims, sourceMark,} from './follow-marks';/** 时长只在是真时长时写:来源没给、给了 0 或给了一个明显是占位的数,都不出这一格。 */const realDuration = (value: unknown) => Number(value) > 0;-/** 列表里时间只写到日:今年的去掉年份,往年的留着。悬停读得到完整时间。 */-function compactWhen(when: string): string {- if (!/^\d{4}-/.test(when)) return when;- return when.startsWith(String(new Date().getFullYear())) ? when.slice(5, 10) : when.slice(0, 10);-}-export interface FollowCardProps {group: FollowGroup;/** 这张卡的创作者名下那几个来源:头像与署名读它。 */@@ -50,13 +45,19 @@ export interface FollowCardProps {onSave(id: number): void;}-/** 卡面图片直连失败时尝试原图代理,每个入口只尝试一次。 */-function Thumb({ src, fallback, width, height, onLearn }: {- src: string; fallback?: string; width?: number; height?: number; onLearn?: (width: number, height: number) => void;+/** 卡面没有画面时的那一格:来源的站标居中,和本来就没给缩略图的卡同一个样子。 */+const NoThumb = ({ provider }: { provider: string }) => (+ <span data-follow-nothumb="" dangerouslySetInnerHTML={{ __html: sourceMark(provider) }} />+);++/** 卡面图片直连失败时尝试原图代理,每个入口只尝试一次;都取不到就换成没缩略图的那一格。 */+function Thumb({ src, fallback, width, height, provider, onLearn }: {+ src: string; fallback?: string; width?: number; height?: number; provider: string;+ onLearn?: (width: number, height: number) => void;}) {const [broken, setBroken] = useState(false);const [proxied, setProxied] = useState(false);- if (broken) return null;+ if (broken) return <NoThumb provider={provider} />;return (<img src={proxied ? fallback : src} alt="" loading="lazy" referrerPolicy="no-referrer" width={width} height={height}onError={() => {@@ -114,7 +115,8 @@ function FollowCardView(props: FollowCardProps) {}, []);const identity = followIdentity(item, authorSources, context);- const when = followWhen(item);+ const title = followTitle(item);+ const picProvider = item.resource_provider || item.provider;const tags = (item.tags || []).slice(0, 3);const issue = followMediaIssue(item, context);const badges = followBadges(group, item);@@ -139,11 +141,12 @@ function FollowCardView(props: FollowCardProps) {data-selected={selected ? '' : undefined} onClick={click} onMouseDown={suppressShiftTextSelection}onMouseEnter={flip.onPointerEnter} onMouseLeave={flip.onPointerLeave}><div data-follow-visual="" data-mix-stack={stack.isMix ? '' : undefined}>- <button type="button" data-follow-open="" aria-label={`打开 ${item.title} 详情`} />+ <button type="button" data-follow-open="" aria-label={`打开 ${title} 详情`} /><div data-media-pic="">{thumbUrl- ? <Thumb key={thumbUrl} src={thumbUrl} fallback={imageFallback} width={sized?.width} height={sized?.height} onLearn={learn} />- : <span data-follow-nothumb="" dangerouslySetInnerHTML={{ __html: sourceIcon(item.resource_provider || item.provider) }} />}+ ? <Thumb key={thumbUrl} src={thumbUrl} fallback={imageFallback} width={sized?.width} height={sized?.height}+ provider={picProvider} onLearn={learn} />+ : <NoThumb provider={picProvider} />}{stack.faces.length > 1 ? (<div data-mix-faces="" hidden={!flip.faces.length}>{flip.faces.map((src, index) => (@@ -153,8 +156,9 @@ function FollowCardView(props: FollowCardProps) {))}</div>) : null}- <span data-media-badge="" title={item.provider_label} aria-label={`来源:${item.provider_label || ''}`}- dangerouslySetInnerHTML={{ __html: sourceIcon(item.provider) }} />+ <span data-media-badge="" title={item.provider_label || item.provider}+ aria-label={`来源:${item.provider_label || item.provider}`}+ dangerouslySetInnerHTML={{ __html: sourceMark(item.provider, item.provider_label) }} /><span data-media-check="" onClick={(event) => {event.preventDefault();event.stopPropagation();@@ -199,10 +203,10 @@ function FollowCardView(props: FollowCardProps) {dangerouslySetInnerHTML={{ __html: identity.avatar }} /><div data-media-text=""><button type="button" data-media-title=""- dangerouslySetInnerHTML={{ __html: followTitleMarks(group, item) + esc(item.title) }} />+ dangerouslySetInnerHTML={{ __html: followTitleMarks(group, item) + esc(title) }} /><div data-follow-byline=""><span data-follow-author="" title={identity.author}>{identity.author}</span>- <time dateTime={item.published_at || ''} title={when}>{compactWhen(when)}</time>+ <time dateTime={item.published_at || ''} title={followWhen(item)}>{followCompactWhen(item)}</time></div>{identity.credited? <div data-follow-credit="" title={`署名含 ${identity.credited}`}>{`署名含 ${identity.credited}`}</div>diff --git a/frontend/src/react/follow-feed/follow-feed-page.tsx b/frontend/src/react/follow-feed/follow-feed-page.tsxindex 23bb3b5ae..b0adfcd5b 100644--- a/frontend/src/react/follow-feed/follow-feed-page.tsx+++ b/frontend/src/react/follow-feed/follow-feed-page.tsx@@ -15,6 +15,7 @@ import { tagLabel } from '@peach/legacy/tags';import { emptyStateHtml, spinnerHtml } from '@peach/legacy/ui';import { Button } from '@/components/base/buttons/button';+import { InputBase, TextField } from '@/components/base/input/input';import { apiGet, apiSend } from '../../api';import { LoadMore } from '../catalog-grid/catalog-grid-page';@@ -28,9 +29,10 @@ import { FOLLOW_CHECK_URL, FOLLOW_STATUS_URL, sourceIconUrl } from '../follow-maimport { sidebarTagCounts } from '../../sidebar';import { queryClient } from '../query';import { FollowCard } from './follow-card';-import { authorAvatarHtml, followAuthorName, sourceIcon } from './follow-marks';+import { authorAvatarHtml, followAuthorName, sourceMark } from './follow-marks';import {- FOLLOW_CREDENTIALS_KEY, FOLLOW_FEED_SORTS, FOLLOW_FILTERS, FOLLOW_TAGS_FIRST, FOLLOW_WORKS_FIRST,+ FOLLOW_AUTHORS_FIRST, FOLLOW_AUTO_LOAD_LIMIT, FOLLOW_CREDENTIALS_KEY, FOLLOW_FEED_SORTS, FOLLOW_FILTERS, FOLLOW_TAGS_FIRST,+ FOLLOW_WORKS_FIRST, authorRow,collectionItems, dropCondition, fetchFollowCredentials, followConditions, followFeedQuery, groupMediaKinds, groupTagType, itemForMedia,mergedPage, nextSort, randomOrder, sortAriaLabel, backfillState, withStatus,type FollowCondition, type FollowContext, type FollowDrawer, type FollowFeedProps, type FollowGroup, type FollowPage, type FollowSource,@@ -41,6 +43,7 @@ const Sep = () => <span data-entity-sep="" aria-hidden="true" />;const SETTINGS = spriteGlyph('settings');const CHEVRON_DOWN = spriteGlyph('chevron-down');const HISTORY = spriteGlyph('history');+const SEARCH = spriteGlyph('search');/** 照片墙那一排的图片布局两档,同壳里 `PHOTO_LAYOUTS`。 */export const FOLLOW_PHOTO_LAYOUTS: readonly SegmentOption[] = [@@ -132,8 +135,14 @@ export function FollowFeedPage(props: FollowFeedProps) {const job = useFollowJob(props, !!data);if (!data) {+ /* 取不到列表时页头照画:这时候最用得上的就是去管理页看来源出了什么事。 */if (result.isError) {- return <RetryNote message={requestErrorMessage(result.error)} onRetry={() => void result.refetch()} />;+ return (+ <div data-follow-feed="">+ <Head onManage={actions.openManage} />+ <RetryNote message={requestErrorMessage(result.error)} onRetry={() => void result.refetch()} />+ </div>+ );}return null;}@@ -151,23 +160,17 @@ export function FollowFeedPage(props: FollowFeedProps) {{/* 进度那一格归 `followJobProgress`:它自己往里插面板、自己开合,React 只给一个空节点。 */}<div key={job.generation} ref={job.host} data-follow-progress="" /><div data-follow-feed="" data-select-mode={props.selectMode ? '' : undefined}>- <div data-follow-head="">- <h2 data-follow-title="">关注</h2>- <span data-follow-head-actions="">- <Button variant="secondary" leadingIcon={SETTINGS} data-follow-manage="" onClick={actions.openManage}>- 管理关注+ <Head onManage={actions.openManage}>+ {facets.sources.length ? (+ <Button variant="primary" data-follow-recheck="" aria-label="检查每个来源的更新"+ aria-busy={job.busy || undefined}+ onClick={() => void job.start(false)}>+ {job.starting === 'check'+ ? <span className="contents" dangerouslySetInnerHTML={{ __html: spinnerHtml('检查中') }} />+ : '检查更新'}</Button>- {facets.sources.length ? (- <Button variant="primary" data-follow-recheck="" aria-label="检查每个来源的更新"- aria-busy={job.busy || undefined}- onClick={() => void job.start(false)}>- {job.starting === 'check'- ? <span className="contents" dangerouslySetInnerHTML={{ __html: spinnerHtml('检查中') }} />- : '检查更新'}- </Button>- ) : null}- </span>- </div>+ ) : null}+ </Head><Authors facets={facets} pressed={facets.author} context={context} props={props}onPick={(key) => route({ author: facets.author === key ? '' : key })} /><Works rows={facets.workRows} pressed={view.work} props={props}@@ -182,10 +185,16 @@ export function FollowFeedPage(props: FollowFeedProps) {<div data-follow-pagination="">{data.has_more ? (<span data-follow-page-action="">- <LoadMore key={result.data?.pages.length} entity enabled={() => !job.busyRef.current}- load={async () => { await result.fetchNextPage({ throwOnError: true }) }}>- <CHEVRON_DOWN className="size-3.5" />加载更多- </LoadMore>+ {data.groups.length < FOLLOW_AUTO_LOAD_LIMIT ? (+ <LoadMore key={result.data?.pages.length} entity enabled={() => !job.busyRef.current}+ load={async () => { await result.fetchNextPage({ throwOnError: true }) }}>+ <CHEVRON_DOWN className="size-3.5" />加载更多+ </LoadMore>+ ) : (+ <ManualMore busy={result.isFetchingNextPage}+ error={result.isFetchNextPageError ? requestErrorMessage(result.error) : ''}+ load={() => { if (!job.busyRef.current && !result.isFetchingNextPage) void result.fetchNextPage() }} />+ )}</span>) : null}{canBackfill ? (@@ -207,6 +216,34 @@ export function FollowFeedPage(props: FollowFeedProps) {);}+/** 页头:标题与「管理关注」恒在,检查更新那枚键要等来源读到才摆(`children`)。 */+function Head({ onManage, children }: { onManage(): void; children?: ReactNode }) {+ return (+ <div data-follow-head="">+ <h2 data-follow-title="">关注</h2>+ <span data-follow-head-actions="">+ <Button variant="secondary" leadingIcon={SETTINGS} data-follow-manage="" onClick={onManage}>+ 管理关注+ </Button>+ {children}+ </span>+ </div>+ );+}++/** 摆满 `FOLLOW_AUTO_LOAD_LIMIT` 组以后的「加载更多」:外观同 `LoadMore` 那枚,只是滚到它不会自己接,+ * 要点一下。失败时原位留原因与重试。 */+function ManualMore({ busy, error, load }: { busy: boolean; error: string; load(): void }) {+ return (+ <>+ <button type="button" data-entity-more="" aria-busy={busy || undefined} aria-disabled={busy || undefined} onClick={load}>+ <CHEVRON_DOWN className="size-3.5" />加载更多+ </button>+ {error ? <RetryNote message={error} onRetry={load} /> : null}+ </>+ );+}+/* ── 检查更新与往回抓 ──* 一次只往回一页:追更的常规检查永远只看第一页,往回抓是一个独立的、显式的动作,点一次走一页,* 不自动、不连翻。两枚键起的是同一趟任务,任务在跑时两枚一起忙,续页也停下。 */@@ -284,19 +321,34 @@ function Authors({ facets, pressed, context, props, onPick }: {facets: Facets; pressed: string; context: FollowContext; props: FollowFeedProps; onPick(key: string): void;}) {const row = useRef<HTMLDivElement>(null);+ const [query, setQuery] = useState('');useEffect(() => { props.helpers.wireDrag(row.current) }, [props.helpers]);+ const nameOf = (key: string) => followAuthorName(facets.authorSources.get(key) || [], context);+ const searchable = facets.authorOrder.length > FOLLOW_AUTHORS_FIRST;+ const keys = authorRow(facets.authorOrder, nameOf, searchable ? query : '', pressed);if (!facets.authorOrder.length) return null;+ /* 搜索框在横滚那一排外面:拖动监听挂在那一排上,框放进去的话按下去就被当成拖动吃掉。 */return (- <div ref={row} data-follow-authors="" aria-label="按创作者筛选">- {facets.authorOrder.map((key) => {- const list = facets.authorSources.get(key) || [];- return (- <button key={key} type="button" data-follow-author={key} aria-pressed={pressed === key} onClick={() => onPick(key)}>- <span data-follow-ring="" dangerouslySetInnerHTML={{ __html: authorAvatarHtml(list, followAuthorName(list, context)) }} />- <span data-follow-name="">{followAuthorName(list, context)}</span>- </button>- );- })}+ <div data-follow-authors-bar="">+ {searchable ? (+ <div data-follow-author-search="">+ <TextField aria-label="搜索创作者" value={query} onChange={setQuery}>+ <InputBase type="search" leadingIcon={SEARCH} placeholder="搜索创作者" spellCheck={false} autoComplete="off" />+ </TextField>+ </div>+ ) : null}+ <div ref={row} data-follow-authors="" aria-label="按创作者筛选">+ {keys.map((key) => {+ const list = facets.authorSources.get(key) || [];+ return (+ <button key={key} type="button" data-follow-author={key} aria-pressed={pressed === key} onClick={() => onPick(key)}>+ <span data-follow-ring="" dangerouslySetInnerHTML={{ __html: authorAvatarHtml(list, nameOf(key)) }} />+ <span data-follow-name="">{nameOf(key)}</span>+ </button>+ );+ })}+ {!keys.length ? <span data-follow-author-none="">没有名字含「{query.trim()}」的创作者</span> : null}+ </div></div>);}@@ -392,7 +444,7 @@ function Glass({ facets, view, total, busy, props, route }: {<button key={key} type="button" data-follow-provider={key} data-entity-press=""aria-pressed={facets.provider === key} title={label} aria-label={`来源:${label}`}onClick={() => route({ provider: facets.provider === key ? '' : key })}- dangerouslySetInnerHTML={{ __html: sourceIcon(key) }} />+ dangerouslySetInnerHTML={{ __html: sourceMark(key, label) }} />))}{providers.length && facets.tagRows.length ? <Sep /> : null}{facets.tagRows.map(([tag, n]) => (@@ -519,7 +571,7 @@ function Cards({ facets, data, context, props, images }: {);});} else {- body = <Empty data={data} />;+ body = <Empty data={data} filtered={!!(view.status || facets.author || facets.provider || view.work || view.tags.length)} />;}return (<div data-follow-list="" data-follow-wall={images ? '' : undefined} {...wall}>@@ -533,11 +585,15 @@ function cardId(group: FollowGroup, view: FollowView): number {return itemForMedia(group, view.media).id;}-function Empty({ data }: { data: FollowPage }) {+/** 空列表分四种:这一页有组只是媒体类型没对上;设了筛选没筛出东西;有来源但一条都还没抓到;+ * 一个来源都没有。没设筛选时不叫人去改筛选。 */+function Empty({ data, filtered }: { data: FollowPage; filtered: boolean }) {const html = (data.groups || []).length? emptyStateHtml('search-x', '当前筛选下没有更新', '切换媒体类型、创作者、来源、时长或标签后再试。'): (data.sources || []).length- ? emptyStateHtml('rss', '没有符合条件的更新', '切换状态或来源筛选后再试。')+ ? filtered+ ? emptyStateHtml('rss', '没有符合条件的更新', '切换状态或来源筛选后再试。')+ : emptyStateHtml('rss', '还没有更新', '点「检查更新」去各个来源取一遍;来源有新内容时会集中显示在这里。'): emptyStateHtml('rss', '还没有关注任何来源', '添加创作者或订阅来源后,更新会集中显示在这里。',{ actions: '<a class="geist-button primary" href="/follow-manage?tab=add">添加关注</a>' });return <div data-follow-empty="" className="contents" dangerouslySetInnerHTML={{ __html: html }} />;diff --git a/frontend/src/react/follow-feed/follow-feed.css b/frontend/src/react/follow-feed/follow-feed.cssindex 65d199b85..89f2b3b2d 100644--- a/frontend/src/react/follow-feed/follow-feed.css+++ b/frontend/src/react/follow-feed/follow-feed.css@@ -47,6 +47,17 @@@media (max-width: 640px) {.peach-react [data-follow-authors] { margin-right: -12px; }}+/* 创作者多于一排能摆下的(`FOLLOW_AUTHORS_FIRST`)时,排上方一枚搜索框,搜的是全部创作者。 */+.peach-react [data-follow-author-search] { width: min(240px, 100%); margin: 0 0 6px; }+.peach-react [data-follow-author-none] {+ display: flex;+ align-items: center;+ min-height: 84px;+ padding: 0 4px;+ color: var(--color-text-tertiary);+ font: var(--board-body);+ overflow-wrap: anywhere;+}.peach-react :is([data-follow-authors], [data-follow-works]) > button {flex: none;border: 0;@@ -333,6 +344,18 @@font-size: var(--fs-xs);}.peach-react :is([data-media-badge], [data-follow-nothumb]) > img { width: 18px; height: 18px; margin: 0; border-radius: var(--badge-radius); object-fit: contain; }+/* 站标取不到或没登记时那枚站名首字(`sourceMark`):和图标同一个 18px 方块,筛选键、卡角与空卡面通用。+ 图坏了时回落脚本换上的 span 只带这个类名,接不住 `data-*`。 */+.peach-react .follow-site-initial {+ display: inline-grid;+ place-items: center;+ width: 18px;+ height: 18px;+ border-radius: var(--badge-radius);+ background: var(--overlay-5);+ color: var(--muted);+ font: 600 11px/1 var(--board-font);+}.peach-react [data-follow-image] [data-media-pic] { aspect-ratio: 4 / 3; min-height: 0; background: var(--sunk); }.peach-react [data-follow-image] [data-media-pic] > img { background: var(--sunk); }.peach-react [data-follow-image] :is([data-mix-faces], [data-mix-face] img) { background: var(--sunk); }@@ -345,6 +368,13 @@position: static;height: auto;}+/* 极端竖长的图(长条漫画、200×4000 那种)最高到列宽的 2.5 倍,多出来的裁掉:按固有比例摆的话+ 一张就占满一整列,瀑布流的分列全被它打乱。量的是列宽,所以封面格自己当尺寸容器。 */+.peach-react [data-follow-wall][data-layout="masonry"] [data-follow-image] [data-media-pic]:has(> img[width][height]) { container-type: inline-size; }+.peach-react [data-follow-wall][data-layout="masonry"] [data-follow-image] [data-media-pic] > img[width][height] {+ max-height: 250cqi;+ object-fit: cover;+}/* 右上角:合并计数与主页卡片的版本角标同一个位置,右下角只留给时长。* 能悬停的设备上计数和操作键叠在同一格:悬停或键盘聚焦时计数淡出、退出命中与 Tab 序,操作键@@ -417,6 +447,9 @@}@media (hover: none), (pointer: coarse) {.peach-react [data-follow-item] [data-follow-actions] { opacity: 1; pointer-events: auto; }+ /* 触屏上没有悬停,键是常驻的;图片墙的格子小,三枚圆键会盖住大半张图,只留「保存到账本」,+ 已看与忽略到详情里点。 */+ .peach-react [data-follow-wall] [data-follow-item] [data-follow-actions] > :not([data-follow-save]) { display: none; }}/* 元信息区:署名行一行排开,作者名可截断、时间不收;署名含那一行弱于作者名。 */@@ -504,5 +537,5 @@.peach-react [data-follow-item] [data-media-tag][data-tag-cat="r34-character"] { --tag-color: #68c76f; }.peach-react [data-follow-item] [data-media-tag][data-tag-cat="r34-copyright"] { --tag-color: #d675d6; }.peach-react [data-follow-item] [data-media-tag][data-tag-cat="r34-metadata"] { --tag-color: #f5a24a; }-.peach-react [data-follow-issue] { display: block; margin: 18px 0 8px; color: var(--drop); font-size: var(--fs-sm); line-height: 1.7; }+.peach-react [data-follow-issue] { display: block; margin: 18px 0 8px; color: var(--drop); font-size: var(--fs-sm); line-height: 1.7; overflow-wrap: anywhere; }.peach-react [data-follow-state] { flex: 1 1 100%; color: var(--drop); font-size: var(--fs-xs); }diff --git a/frontend/src/react/follow-feed/follow-feed.ts b/frontend/src/react/follow-feed/follow-feed.tsindex 0f8ca9caf..afa6f3c1c 100644--- a/frontend/src/react/follow-feed/follow-feed.ts+++ b/frontend/src/react/follow-feed/follow-feed.ts@@ -13,7 +13,7 @@* (`findFollowItem`),扫不到才单独取。侧栏仍归壳画:岛每取到一版列表就经 `actions.loaded`* 交回这一视图可见条目的标签计数、全库口径的来源与时长有无。 */import { keepPreviousData, type InfiniteData, type QueryKey } from '@tanstack/react-query';-import { seededRank } from '@peach/legacy/core';+import { foldName, seededRank } from '@peach/legacy/core';import { apiGet } from '../../api';import { FOLLOW_CREDENTIALS_URL } from '../follow-manage/follow-manage';@@ -51,8 +51,14 @@ export interface FollowView {seed: number;}-/** 关注页一次取一屏。`counts` 是全库口径,`groups` 只是这一页,所以列表底部要能继续加载。 */-export const FOLLOW_PAGE = 300;+/** 关注页一次取一屏。`counts` 是全库口径,`groups` 只是这一页,所以列表底部要能继续加载。+ * 一页 100 组:一张卡三四十个节点,一次挂几百张就是首屏一秒多的长任务。 */+export const FOLLOW_PAGE = 100;+/** 已经摆出这么多组以后,滚到底不再自己接下一页,要点「加载更多」:一直滚下去页面就一直变重,+ * 滚过头的那一下不该悄悄再挂几百张卡。 */+export const FOLLOW_AUTO_LOAD_LIMIT = 500;+/** 创作者那一排一次露出几位,同题材那一排;其余的用这一排前面的搜索框找。 */+export const FOLLOW_AUTHORS_FIRST = 24;/** 这一页第 `offset` 组起的请求地址,参数拼法同壳里 `followPageUrl`:默认那一档不写进去。 */export function followPageUrl(view: FollowView, offset: number): string {@@ -232,6 +238,14 @@ export function randomOrder<T>(rows: readonly T[], key: (row: T) => string, seedseededRank(seed, key(a)) - seededRank(seed, key(b)) || String(key(a)).localeCompare(String(key(b))));}+/** 创作者那一排露出哪几位:按种子取样的前 `FOLLOW_AUTHORS_FIRST` 位;有搜索词时从全部创作者里+ * 按名字找,不取样。按下的那位不在其中时排到最前,页面不能停在一个看不见按下项的筛选里。 */+export function authorRow(order: readonly string[], nameOf: (key: string) => string, query: string, pressed: string): string[] {+ const needle = foldName(query);+ const rows = (needle ? order.filter((key) => foldName(nameOf(key)).includes(needle)) : order).slice(0, FOLLOW_AUTHORS_FIRST);+ return pressed && order.includes(pressed) && !rows.includes(pressed) ? [pressed, ...rows] : rows;+}+/** 题材那一排露出几个,同首页那排厂牌(壳的 `ROW_FIRST`)。 */export const FOLLOW_WORKS_FIRST = 24;/** 标签露出几个。 */diff --git a/frontend/src/react/follow-feed/follow-marks.ts b/frontend/src/react/follow-feed/follow-marks.tsindex 3504868e4..5af28b7fd 100644--- a/frontend/src/react/follow-feed/follow-marks.ts+++ b/frontend/src/react/follow-feed/follow-marks.ts@@ -26,6 +26,21 @@ export function sourceIcon(provider: string, label = ''): string {: '';}+/** 站标那一格只有图标、旁边没有文字时用它:筛选条的来源键、卡角的来源角标、没缩略图的卡面。+ * 没登记图标的站直接写站名首字;图标取不到时由回落脚本换成同一枚首字,那一格不会空着。+ * 名字由外层的 `aria-label`/`title` 说,这里的字与图都只作装饰。 */+export function sourceMark(provider: string, label = ''): string {+ const initial = esc(authorInitial(label || provider));+ const url = sourceIconUrl(provider);+ return url+ ? `<img data-follow-site-icon="" src="${url}" alt="" loading="lazy" data-drop="initial" data-initial="${initial}" data-drop-class="follow-site-initial">`+ : `<span class="follow-site-initial" aria-hidden="true">${initial}</span>`;+}++/** 标题为空时卡片、详情与队列都写这一句。 */+export const FOLLOW_UNTITLED = '未命名内容';+export const followTitle = (item: { title?: unknown }): string => text(item.title).trim() || FOLLOW_UNTITLED;+/** 这一版列表里一位创作者的名字(别名合并后的统称优先)。 */export const followAuthorName = (sources: readonly FollowSource[], context: FollowContext): string =>authorName(sources, aliasesOf(context));@@ -98,9 +113,42 @@ export function followMediaIssue(item: FollowItem, context: FollowContext): strireturn '';}+/** 晚于此刻一天以上的发布时间:来源的时钟或时区写错了,照实标出来,不当作正常的最新一条。 */+const FUTURE_SLACK_MS = 24 * 3600_000;+const isFuture = (iso: string, now: number): boolean => {+ const at = new Date(/[Zz]|[+-]\d\d:?\d\d$/.test(iso) ? iso : `${iso}Z`).getTime();+ return Number.isFinite(at) && at - now > FUTURE_SLACK_MS;+};++/** 发布时间的三段:精度前缀、按看的人所在时区写的时间、晚于现在的标记。来源只给了相对时间+ * (`published_precision` 为 `approximate`,如「3 years ago」换算来的)时只写到日并加「约」,+ * 时分是换算出来的,写出来就是假精度。 */+function whenParts(item: FollowItem, now: number) {+ const iso = text(item.published_at);+ if (!iso) return null;+ const approximate = item.published_precision === 'approximate';+ const full = localTime(iso);+ return {+ prefix: approximate ? '约 ' : '',+ full: approximate ? full.slice(0, 10) : full,+ suffix: isFuture(iso, now) ? ' · 晚于现在' : '',+ };+}+/** 发布时间,按看的人所在时区显示;来源没给就明说。 */-export const followWhen = (item: FollowItem): string =>- (item.published_at ? localTime(item.published_at) : '时间未取得');+export function followWhen(item: FollowItem, now = Date.now()): string {+ const parts = whenParts(item, now);+ return parts ? `${parts.prefix}${parts.full}${parts.suffix}` : '时间未取得';+}++/** 列表里时间只写到日:今年的去掉年份,往年的留着。悬停读得到 `followWhen` 的完整写法。 */+export function followCompactWhen(item: FollowItem, now = Date.now()): string {+ const parts = whenParts(item, now);+ if (!parts) return '时间未取得';+ if (!/^\d{4}-/.test(parts.full)) return `${parts.prefix}${parts.full}${parts.suffix}`;+ const day = parts.full.startsWith(String(new Date(now).getFullYear())) ? parts.full.slice(5, 10) : parts.full.slice(0, 10);+ return `${parts.prefix}${day}${parts.suffix}`;+}/* 这次会话里已经回写过的图,`条目:媒体序号`。回写只补空缺,服务端本来就会忽略已有尺寸的条目,但每次重渲染都把同一批再发一遍是白跑。攒 800ms 一批、一批至多 200 条。 */diff --git a/frontend/src/react/follow-manage/credentials.tsx b/frontend/src/react/follow-manage/credentials.tsxindex 839f1b512..a6ede9888 100644--- a/frontend/src/react/follow-manage/credentials.tsx+++ b/frontend/src/react/follow-manage/credentials.tsx@@ -113,11 +113,11 @@ function CredentialForm({ row, readOnly, toast }:function CredentialSection({ row, readOnly, toast }:{ row: CredentialRow; readOnly: boolean; toast(message: string): void }) {const head = (- <span className="flex min-w-0 items-center gap-2">+ <span className="flex min-w-0 flex-wrap items-center gap-2"><span className="inline-flex size-3.5 shrink-0 items-center justify-center"><SourceIcon provider={row.provider} /></span>- <b className="text-body-medium text-text-primary">{row.provider_label}</b>+ <b className="min-w-0 text-body-medium wrap-anywhere text-text-primary">{row.provider_label}</b><StateChip row={row} />{row.missing.length? <Chip variant="caption" color="rose">{`缺 ${row.missing.join('、')}`}</Chip>diff --git a/frontend/src/react/follow-manage/feed-sources.tsx b/frontend/src/react/follow-manage/feed-sources.tsxindex bb7f64241..79a78ba4b 100644--- a/frontend/src/react/follow-manage/feed-sources.tsx+++ b/frontend/src/react/follow-manage/feed-sources.tsx@@ -40,7 +40,8 @@ import { localTime } from '../time';import { AddFeed } from './add-feed';import { Pagination } from './source-list';import {- checkFeeds, FEEDS_KEY, fetchFeeds, removeFeed, setFeedEnabled, PAGE_SIZES, pageWindow, type FeedSource,+ checkFeeds, errorHeadline, FEEDS_KEY, feedIntervalText, fetchFeeds, removeFeed, setFeedEnabled,+ PAGE_SIZES, pageWindow, type FeedSource,} from './follow-manage';const COLUMN_LABELS: Record<string, string> = {@@ -62,9 +63,6 @@ const reload = () => queryClient.invalidateQueries({ queryKey: FEEDS_KEY, exact:const feedName = (source: FeedSource) => source.name || source.url;-const intervalText = (minutes: number) => (minutes >= 60- ? `每 ${Math.round(minutes / 60)} 小时`- : `每 ${minutes} 分钟`);/** 来源那一格只摆站名:地址整条写出来会把这张表撑到一屏之外,点开就是原页面。 */function originHost(url: string): string {@@ -261,7 +259,7 @@ export function FeedSources({ readOnly, toast }: {header: label('status'),cell: (context) => <StatusChip source={context.row.original} />,}),- column.accessor((row) => intervalText(row.interval_minutes), {+ column.accessor((row) => feedIntervalText(row.interval_minutes), {id: 'interval',header: label('interval'),cell: (context) => <span className="whitespace-nowrap">{context.getValue()}</span>,@@ -339,18 +337,26 @@ export function FeedSources({ readOnly, toast }: {className={cardClass({ padding: 'none', className: 'flex flex-col gap-4 px-6 py-5 max-sm:px-4' })}><div className="flex flex-wrap items-center gap-2"><h3 className="mr-auto text-title-2-medium text-text-primary">JAV 订阅源</h3>- <span className="text-body-2-regular text-text-secondary">{`${sources.length} 个订阅源 · ${data.unread} 条未看`}</span>+ <span className="text-body-2-regular text-text-secondary">{`${sources.length.toLocaleString()} 个订阅源 · ${(Number(data.unread) || 0).toLocaleString()} 条未看`}</span><Button onClick={check} disabled={readOnly} {...busyProps(action.busy === 'check')}>立即拉取</Button></div>{failing.length || action.error ? (<div className="flex flex-col gap-3">- {/* 拉不动的源各自把原因摆出来:一条源坏掉不该让整张表看起来都坏了。 */}- {failing.map((source) => (- <Note key={source.id} tone="error" title={`${feedName(source)} 拉取失败`}>- {source.last_error}+ {/* 拉不动的源并成一条:每条源一行「源名:报错首行」,几条源同时坏也不把表格推出首屏;+ 表格里那一行的状态徽章同时标着「拉取失败」。 */}+ {failing.length ? (+ <Note tone="error" title={`${failing.length.toLocaleString()} 条订阅源拉取失败`}+ extra={<ul className="flex flex-col gap-0.5 text-body-2-regular">+ {failing.map((source) => (+ <li key={source.id} className="min-w-0 truncate" title={source.last_error || ''}>+ {`${feedName(source)}:${errorHeadline(source.last_error || '') || '未说明原因'}`}+ </li>+ ))}+ </ul>}>+ 这些订阅源这一轮没有取到新条目。</Note>- ))}+ ) : null}{action.error ? <ErrorText>{action.error}</ErrorText> : null}</div>) : null}@@ -399,7 +405,7 @@ export function FeedSources({ readOnly, toast }: {)}{sources.length ? (<div className="flex flex-wrap items-center justify-between gap-3">- <span className="text-body-2-regular text-text-secondary">{`${win.start + 1}–${win.end} / ${win.total} 个订阅源`}</span>+ <span className="text-body-2-regular text-text-secondary">{`${(win.start + 1).toLocaleString()}–${win.end.toLocaleString()} / ${win.total.toLocaleString()} 个订阅源`}</span><Select aria-label="每页显示数量" size="sm" selectedKey={String(pageSize)}onSelectionChange={(key) => { if (key !== null) { setPageSize(Number(key)); setPage(1) } }}>{PAGE_SIZES.map((size) => <SelectItem key={size} id={String(size)}>{`每页 ${size} 条`}</SelectItem>)}@@ -409,7 +415,7 @@ export function FeedSources({ readOnly, toast }: {) : null}<footer className="-mx-6 -mb-5 flex flex-wrap items-center gap-2 border-t border-separator-border rounded-b-2xl bg-card-footer px-6 py-4 max-sm:-mx-4 max-sm:px-4"><span role="status" className="mr-auto text-body-2-regular text-text-secondary">- {`未看 ${data.unread} · 已启用 ${sources.filter((source) => source.enabled).length} / ${sources.length}`}+ {`未看 ${(Number(data.unread) || 0).toLocaleString()} · 已启用 ${sources.filter((source) => source.enabled).length.toLocaleString()} / ${sources.length.toLocaleString()}`}</span></footer></section>diff --git a/frontend/src/react/follow-manage/follow-manage-page.tsx b/frontend/src/react/follow-manage/follow-manage-page.tsxindex 2a6af2474..79d3945fc 100644--- a/frontend/src/react/follow-manage/follow-manage-page.tsx+++ b/frontend/src/react/follow-manage/follow-manage-page.tsx@@ -50,8 +50,11 @@ function Reading({ term, figure, unit }: { term: string; figure: number; unit: sreturn (<div className={cardClass({ padding: 'none', className: 'flex flex-col gap-3 px-6 py-5 max-sm:gap-2 max-sm:p-4' })}><span className="text-body-medium text-text-secondary">{term}</span>- <b className="text-title-1-medium tabular-nums text-text-primary">- {figure}<small className="text-body-2-regular text-text-secondary">{` ${unit}`}</small>+ {/* 六位数以上换小一号字,单位放不下时落到下一行,读数不顶出卡片。 */}+ <b data-follow-reading="" className={`flex min-w-0 flex-wrap items-baseline gap-x-1 tabular-nums text-text-primary ${+ figure >= 100000 ? 'text-title-3-medium' : 'text-title-1-medium'}`}>+ <span className="min-w-0 wrap-anywhere">{figure.toLocaleString()}</span>+ <small className="whitespace-nowrap text-body-2-regular text-text-secondary">{` ${unit}`}</small></b></div>);diff --git a/frontend/src/react/follow-manage/follow-manage.ts b/frontend/src/react/follow-manage/follow-manage.tsindex 76c9fc615..7e1a2efc1 100644--- a/frontend/src/react/follow-manage/follow-manage.ts+++ b/frontend/src/react/follow-manage/follow-manage.ts@@ -244,6 +244,22 @@ export function statusText(source: FollowSource): string {export const isBroken = (source: FollowSource): boolean =>source.last_status === 'error' || source.last_status === 'unauthorized';+/** 订阅源的拉取频率:一小时以内按分钟,两天以内按小时,再长按天。 */+export function feedIntervalText(minutes: number): string {+ const value = Number(minutes) || 0;+ if (value >= 2880) return `每 ${Math.round(value / 1440).toLocaleString()} 天`;+ if (value >= 60) return `每 ${Math.round(value / 60)} 小时`;+ return `每 ${value} 分钟`;+}++/** 一段报错在列表里只露的那一行。Python traceback 的第一行永远是「Traceback (most recent call+ * last):」,说明不了什么,取最后一行的异常类型与消息;别的取第一行非空。 */+export function errorHeadline(text: string): string {+ const lines = String(text || '').split(/\r?\n/).map((line) => line.trim()).filter(Boolean);+ if (!lines.length) return '';+ return /^Traceback \(most recent call last\)/.test(lines[0]!) ? lines[lines.length - 1]! : lines[0]!;+}+const byLabel = (a: FollowSource, b: FollowSource) =>String(a.label || '').localeCompare(String(b.label || ''), 'zh-CN', { numeric: true });diff --git a/frontend/src/react/follow-manage/source-list.tsx b/frontend/src/react/follow-manage/source-list.tsxindex c6aa3bdd5..8515db02d 100644--- a/frontend/src/react/follow-manage/source-list.tsx+++ b/frontend/src/react/follow-manage/source-list.tsx@@ -43,14 +43,16 @@ import { SelectionDock } from '../components/selection-dock';import { busyProps } from '../settings/use-action';import {authorGroups, authorName, checkedText, checkEvidenceGap, checkFailures, checkSummary,- COLUMN_SORT, dropSources, fetchCheckJob, fetchPending, FOLLOW_CHECK_KEY, isBroken,+ COLUMN_SORT, dropSources, errorHeadline, fetchCheckJob, fetchPending, FOLLOW_CHECK_KEY, isBroken,LAYOUTS, markItem, PAGE_SIZES, pageWindow, patchSource, removeSource,reloadFollowManage, selectionState, setSourceEnabled, SORT_DEFAULT_DIR, SORT_OPTIONS,sortLabel, startCheck, tableRows, toggleGroup,type CheckJob, type FollowData, type FollowSource, type Layout, type SortDir, type SortKey,type TableRow as SourceTableRow,} from './follow-manage';-import { AuthorAvatar, SourceIcon, SourceLink, StatusBadge } from './source-view';+import { AuthorAvatar, ErrorLine, SourceIcon, SourceLink, StatusBadge } from './source-view';++const count = (value: unknown) => (Number(value) || 0).toLocaleString();/** 列头点的就是工具栏里的那一档排序,所以两边共用同一张对照表,方向也共用一个值。 */const SORT_COLUMN = Object.fromEntries(@@ -144,17 +146,16 @@ function SourceRow({ source, selected, onToggle, handlers }:{ source: FollowSource; selected: boolean; onToggle(on: boolean): void; handlers: RowHandlers },) {- /* 点这一行的空白处就是勾上或取消:勾选框只有 16px,一行里其余的地方点了没反应的话,选几条要瞄几次。 */+ /* 点这一行的空白处就是勾上或取消:勾选框只有 16px,一行里其余的地方点了没反应的话,选几条要瞄几次。+ 窄屏固定两行:上一行勾选、名字、站标与状态,下一行上次检查、开关与两枚动作键。 */return (- <div data-selected={selected || undefined}- className="flex min-h-16 flex-wrap items-center gap-3 px-2 py-3"+ <div data-selected={selected || undefined} data-follow-source-row=""+ className="flex min-h-16 flex-wrap items-center gap-3 px-2 py-3 max-sm:gap-x-2"onClick={(event) => { if (clickedBlank(event, event.currentTarget)) onToggle(!selected) }}><Checkbox isSelected={selected} onChange={onToggle} aria-label={`选择 ${source.label}`} /><span className="flex min-w-0 grow flex-col gap-0.5"><SourceLink source={source} />- {source.last_error- ? <small className="text-caption-1-regular text-text-error-primary">{source.last_error}</small>- : null}+ {source.last_error ? <ErrorLine text={source.last_error} /> : null}</span>{/* 卡片里站名只出一枚图标:这一行紧挨着的就是作者名和状态徽章,站名写出来是同一个词并排两次。名字仍在 DOM 里,读屏和取不到图标时都还读得到;表格那边「站点」是独立@@ -164,19 +165,21 @@ function SourceRow(<SourceIcon provider={source.provider} label={source.provider_label} /></span><StatusBadge source={source} />- <span className="shrink-0 text-body-2-regular whitespace-nowrap text-text-secondary">- {checkedText(source)}- </span>- <Switch aria-label={`启用 ${source.label}`} isSelected={source.enabled}- isDisabled={handlers.readOnly} onChange={(on) => handlers.toggle(source, on)} />- <span className="flex shrink-0 items-center gap-1">- <Button variant="secondary" size="small" iconOnly leadingIcon={RiRefreshLine}- aria-label={`检查 ${source.label} 的更新`}- disabled={!source.enabled || handlers.readOnly} {...busyProps(handlers.busy)}- onClick={() => handlers.check([source.id])} />- <Button variant="secondary" size="small" iconOnly leadingIcon={RiDeleteBinLine}- aria-label={`移除 ${source.label}`} disabled={handlers.readOnly}- onClick={() => handlers.remove(source)} />+ <span data-follow-source-controls="" className="contents max-sm:flex max-sm:w-full max-sm:flex-wrap max-sm:items-center max-sm:gap-1.5">+ <span className="shrink-0 text-body-2-regular whitespace-nowrap text-text-secondary max-sm:mr-auto max-sm:text-caption-1-regular">+ {checkedText(source)}+ </span>+ <Switch aria-label={`启用 ${source.label}`} isSelected={source.enabled}+ isDisabled={handlers.readOnly} onChange={(on) => handlers.toggle(source, on)} />+ <span className="flex shrink-0 items-center gap-1">+ <Button variant="secondary" size="small" iconOnly leadingIcon={RiRefreshLine}+ aria-label={`检查 ${source.label} 的更新`}+ disabled={!source.enabled || handlers.readOnly} {...busyProps(handlers.busy)}+ onClick={() => handlers.check([source.id])} />+ <Button variant="secondary" size="small" iconOnly leadingIcon={RiDeleteBinLine}+ aria-label={`移除 ${source.label}`} disabled={handlers.readOnly}+ onClick={() => handlers.remove(source)} />+ </span></span></div>);@@ -207,27 +210,30 @@ function AuthorCard(<div data-follow-author-header data-open={open || undefined}className="flex flex-wrap items-center gap-3 px-2 py-2.5"><AuthorAvatar group={group} name={name} />- <b className="min-w-0 grow text-body-medium break-words text-text-primary">{name}</b>+ <b className="min-w-0 grow text-body-medium wrap-anywhere text-text-primary max-sm:basis-0">{name}</b><Button variant="secondary" size="small" iconOnly leadingIcon={RiRefreshLine}aria-label={`检查 ${name} 的全部来源`} disabled={!enabled.length || handlers.readOnly}{...busyProps(handlers.busy)} onClick={() => handlers.check(enabled)} />- <span className="flex shrink-0 items-center gap-1" title={providers}>- {group.map((source) => <SourceIcon key={source.id} provider={source.provider} />)}- {/* 只读屏用的文字走 `VisuallyHidden`:它把样式写在元素上,不会生成一个和旧- 样式表同名的工具类(`web/css/01-base.css` 里那条 `.sr-only` 带 !important)。 */}- <VisuallyHidden>{`来源:${providers}`}</VisuallyHidden>+ {/* 窄屏固定两行:上一行头像、名字与检查键,下一行站标、失败数与全选、收起。 */}+ <span data-follow-author-controls="" className="contents max-sm:flex max-sm:w-full max-sm:items-center max-sm:gap-2">+ <span className="flex shrink-0 items-center gap-1 max-sm:mr-auto max-sm:min-w-0 max-sm:shrink max-sm:flex-wrap" title={providers}>+ {group.map((source) => <SourceIcon key={source.id} provider={source.provider} />)}+ {/* 只读屏用的文字走 `VisuallyHidden`:它把样式写在元素上,不会生成一个和旧+ 样式表同名的工具类(`web/css/01-base.css` 里那条 `.sr-only` 带 !important)。 */}+ <VisuallyHidden>{`来源:${providers}`}</VisuallyHidden>+ </span>+ {bad+ ? <span className="shrink-0 text-body-2-regular text-text-error-primary">{`${bad} 个失败`}</span>+ : null}+ <Button variant="secondary" size="small" leadingIcon={RiCheckDoubleLine}+ aria-pressed={state.all ? 'true' : state.some ? 'mixed' : 'false'}+ aria-label={`${state.all ? '取消全选' : '全选'} ${name} 的来源`}+ onClick={() => onToggleGroup(!state.all)}>{state.all ? '取消全选' : '全选'}</Button>+ <Button variant="secondary" size="small" aria-expanded={open} aria-controls={panel}+ leadingIcon={open ? RiArrowUpSLine : RiArrowDownSLine}+ aria-label={`${open ? '收起' : '展开'} ${name} 的来源`}+ onClick={() => onOpen(!open)}>{open ? '收起' : '展开'}</Button></span>- {bad- ? <span className="shrink-0 text-body-2-regular text-text-error-primary">{`${bad} 个失败`}</span>- : null}- <Button variant="secondary" size="small" leadingIcon={RiCheckDoubleLine}- aria-pressed={state.all ? 'true' : state.some ? 'mixed' : 'false'}- aria-label={`${state.all ? '取消全选' : '全选'} ${name} 的来源`}- onClick={() => onToggleGroup(!state.all)}>{state.all ? '取消全选' : '全选'}</Button>- <Button variant="secondary" size="small" aria-expanded={open} aria-controls={panel}- leadingIcon={open ? RiArrowUpSLine : RiArrowDownSLine}- aria-label={`${open ? '收起' : '展开'} ${name} 的来源`}- onClick={() => onOpen(!open)}>{open ? '收起' : '展开'}</Button></div><div id={panel} hidden={!open} data-source-divider>{group.map((source) => (@@ -397,11 +403,7 @@ export function SourceList(props: SourceListProps) {cell: (context) => (<span className="flex min-w-0 flex-col gap-0.5"><SourceLink source={context.row.original.source} />- {context.row.original.source.last_error- ? <small className="text-caption-1-regular text-text-error-primary">- {context.row.original.source.last_error}- </small>- : null}+ {context.row.original.source.last_error ? <ErrorLine text={context.row.original.source.last_error} /> : null}</span>),}),@@ -516,46 +518,51 @@ export function SourceList(props: SourceListProps) {padding: 'none',className: 'flex flex-col gap-4 px-6 py-5 max-sm:px-4',})}>- {/* 放不下时带字的按钮先收成图标,再让整行换行。收起后名字由 `aria-label` 接着说。 */}- <div ref={toolbar} className="flex flex-wrap items-center gap-2">- <h3 className="mr-auto text-title-2-medium text-text-primary">关注列表</h3>- <span className="text-body-2-regular text-text-secondary">- {`${sources.length} 个来源${counts.new ? ` · ${counts.new} 条未看` : ''}`}+ {/* 放不下时带字的按钮先收成图标,再让整行换行。收起后名字由 `aria-label` 接着说。+ 窄屏固定两行:上一行标题、读数与检查全部,下一行版式、排序与全部收起。 */}+ <div ref={toolbar} data-follow-toolbar="" className="flex flex-wrap items-center gap-2">+ <span className="contents max-sm:flex max-sm:min-w-0 max-sm:flex-1 max-sm:flex-col">+ <h3 className="mr-auto text-title-2-medium text-text-primary">关注列表</h3>+ <span className="text-body-2-regular text-text-secondary">+ {`${sources.length.toLocaleString()} 个来源${counts.new ? ` · ${count(counts.new)} 条未看` : ''}`}+ </span></span><Button variant="primary" leadingIcon={RiRefreshLine} disabled={readOnly}aria-label="检查全部" iconOnly={compact}{...busyProps(rowHandlers.busy)} onClick={() => startChecking([])}>检查全部</Button>- <span data-button-group role="group" aria-label="关注列表版式">- <Button variant="ghost" iconOnly- leadingIcon={RiLayoutGridLine} aria-label={LAYOUTS[0][1]} aria-pressed={!asTable}- onClick={() => onLayout('default')} />- <Button variant="ghost" iconOnly- leadingIcon={RiTableLine} aria-label={LAYOUTS[1][1]} aria-pressed={asTable}- onClick={() => onLayout('table')} />+ <span data-follow-toolbar-controls="" className="contents max-sm:flex max-sm:w-full max-sm:items-center max-sm:gap-2">+ <span data-button-group role="group" aria-label="关注列表版式">+ <Button variant="ghost" iconOnly+ leadingIcon={RiLayoutGridLine} aria-label={LAYOUTS[0][1]} aria-pressed={!asTable}+ onClick={() => onLayout('default')} />+ <Button variant="ghost" iconOnly+ leadingIcon={RiTableLine} aria-label={LAYOUTS[1][1]} aria-pressed={asTable}+ onClick={() => onLayout('table')} />+ </span>+ <Select aria-label="关注列表排序" selectedKey={sort}+ onSelectionChange={(key) => {+ if (key === null) return;+ const next = String(key) as SortKey;+ onSort(next, SORT_DEFAULT_DIR[next]);+ }}>+ {SORT_OPTIONS.map(([key, name]) => <SelectItem key={key} id={key}>{name}</SelectItem>)}+ </Select>+ {/* 箭头是装饰,方向由无障碍名称说,而且说的是点下去会得到的那一头。 */}+ <Button variant="secondary" iconOnly+ leadingIcon={dir === 'asc' ? RiArrowUpLine : RiArrowDownLine}+ aria-label={sortLabel(sort, dir)}+ onClick={() => onSort(sort, dir === 'asc' ? 'desc' : 'asc')} />+ {asTable ? null : (+ <Button variant="secondary" iconOnly={compact}+ leadingIcon={allCollapsed ? RiArrowDownSLine : RiArrowUpSLine}+ aria-label={allCollapsed ? '全部展开' : '全部收起'}+ onClick={() => setCollapsed(allCollapsed+ ? new Set<string>()+ : new Set(groups.map((group) => String(group[0]!.author_key || group[0]!.id))))}>+ {allCollapsed ? '全部展开' : '全部收起'}+ </Button>+ )}</span>- <Select aria-label="关注列表排序" selectedKey={sort}- onSelectionChange={(key) => {- if (key === null) return;- const next = String(key) as SortKey;- onSort(next, SORT_DEFAULT_DIR[next]);- }}>- {SORT_OPTIONS.map(([key, name]) => <SelectItem key={key} id={key}>{name}</SelectItem>)}- </Select>- {/* 箭头是装饰,方向由无障碍名称说,而且说的是点下去会得到的那一头。 */}- <Button variant="secondary" iconOnly- leadingIcon={dir === 'asc' ? RiArrowUpLine : RiArrowDownLine}- aria-label={sortLabel(sort, dir)}- onClick={() => onSort(sort, dir === 'asc' ? 'desc' : 'asc')} />- {asTable ? null : (- <Button variant="secondary" iconOnly={compact}- leadingIcon={allCollapsed ? RiArrowDownSLine : RiArrowUpSLine}- aria-label={allCollapsed ? '全部展开' : '全部收起'}- onClick={() => setCollapsed(allCollapsed- ? new Set<string>()- : new Set(groups.map((group) => String(group[0]!.author_key || group[0]!.id))))}>- {allCollapsed ? '全部展开' : '全部收起'}- </Button>- )}</div>{/* 这一趟在后台跑,关掉页面还在继续,所以状态留在页面上而不是只让按钮转一下。 */}@@ -569,7 +576,7 @@ export function SourceList(props: SourceListProps) {extra={<ul className="flex flex-col gap-0.5 text-body-2-regular">{failures.map((row, at) => (<li key={`${row.provider || ''}-${row.ref || at}`}>- {`${row.provider_label || row.provider || ''} ${row.author || row.label || row.ref || ''}:${row.error || '未说明原因'}`}+ {`${row.provider_label || row.provider || ''} ${row.author || row.label || row.ref || ''}:${errorHeadline(row.error || '') || '未说明原因'}`}</li>))}</ul>}>@@ -663,7 +670,7 @@ export function SourceList(props: SourceListProps) {<div className="flex flex-wrap items-center justify-between gap-3"><span className="text-body-2-regular text-text-secondary">- {`${win.start + 1}–${win.end} / ${win.total} ${asTable ? '个来源' : '位创作者'}`}+ {`${count(win.start + 1)}–${count(win.end)} / ${count(win.total)} ${asTable ? '个来源' : '位创作者'}`}</span><Select aria-label="每页显示数量" size="sm" selectedKey={String(pageSize)}onSelectionChange={(key) => { if (key !== null) table.setPageSize(Number(key)) }}>@@ -681,7 +688,7 @@ export function SourceList(props: SourceListProps) {/* 旧 `.fsecfoot`:汇总与它的动作是卡底那一条带,比卡面暗一点点,通到卡片左右两沿。 */<div className="-mx-6 -mb-5 flex flex-wrap items-center gap-2 border-t border-separator-border rounded-b-2xl bg-card-footer px-6 py-4 max-sm:-mx-4 max-sm:px-4"><span className="mr-auto text-body-2-regular text-text-secondary">- {`未看 ${counts.new} · 已看 ${counts.seen || 0} · 已保存 ${counts.saved || 0} · 已忽略 ${counts.ignored || 0}`}+ {`未看 ${count(counts.new)} · 已看 ${count(counts.seen)} · 已保存 ${count(counts.saved)} · 已忽略 ${count(counts.ignored)}`}</span><Button variant="secondary" size="small" onClick={openFollow}>去看更新</Button><Button variant="secondary" size="small" disabled={readOnly} {...busyProps(markAll.isPending)}diff --git a/frontend/src/react/follow-manage/source-view.tsx b/frontend/src/react/follow-manage/source-view.tsxindex 1ae79f1fa..7a4130b0a 100644--- a/frontend/src/react/follow-manage/source-view.tsx+++ b/frontend/src/react/follow-manage/source-view.tsx@@ -3,13 +3,14 @@* 创作者卡片、表格视图和别名清单读的是同一份,所以这几格摆在这里而不是各画一次:* 同一条来源在两种视图里的状态写法一旦分开写,就会出现同一行在卡片里说「未检查」、* 在表格里说「正常」。 */-import { useState } from 'react';+import { useLayoutEffect, useRef, useState } from 'react';import { VisuallyHidden } from 'react-aria-components';import { Chip } from '@/components/base/badges/chip';+import { Button } from '@/components/base/buttons/button';import {- authorAvatar, authorInitial, isBroken, sourceIconUrl, statusText,+ authorAvatar, authorInitial, errorHeadline, isBroken, sourceIconUrl, statusText,type FollowSource,} from './follow-manage';@@ -66,8 +67,41 @@ export function StatusBadge({ source }: { source: FollowSource }) {export function SourceLink({ source }: { source: FollowSource }) {return (<a href={source.url} target="_blank" rel="noreferrer noopener" title="打开原来源"- className="min-w-0 text-body-medium break-words text-text-primary underline-offset-2 hover:underline">+ className="min-w-0 text-body-medium wrap-anywhere text-text-primary underline-offset-2 hover:underline">{source.label}</a>);}++/** 一条报错:列表里只露一行(`errorHeadline`),放不下就截断;多于这一行或被截了时给「查看详情」原地展开全文。+ * 来源的上次检查、JAV 入库的刮削失败都用它,后端常回整页 HTML 或整段 traceback。 */+export function ErrorLine({ text, prefix = '', tone = 'error' }: { text: string; prefix?: string; tone?: 'error' | 'muted' }) {+ const line = useRef<HTMLElement>(null);+ const [open, setOpen] = useState(false);+ const [cut, setCut] = useState(false);+ const head = errorHeadline(text);+ useLayoutEffect(() => {+ const node = line.current;+ if (!node || open) return undefined;+ const measure = () => setCut(node.scrollWidth > node.clientWidth + 1);+ measure();+ const observer = new ResizeObserver(measure);+ observer.observe(node);+ return () => observer.disconnect();+ }, [head, open]);+ const more = cut || head !== String(text || '').trim();+ return (+ <span className="flex min-w-0 max-w-full flex-col items-start gap-0.5">+ <small ref={line} data-error-line=""+ className={`max-w-full text-caption-1-regular ${tone === 'error' ? 'text-text-error-primary' : 'text-text-secondary'} ${open ? 'whitespace-pre-line wrap-anywhere' : 'block truncate'}`}>+ {prefix}{open ? text : head}+ </small>+ {more ? (+ <Button variant="ghost" size="xs" data-error-line-toggle="" aria-expanded={open} className="-ml-2"+ onClick={() => setOpen(!open)}>+ {open ? '收起详情' : '查看详情'}+ </Button>+ ) : null}+ </span>+ );+}diff --git a/frontend/src/react/sidebar/sidebar-island.tsx b/frontend/src/react/sidebar/sidebar-island.tsxindex 9a17c497e..abd143754 100644--- a/frontend/src/react/sidebar/sidebar-island.tsx+++ b/frontend/src/react/sidebar/sidebar-island.tsx@@ -343,7 +343,7 @@ function ChipList({ rows, filterKey, multi, selected, counts, host: at, onTogglereturn (<button type="button" key={row.value} data-sidebar-chip="" aria-pressed={selected.includes(row.value)}data-key={filterKey} data-val={row.value} data-multi={multi ? '1' : '0'}- data-offline={row.offline ? '' : undefined} disabled={!!row.offline} title={row.offline}+ data-offline={row.offline ? '' : undefined} disabled={!!row.offline} title={row.offline || row.label}onClick={() => onToggle(filterKey, row.value, multi)}><Dot dot={row.dot} /><span data-sidebar-chip-label="">{row.label}</span>@@ -418,7 +418,7 @@ function FollowChips({ rows, host: at, selected, badges }: {<div data-sidebar-chips="">{rows.map((row) => (<button type="button" key={row.value} data-sidebar-chip="" data-online="" data-follow-drawer-tag={row.value}- aria-pressed={selected ? selected.has(row.value) : undefined}+ aria-pressed={selected ? selected.has(row.value) : undefined} title={row.label}onClick={() => (selected ? at.selectFollowTag(row.value) : at.openFollowTag(row.value))}><span data-sidebar-chip-label="">{row.label}</span><span data-sidebar-count="" data-count-badge={badges ? `follow:${row.value}` : undefined}>diff --git a/frontend/src/react/wants/want-list.tsx b/frontend/src/react/wants/want-list.tsxindex 65f18fb3b..1a2a1a1a2 100644--- a/frontend/src/react/wants/want-list.tsx+++ b/frontend/src/react/wants/want-list.tsx@@ -3,7 +3,7 @@* 卡片下方的候选来自 JavDB;「搜索资源」打开云下载弹层,查自配索引器或贴磁力。页上那颗* 「提交磁力」是不挂在任何作品上的同一个弹层。 */import { useState } from 'react';-import type { KeyboardEvent } from 'react';+import type { KeyboardEvent, ReactNode } from 'react';import { useQuery } from '@tanstack/react-query';import { RiStarLine, RiExternalLinkLine, RiDeleteBinLine } from '@remixicon/react';@@ -18,6 +18,9 @@ import { DOWNLOADS_KEY, DOWNLOADS_URL } from '../activity/downloads-panel';import { cardClass } from '../components/card';import { EmptyState } from '../components/empty-state';import { Note } from '../components/note';+import { Pagination } from '../follow-manage/source-list';+import { pageWindow } from '../follow-manage/follow-manage';+import { ErrorLine } from '../follow-manage/source-view';import { Help } from '../settings/section';import { WantMagnets } from './want-magnets';import { busyProps, useAction } from '../settings/use-action';@@ -27,6 +30,8 @@ import {} from './wants';const ORIGINS: Record<Want['origin'], string> = { code: '手动添加', feed: 'Feed 新作', follow: '关注' };+/** 每一段一页摆多少张:一张卡二十来个节点,上千条一次摆开就是十几万像素高的一页。 */+export const WANT_PAGE_SIZE = 20;/** 资料那一行:发行日、厂牌、女优、从哪儿加进来的。 */const facts = (want: Want) => [want.release_date, want.studio, want.performers, ORIGINS[want.origin]]@@ -57,7 +62,7 @@ function WantRow({ want, readOnly, busy, onReset, onRemove, onCloudDownload, dow<Cover want={want} /><div className="flex min-w-0 flex-1 flex-col gap-1"><p className="flex min-w-0 flex-wrap items-baseline gap-x-2">- <b className="text-headline-medium text-text-primary">{wantName(want)}</b>+ <b className="min-w-0 text-headline-medium wrap-anywhere text-text-primary">{wantName(want)}</b>{want.code && want.title ? (<span className="min-w-0 truncate text-body-2-regular text-text-secondary">{want.title}</span>) : null}@@ -65,7 +70,7 @@ function WantRow({ want, readOnly, busy, onReset, onRemove, onCloudDownload, dow{facts(want) ? <p className="text-body-2-regular text-text-secondary">{facts(want)}</p> : null}{!want.code || want.phase === 'unreleased' || want.phase === 'acquired' ?<p data-want-note="" className="text-caption-1-regular text-text-secondary">{searchNote(want)}</p> : null}- {want.scrape_error ? <p className="text-caption-1-regular text-text-secondary">资料未取得:{want.scrape_error}</p> : null}+ {want.scrape_error ? <ErrorLine text={want.scrape_error} prefix="资料未取得:" tone="muted" /> : null}<div className="mt-1 flex flex-wrap items-center gap-2">{source ? <ButtonLink data-button-link="" variant="secondary" size="small" trailingIcon={RiExternalLinkLine} href={source} target="_blank" rel="noopener noreferrer">来源页</ButtonLink> : null}{/* 还在找的两段才给云下载:未发售的没有资源可下,已入库的已经到手。 */}@@ -87,6 +92,31 @@ function WantRow({ want, readOnly, busy, onReset, onRemove, onCloudDownload, dow);}+/** 一段(待找、未发售……):标题带这一段的总数,多于一页时分页,页码各段各记各的。 */+function WantPhase({ phase, label, rows, row }: {+ phase: string; label: string; rows: Want[]; row(want: Want): ReactNode;+}) {+ const [page, setPage] = useState(1);+ const win = pageWindow(rows.length, WANT_PAGE_SIZE, page);+ return (+ <section aria-label={label} data-want-phase={phase} className="flex flex-col gap-4">+ <h3 className="flex items-baseline gap-2 text-title-2-medium text-text-primary">+ {label}+ <span className="text-body-2-regular tabular-nums text-text-secondary">{rows.length.toLocaleString()}</span>+ </h3>+ <ul className="flex flex-col gap-4">{rows.slice(win.start, win.end).map(row)}</ul>+ {win.pages > 1 ? (+ <div data-want-pager="" className="flex flex-wrap items-center justify-between gap-3">+ <span className="text-body-2-regular tabular-nums text-text-secondary">+ {`${(win.start + 1).toLocaleString()}–${win.end.toLocaleString()} / ${win.total.toLocaleString()} 条`}+ </span>+ <Pagination label={`${label}分页`} page={win.page} pages={win.pages} onPage={setPage} />+ </div>+ ) : null}+ </section>+ );+}+export interface WantListProps {readOnly: boolean;toast(message: string): void;@@ -179,22 +209,14 @@ export function WantList({ readOnly, toast }: WantListProps) {const rows = items.filter((want) => want.phase === phase);if (!rows.length) return null;return (- <section key={phase} aria-label={label} data-want-phase={phase} className="flex flex-col gap-4">- <h3 className="flex items-baseline gap-2 text-title-2-medium text-text-primary">- {label}- <span className="text-body-2-regular tabular-nums text-text-secondary">{rows.length}</span>- </h3>- <ul className="flex flex-col gap-4">- {rows.map((want) => (- <WantRow key={want.id} want={want} readOnly={readOnly} busy={action.busy}- downloads={downloads.data} provider={selected} toast={toast}- onReset={() => reset(want)} onRemove={() => remove(want)}- onCloudDownload={() => setDownload({- code: want.code || '', title: want.title || '', origin: `wishlist:${want.id}`,- })} />- ))}- </ul>- </section>+ <WantPhase key={phase} phase={phase} label={label} rows={rows} row={(want) => (+ <WantRow key={want.id} want={want} readOnly={readOnly} busy={action.busy}+ downloads={downloads.data} provider={selected} toast={toast}+ onReset={() => reset(want)} onRemove={() => remove(want)}+ onCloudDownload={() => setDownload({+ code: want.code || '', title: want.title || '', origin: `wishlist:${want.id}`,+ })} />+ )} />);})}<CloudDownloadDialog prefill={download} close={() => setDownload(null)} receipt={toast} provider={selected} />diff --git a/frontend/test/board-skeleton.test.ts b/frontend/test/board-skeleton.test.tsindex aa5be64ae..eaec0cb9d 100644--- a/frontend/test/board-skeleton.test.ts+++ b/frontend/test/board-skeleton.test.ts@@ -29,9 +29,9 @@ describe('Board 页面骨架', () => {['/activity', '.activitysection', 3],['/duplicates', '[data-duplicate-group] .duplicate-row', 4],['/quality-goals', '.peach-react .card-grid-cover > li', 6],- ['/follow-manage', '.peach-react .ui-follow-skeleton-surface .follow-skeleton-author', 3],- ['/configuration', '.peach-react .ui-configpage section', 2],- ['/playlists', '.ui-playlistcards > .playlistcard', 6],+ ['/follow-manage', '.peach-react .follow-skeleton-surface .follow-skeleton-author', 3],+ ['/configuration', '.peach-react .configpage section', 2],+ ['/playlists', '.playlistcards > .playlistcard', 6],] as const)('%s 复用最终内容容器', (path, selector, count) => {const root = document.createElement('div');root.innerHTML = boardPageSkeleton(path);@@ -57,10 +57,18 @@ describe('Board 页面骨架', () => {expect(root.querySelector('.board-segment-thumb')).toBeNull();expect(root.querySelector('[data-section-items] [aria-selected=true]')?.textContent).toBe('关注列表');const track = root.querySelector('[data-section-items]')!;- expect([...track.children].map((span) => span.textContent)).toEqual(['关注列表', '添加关注', 'JAV 订阅源', '想要', '来源和凭证']);+ expect([...track.children].map((span) => span.textContent)).toEqual(['关注列表', '添加关注', 'JAV 订阅源', 'JAV 入库', '来源和凭证']);+ });+ it('关注骨架选中地址栏 `?tab=` 那一枚页签,列表以外的页签不画关注列表的工具行', () => {+ const feeds = follow({ followTab: 'feeds' });+ expect(feeds.querySelector('[data-section-items] [aria-selected=true]')?.textContent).toBe('JAV 订阅源');+ expect(feeds.querySelector('.follow-skeleton-toolbar')).toBeNull();+ expect(feeds.querySelector('.follow-skeleton-surface')).not.toBeNull();+ expect(follow({ followTab: 'wants' }).querySelector('[data-section-items] [aria-selected=true]')?.textContent).toBe('JAV 入库');+ expect(follow({ followTab: 'nope' }).querySelector('[data-section-items] [aria-selected=true]')?.textContent).toBe('关注列表');});it('关注骨架的工具行按 Board UI 最终变体画:检查全部是主按钮,视图切换是按版式选中的按钮组', () => {- const toolbar = follow().querySelector('.ui-follow-skeleton-toolbar')!;+ const toolbar = follow().querySelector('.follow-skeleton-toolbar')!;const check = toolbar.querySelector(':scope > button')!;expect(check.textContent).toBe('检查全部');expect(check.classList.contains('bg-button-primary')).toBe(true);@@ -69,13 +77,13 @@ describe('Board 页面骨架', () => {expect(group.map((button) => button.getAttribute('aria-pressed'))).toEqual(['true', 'false']);expect(group.every((button) => button.classList.contains('bg-button-ghost-background'))).toBe(true);expect(toolbar.querySelector('button[aria-haspopup="listbox"]')?.textContent).toBe('检查时间');- expect(toolbar.lastElementChild?.textContent).toBe('全部收起');+ expect([...toolbar.querySelectorAll('button')].at(-1)?.textContent).toBe('全部收起');const tableGroup = follow({ followLayout: 'table' }).querySelectorAll('[data-button-group] > button');expect([...tableGroup].map((button) => button.getAttribute('aria-pressed'))).toEqual(['false', 'true']);});it('排序框与方向键跟着地址栏上的排序', () => {const toolbar = (options: Parameters<typeof boardPageSkeleton>[1]) =>- follow(options).querySelector('.ui-follow-skeleton-toolbar')!;+ follow(options).querySelector('.follow-skeleton-toolbar')!;const arrow = (root: Element) => root.querySelector('button[aria-haspopup]')!.parentElement!.nextElementSibling!.querySelector('use')?.getAttribute('href');expect(arrow(toolbar({}))).toBe('#i-arrow-down');@@ -88,13 +96,13 @@ describe('Board 页面骨架', () => {const root = follow();expect(root.querySelectorAll('.follow-skeleton-source')).toHaveLength(10);for (const row of root.querySelectorAll('.follow-skeleton-source')) {- const actions = [...row.lastElementChild!.children];+ const actions = [...row.lastElementChild!.lastElementChild!.children];expect(actions.map((button) => button.querySelector('use')?.getAttribute('href'))).toEqual(['#i-refresh-cw', '#i-trash']);for (const button of actions) expect(button.className).toContain('size-8 rounded-lg p-0');}const head = root.querySelector('.follow-skeleton-author [data-follow-author-header]')!;- expect([...head.querySelectorAll(':scope > button')].map((button) => button.textContent)).toEqual(['', '全选', '收起']);- expect(root.querySelector('.ui-follow-skeleton-surface > .group')?.textContent).toBe('全选本页');+ expect([...head.querySelectorAll('button')].map((button) => button.textContent)).toEqual(['', '全选', '收起']);+ expect(root.querySelector('.follow-skeleton-surface > .group')?.textContent).toBe('全选本页');expect(root.querySelector('[data-selection-dock]')).toBeNull();});it('口味骨架保留分段背景与状态行间距', () => {@@ -102,8 +110,8 @@ describe('Board 页面骨架', () => {root.innerHTML = boardPageSkeleton('/taste');expect(root.querySelector('.insightswitch[data-board-segments]')).not.toBeNull();expect(root.querySelector('.skeleton-segment-selected')?.textContent).toBe('浏览器记录');- expect(root.querySelector('.ui-tastehead + .ui-tastestate + .ui-tastesummaries')).not.toBeNull();- expect(root.querySelector('.ui-tastehead .skeleton-tabs')).toBeNull();+ expect(root.querySelector('.tastehead + .tastestate + .tastesummaries')).not.toBeNull();+ expect(root.querySelector('.tastehead .skeleton-tabs')).toBeNull();});it('关注表格视图是 Board UI 表格外框,当前排序那一列带方向', () => {const root = follow({ followLayout: 'table' });@@ -113,14 +121,14 @@ describe('Board 页面骨架', () => {expect([...table.querySelectorAll('[data-sort-indicator][data-direction]')].map((mark) => [mark.parentElement!.textContent, mark.getAttribute('data-direction')])).toEqual([['上次检查', 'descending']]);expect(root.querySelector('.follow-skeleton-author')).toBeNull();- expect(root.querySelector('.ui-follow-skeleton-toolbar')?.textContent).not.toContain('全部收起');+ expect(root.querySelector('.follow-skeleton-toolbar')?.textContent).not.toContain('全部收起');});it('表格骨架的行数跟着每页条数走', () => {localStorage.setItem('peach.settings.v1', JSON.stringify({ followPageSize: 40 }));try {const root = follow({ followLayout: 'table' });expect(root.querySelectorAll('.follow-skeleton-table tbody tr')).toHaveLength(40);- expect(root.querySelector('.ui-follow-skeleton-surface > :last-child button[aria-haspopup]')?.textContent).toBe('每页 40 条');+ expect(root.querySelector('.follow-skeleton-surface > :last-child button[aria-haspopup]')?.textContent).toBe('每页 40 条');} finally { localStorage.removeItem('peach.settings.v1') }});});diff --git a/frontend/test/react/follow-detail.test.tsx b/frontend/test/react/follow-detail.test.tsxindex 23d3f9b60..58b8f1741 100644--- a/frontend/test/react/follow-detail.test.tsx+++ b/frontend/test/react/follow-detail.test.tsx@@ -9,7 +9,7 @@ import {collectionCopy, detailTags, followItemKey, tagCategory,type FollowDetailActions, type FollowDetailData, type FollowDetailItem, type FollowDetailProps,} from '../../src/react/follow-detail/follow-detail';-import { FollowDetailPage } from '../../src/react/follow-detail/follow-detail-page';+import { FOLLOW_DOTS_MAX, FollowDetailPage } from '../../src/react/follow-detail/follow-detail-page';import { FOLLOW_CREDENTIALS_KEY, type FollowFeedHelpers, type FollowGroup } from '../../src/react/follow-feed/follow-feed';import { openPhotoLightbox } from '../../src/react/photo-lightbox/photo-lightbox-dialog';import { queryClient } from '../../src/react/query';@@ -97,6 +97,12 @@ describe('取数', () => {await settle();expect(gone.textContent).toContain('这条关注内容已不存在');});+ /* 不存在的条目重试也取不回来:只给一条回到关注的路。 */+ const back = gone.querySelector('[data-follow-detail-gone] [data-note-action]');+ expect(back?.textContent).toBe('回到关注');+ expect(gone.textContent).not.toContain('重试');+ await click(back);+ expect(props.actions.close).toHaveBeenCalled();});});@@ -131,6 +137,34 @@ describe('侧栏', () => {expect(host.querySelector('[data-follow-detail-identity] > div')?.textContent).toBe('作者发布者 Poster');});+ it('标题为空时标题区与多媒体队列写同一句「未命名内容」', async () => {+ const { host } = await show(data(item(5, { title: '', media_items: [+ { index: 0, media_kind: 'video', name: 'a.mp4', resource_group: 'g1' }, { ...image(1), resource_group: 'g1' },+ ] })));+ expect(host.querySelector('[data-follow-detail-name]')?.textContent).toBe('未命名内容');+ expect(host.querySelector('[data-follow-queue]')?.textContent).toContain('未命名内容 · 2 个媒体');+ });++ it('摘要默认收起,量出来被截了才给「展开」,展开后同一枚键收回', async () => {+ const high = vi.spyOn(HTMLElement.prototype, 'scrollHeight', 'get').mockReturnValue(400);+ const box = vi.spyOn(HTMLElement.prototype, 'clientHeight', 'get').mockReturnValue(200);+ try {+ const { host } = await show(data(item(6, { summary: '很长的正文' })));+ const summary = host.querySelector('[data-follow-detail-summary]')!;+ expect(summary.hasAttribute('data-clamped')).toBe(true);+ const toggle = host.querySelector('[data-follow-summary-toggle]')!;+ expect(toggle.textContent).toBe('展开');+ await click(toggle);+ expect(summary.hasAttribute('data-clamped')).toBe(false);+ expect(host.querySelector('[data-follow-summary-toggle]')?.textContent).toBe('收起');+ } finally {+ high.mockRestore();+ box.mockRestore();+ }+ const { host: short } = await show(data(item(7, { summary: '短' })));+ expect(short.querySelector('[data-follow-summary-toggle]')).toBeNull();+ });+it('媒体没取回来的原因画在侧栏里', async () => {const { host } = await show(data(item(3, { playable: false, media_kind: 'external', media_error: '附件要登录' })));expect(host.querySelector('[data-follow-media-issue]:not([hidden])')?.textContent).toBe('媒体未取得:附件要登录');@@ -232,6 +266,17 @@ describe('媒体', () => {expect(host.querySelector('[data-media-thumb-fallback]')?.hasAttribute('hidden')).toBe(false);});+ it(`轮播多于 ${FOLLOW_DOTS_MAX} 张时圆点条换成「当前 / 总数」`, async () => {+ const many = Array.from({ length: FOLLOW_DOTS_MAX + 100 }, (_, index) => image(index));+ const { host } = await show(data(item(14, { media_kind: 'image', media_items: many })), { mediaIndex: 99 });+ expect(host.querySelector('[data-follow-image-dots]')).toBeNull();+ expect(host.querySelector('[data-follow-image-count]')?.textContent).toBe('100 / 120');+ queryClient.clear();+ const { host: few } = await show(data(item(15, { media_kind: 'image', media_items: [image(0), image(1), image(2)] })));+ expect(few.querySelectorAll('[data-follow-image-dots] [data-follow-image-item]')).toHaveLength(3);+ expect(few.querySelector('[data-follow-image-count]')).toBeNull();+ });+it('多图帖点图把整组交给灯箱,从当前这张开始', async () => {const shown = item(12, { media_kind: 'image', media_items: [image(0), image(1), image(2)] });const { host } = await show(data(shown), { mediaIndex: 1 });diff --git a/frontend/test/react/follow-feed.test.tsx b/frontend/test/react/follow-feed.test.tsxindex bfa9e5f66..2f06ae770 100644--- a/frontend/test/react/follow-feed.test.tsx+++ b/frontend/test/react/follow-feed.test.tsx@@ -7,7 +7,7 @@ import { act, useState } from 'react';import { afterEach, describe, expect, it, vi } from 'vitest';import {- backfillState, dropCondition, followConditions, followPageUrl, followStack, groupMediaKinds, itemForMedia,+ FOLLOW_AUTHORS_FIRST, FOLLOW_AUTO_LOAD_LIMIT, authorRow, backfillState, dropCondition, followConditions, followPageUrl, followStack, groupMediaKinds, itemForMedia,nextSort, prefetchFollowFeed, randomOrder, sortAriaLabel, withStatus,type FollowFeedActions, type FollowFeedHelpers, type FollowFeedProps, type FollowGroup, type FollowItem,type FollowPage, type FollowSource, type FollowStackInfo, type FollowView,@@ -15,7 +15,7 @@ import {import { FollowFeedPage } from '../../src/react/follow-feed/follow-feed-page';import { learnFollowDims } from '../../src/react/follow-feed/follow-marks';import { queryClient } from '../../src/react/query';-import { click, mount, settle } from './render';+import { click, mount, settle, type } from './render';/* 回写尺寸那一批由 `follow-marks.test.ts` 量;这里只看卡片在什么时候报。 */vi.mock(import('../../src/react/follow-feed/follow-marks'), async (importOriginal) => ({@@ -43,12 +43,12 @@ const source = (id: number, author: string, extra: Partial<FollowSource> = {}):describe('请求地址', () => {it('默认那一档不写进去,标签按逗号拼,种子只跟着随机排序走', () => {- expect(followPageUrl(VIEW, 0)).toBe('/api/follow?limit=300&offset=0');+ expect(followPageUrl(VIEW, 0)).toBe('/api/follow?limit=100&offset=0');const url = new URL(followPageUrl(view({status: 'saved', author: 'name:kou', provider: 'kemono', tags: ['3d', 'loop'], work: 'zelda', sort: 'hot', dir: 'asc',- }), 300), 'http://peach.test');+ }), 100), 'http://peach.test');expect(Object.fromEntries(url.searchParams)).toEqual({- limit: '300', offset: '300', status: 'saved', author: 'name:kou', provider: 'kemono', tag: '3d,loop', work: 'zelda',+ limit: '100', offset: '100', status: 'saved', author: 'name:kou', provider: 'kemono', tag: '3d,loop', work: 'zelda',sort: 'hot', dir: 'asc',});expect(new URL(followPageUrl(view({ sort: 'rand', seed: 42 }), 0), 'http://peach.test').searchParams.get('seed')).toBe('42');@@ -91,6 +91,16 @@ describe('取样', () => {expect(randomOrder(keys, (key) => key, 12)).not.toEqual(once);expect([...once].sort()).toEqual([...keys].sort());});++ it('创作者排露出前 24 位;有搜索词时在全部创作者里按名字找,按下的那位总在排上', () => {+ const order = Array.from({ length: 400 }, (_, index) => `k${index}`);+ const nameOf = (key: string) => (key === 'k399' ? 'Mira' : `作者${key}`);+ expect(authorRow(order, nameOf, '', '')).toEqual(order.slice(0, FOLLOW_AUTHORS_FIRST));+ expect(authorRow(order, nameOf, ' mira ', '')).toEqual(['k399']);+ expect(authorRow(order, nameOf, 'mira', 'k5')).toEqual(['k5', 'k399']);+ expect(authorRow(order, nameOf, '', 'k300')).toEqual(['k300', ...order.slice(0, FOLLOW_AUTHORS_FIRST)]);+ expect(authorRow(order, nameOf, '没有这个人', '')).toEqual([]);+ });});describe('媒体与一叠', () => {@@ -331,6 +341,57 @@ describe('页面', () => {expect(given.actions.loaded).toHaveBeenCalled();});+ it('列表取不到时页头照画:标题与「管理关注」都在,失败原因下面给重试', async () => {+ const fetcher = vi.fn(async (url: string) => (url.startsWith('/api/follow?')+ ? { ok: false, status: 500, json: async () => ({ error: '服务端出错' }) }+ : { ok: true, status: 200, json: async () => ({ providers: [] }) }));+ vi.stubGlobal('fetch', fetcher);+ const given = props();+ const host = await open(given);+ expect(host.querySelector('[data-follow-title]')?.textContent).toBe('关注');+ await click(host.querySelector('[data-follow-manage]'));+ expect(given.actions.openManage).toHaveBeenCalled();+ expect(host.querySelector('[data-media-error] [data-note-action]')?.textContent).toBe('重试');+ });++ it('有来源、一条更新都还没有:没设筛选时说还没有更新,设了筛选才叫人换筛选', async () => {+ serve(feed([]));+ const bare = await open(props());+ expect(bare.querySelector('[data-follow-empty]')?.textContent).toContain('还没有更新');+ expect(bare.querySelector('[data-follow-empty]')?.textContent).not.toContain('筛选');+ queryClient.clear();+ serve(feed([]));+ const filtered = await open(props({ view: view({ status: 'saved' }), revision: 2 }));+ expect(filtered.querySelector('[data-follow-empty]')?.textContent).toContain('切换状态或来源筛选后再试');+ });++ it('创作者多于一排时出搜索框,搜的是全部创作者', async () => {+ const many = Array.from({ length: FOLLOW_AUTHORS_FIRST + 6 }, (_, index) => `a${index}`);+ const sources = many.map((author, index) => source(index + 1, author, { author_name: author === 'a29' ? 'Zed Lastone' : author }));+ serve(feed([group(item(1))], { sources, facets: { authors: many.map((author) => `name:${author}`), providers: ['kemono'] } }));+ const host = await open(props());+ expect(authorOrder(host)).toHaveLength(FOLLOW_AUTHORS_FIRST);+ await type(host.querySelector<HTMLInputElement>('[data-follow-author-search] input'), 'lastone');+ expect(authorOrder(host)).toEqual(['name:a29']);+ await type(host.querySelector<HTMLInputElement>('[data-follow-author-search] input'), '没有这个人');+ expect(authorOrder(host)).toEqual([]);+ expect(host.querySelector('[data-follow-author-none]')?.textContent).toContain('没有这个人');+ });++ it(`摆满 ${FOLLOW_AUTO_LOAD_LIMIT} 组以后「加载更多」要点一下才接下一页`, async () => {+ const groups = Array.from({ length: FOLLOW_AUTO_LOAD_LIMIT }, (_, index) => group(item(index + 1)));+ const fetcher = serve(feed(groups, { has_more: true }));+ const host = await open(props());+ const more = host.querySelector('[data-follow-pagination] button[data-entity-more]');+ expect(more?.textContent).toBe('加载更多');+ const before = fetcher.mock.calls.filter(([url]) => String(url).startsWith('/api/follow?')).length;+ await click(more);+ await settle();+ const pages = fetcher.mock.calls.filter(([url]) => String(url).startsWith('/api/follow?'));+ expect(pages).toHaveLength(before + 1);+ expect(new URL(String(pages.at(-1)![0]), 'http://peach.test').searchParams.get('offset')).toBe('100');+ });+it('没有关注任何来源时指到添加关注', async () => {serve(feed([], { sources: [], facets: {} }));const host = await open(props());diff --git a/frontend/test/react/follow-manage.test.tsx b/frontend/test/react/follow-manage.test.tsxindex 23a817846..2cc582419 100644--- a/frontend/test/react/follow-manage.test.tsx+++ b/frontend/test/react/follow-manage.test.tsx@@ -11,7 +11,7 @@ import * as legacyUi from '@peach/legacy/ui';import { JOB_RUNNING_POLL_MS } from '../../src/react/background-job';import { queryClient } from '../../src/react/query';import {- authorAvatar, authorGroups, authorInitial, authorName, checkSummary, FEEDS_CHECK_URL, FEED_SOURCE_URL,+ authorAvatar, authorGroups, authorInitial, authorName, checkSummary, errorHeadline, feedIntervalText, FEEDS_CHECK_URL, FEED_SOURCE_URL,FEEDS_LOOKUP_URL, FEEDS_URL, FOLLOW_CHECK_URL,FOLLOW_CREDENTIAL_URL, FOLLOW_CREDENTIALS_URL, FOLLOW_RESOLVE_URL, FOLLOW_SOURCE_URL,FOLLOW_SUGGEST_URL, FOLLOW_URL, pageWindow, prefetchFollowManage,@@ -568,6 +568,45 @@ it('还有未看时卡底给出计数和三颗动作键,没有未看就整条expect(buttonNamed('全部忽略', quiet.host)).toBeNull();});+it('读数、列表头与卡底的计数都带千分位,六位数以上的读数换小一号字', async () => {+ const counts = { new: 1284000, seen: 22000, saved: 0, ignored: 0 };+ const { host } = await open({ data: follow({ counts }) });+ const readings = [...host.querySelectorAll('[data-follow-reading]')];+ const big = readings.find((node) => node.textContent === '1,284,000 条')!;+ expect(big.className).toContain('text-title-3-medium');+ expect(big.querySelector('small')?.className).toContain('whitespace-nowrap');+ expect(readings.find((node) => node.textContent?.startsWith('0'))?.className).toContain('text-title-1-medium');+ expect(host.textContent).toContain('4 个来源 · 1,284,000 条未看');+ expect(host.textContent).toContain('未看 1,284,000 · 已看 22,000');+});++it('报错只露一行:traceback 取最后那行的异常,「查看详情」原地展开全文', async () => {+ const trace = 'Traceback (most recent call last):\n File "kemono.py", line 412, in fetch_page\n'+ + 'peach.follow_providers.ProviderError: HTTP 403';+ const { host } = await open({ data: follow({ sources: [source({ id: 9, last_status: 'error', last_error: trace })] }) });+ const line = host.querySelector('[data-error-line]')!;+ expect(line.textContent).toBe('peach.follow_providers.ProviderError: HTTP 403');+ const toggle = host.querySelector('[data-error-line-toggle]')!;+ expect(toggle.textContent).toBe('查看详情');+ await click(toggle);+ expect(host.querySelector('[data-error-line]')?.textContent).toBe(trace);+ expect(host.querySelector('[data-error-line-toggle]')?.textContent).toBe('收起详情');+});++it('报错的那一行:traceback 取异常行,别的取第一行非空', () => {+ expect(errorHeadline('Traceback (most recent call last):\n File "a.py"\nValueError: 坏了\n')).toBe('ValueError: 坏了');+ expect(errorHeadline('\n HTTP 429 Too Many Requests\nRetry-After: 60')).toBe('HTTP 429 Too Many Requests');+ expect(errorHeadline('')).toBe('');+});++it('订阅源频率:一小时以内按分钟,两天以内按小时,再长按天', () => {+ expect(feedIntervalText(30)).toBe('每 30 分钟');+ expect(feedIntervalText(720)).toBe('每 12 小时');+ expect(feedIntervalText(2879)).toBe('每 48 小时');+ expect(feedIntervalText(2880)).toBe('每 2 天');+ expect(feedIntervalText(525600)).toBe('每 365 天');+});+it('一条来源都没有时说清这里会显示什么', async () => {const { host } = await open({ data: follow({ sources: [] }) });expect(host.textContent).toContain('还没有关注来源');@@ -647,7 +686,8 @@ it('地址栏指着订阅源时首屏就带着清单,开关、移除与立即const second = checkboxNamed(host, '选择 乙 的新作')!.closest('[role="row"]')!;expect(second.querySelector('[role="rowheader"] img')).toBeNull();expect(second.querySelector('[role="rowheader"] [aria-hidden]')?.textContent).toBe('乙');- expect(host.textContent).toContain('乙 的新作 拉取失败');+ expect(host.textContent).toContain('1 条订阅源拉取失败');+ expect(host.textContent).toContain('乙 的新作:站点 503');expect(host.textContent).toContain('2 个订阅源 · 3 条未看');expect(host.textContent).not.toContain('正在读订阅源');expect(feedReads(fetcher)).toBe(1);diff --git a/frontend/test/react/follow-marks.test.ts b/frontend/test/react/follow-marks.test.tsindex 0d17f79b0..164211c8e 100644--- a/frontend/test/react/follow-marks.test.ts+++ b/frontend/test/react/follow-marks.test.ts@@ -6,8 +6,8 @@ import { afterEach, describe, expect, it, vi } from 'vitest';import type { FollowContext, FollowGroup, FollowItem, FollowSource } from '../../src/react/follow-feed/follow-feed';import {- authorAvatarHtml, followAuthorName, followBadges, followIdentity, followMediaIssue, followTitleMarks, followWhen,- learnFollowDims, sourceIcon,+ FOLLOW_UNTITLED, authorAvatarHtml, followAuthorName, followBadges, followCompactWhen, followIdentity, followMediaIssue,+ followTitle, followTitleMarks, followWhen, learnFollowDims, sourceIcon, sourceMark,} from '../../src/react/follow-feed/follow-marks';const item = (id: number, extra: Partial<FollowItem> = {}): FollowItem =>@@ -29,6 +29,13 @@ describe('来源图标', () => {+ 'alt="F95 <zone>" title="F95 <zone>" loading="lazy" data-drop="self">');expect(sourceIcon('nowhere', '某站')).toBe('');});++ it('只有图标一格的站标:图取不到时由回落脚本换成站名首字,没登记的站直接写首字', () => {+ expect(sourceMark('gofile', 'Gofile')).toBe('<img data-follow-site-icon="" src="/source-icon?provider=gofile" alt="" '+ + 'loading="lazy" data-drop="initial" data-initial="G" data-drop-class="follow-site-initial">');+ expect(sourceMark('itchio', 'itch.io')).toBe('<span class="follow-site-initial" aria-hidden="true">I</span>');+ expect(sourceMark('itchio')).toBe('<span class="follow-site-initial" aria-hidden="true">I</span>');+ });});describe('创作者', () => {@@ -112,6 +119,36 @@ describe('标题前后的字样', () => {/* 账本存 UTC:没带时区标记的串也按 UTC 读,不按本机时区读,否则 UTC+8 的人每个时间都早 8 小时。 */expect(followWhen(item(3, { published_at: '2026-09-04T00:00:00' }))).toBe(when);});++ it('来源只给了相对时间(approximate)时只写到日并加「约」,不写换算出来的时分', () => {+ const now = Date.parse('2026-10-08T12:00:00Z');+ const old = item(1, { published_at: '2009-03-01T12:00:00Z', published_precision: 'approximate' });+ expect(followWhen(old, now)).toBe('约 2009-03-01');+ expect(followCompactWhen(old, now)).toBe('约 2009-03-01');+ expect(followWhen({ ...old, published_precision: 'exact' }, now)).toMatch(/^2009-03-01 \d\d:\d\d$/);+ });++ it('晚于此刻一天以上的时间照写,后面标「晚于现在」;一天以内的时钟误差不标', () => {+ const now = Date.parse('2026-10-08T12:00:00Z');+ const future = item(1, { published_at: '2031-01-01T12:00:00Z' });+ expect(followWhen(future, now)).toMatch(/^2031-01-01 \d\d:\d\d · 晚于现在$/);+ expect(followCompactWhen(future, now)).toBe('2031-01-01 · 晚于现在');+ expect(followWhen(item(2, { published_at: '2026-10-08T20:00:00Z' }), now)).not.toContain('晚于现在');+ });++ it('列表里的短写法:今年的去掉年份,往年的留着', () => {+ const now = Date.parse('2026-10-08T12:00:00Z');+ expect(followCompactWhen(item(1, { published_at: '2026-09-04T12:00:00Z' }), now)).toBe('09-04');+ expect(followCompactWhen(item(2, { published_at: '2024-09-04T12:00:00Z' }), now)).toBe('2024-09-04');+ expect(followCompactWhen(item(3), now)).toBe('时间未取得');+ });++ it('标题为空或只有空白时写同一句「未命名内容」', () => {+ expect(followTitle(item(1, { title: '' }))).toBe(FOLLOW_UNTITLED);+ expect(followTitle(item(2, { title: ' ' }))).toBe('未命名内容');+ expect(followTitle({})).toBe('未命名内容');+ expect(followTitle(item(3, { title: ' 正题 ' }))).toBe('正题');+ });});describe('回写图片尺寸', () => {diff --git a/frontend/test/react/sidebar.test.tsx b/frontend/test/react/sidebar.test.tsxindex 6a0c7b124..37acbe047 100644--- a/frontend/test/react/sidebar.test.tsx+++ b/frontend/test/react/sidebar.test.tsx@@ -303,6 +303,14 @@ describe('筛选分组', async () => {expect(offline.title).toBe('这块盘没挂上');});+ it('名字放不下被省略时悬停读得到全名:普通条目与关注标签都带 title', async () => {+ const { scroll, render } = await setup();+ render({ content: { kind: 'catalog', key: '1', facets: facets({ followTags: [chip('the_legend_of_zelda:_tears_of_the_kingdom', 2)] }) } });+ expect(chipOf(scroll, 'tag', 'a')!.title).toBe(chipOf(scroll, 'tag', 'a')!.querySelector('[data-sidebar-chip-label]')!.textContent);+ expect(scroll.querySelector<HTMLElement>('[data-follow-drawer-tag="the_legend_of_zelda:_tears_of_the_kingdom"]')!.title)+ .toBe(scroll.querySelector('[data-follow-drawer-tag="the_legend_of_zelda:_tears_of_the_kingdom"] [data-sidebar-chip-label]')!.textContent);+ });+it('就地刷新的计数只改数字:名单里有、新聚合里没有的记 0', async () => {const { scroll, render } = await setup();const content = { kind: 'catalog' as const, key: '1', facets: facets() };diff --git a/frontend/test/react/want-list.test.tsx b/frontend/test/react/want-list.test.tsxindex bbaf88640..dce5673d5 100644--- a/frontend/test/react/want-list.test.tsx+++ b/frontend/test/react/want-list.test.tsx@@ -6,7 +6,7 @@ import { notifyManager, QueryClientProvider } from '@tanstack/react-query';import { afterEach, expect, it, vi } from 'vitest';import { queryClient } from '../../src/react/query';-import { WantList } from '../../src/react/wants/want-list';+import { WANT_PAGE_SIZE, WantList } from '../../src/react/wants/want-list';import type { Want, WantsData } from '../../src/react/wants/wants';import { buttonNamed, click, mount, settle, type } from './render';@@ -147,3 +147,21 @@ it('只读的机器:输入框、添加与每行的键都禁用', async () => {expect(buttonNamed('移除', host)!.disabled).toBe(true);expect(buttonNamed('搜索资源', host)!.disabled).toBe(true);});++it(`一段多于 ${WANT_PAGE_SIZE} 条时分页,页码各段各记各的;报错只露一行`, async () => {+ const many = Array.from({ length: 45 }, (_, index) => want(index + 1, {+ phase: index < 42 ? 'unreleased' : 'acquired', scrape_error: index === 0 ? '第一行\n第二行' : null,+ }));+ serve(listed(many));+ const { host } = await open();+ const unreleased = host.querySelector('[data-want-phase="unreleased"]')!;+ expect(unreleased.querySelector('h3')?.textContent).toBe('未发售42');+ expect(unreleased.querySelectorAll('li[data-want-id]')).toHaveLength(WANT_PAGE_SIZE);+ expect(unreleased.querySelector('[data-want-pager]')?.textContent).toContain('1–20 / 42 条');+ expect(unreleased.querySelector('[data-error-line]')?.textContent).toBe('资料未取得:第一行');+ await click(unreleased.querySelector('button[aria-label="第 3 页"]'));+ expect([...unreleased.querySelectorAll<HTMLElement>('li[data-want-id]')].map((row) => row.dataset.wantId)).toEqual(['41', '42']);+ const acquired = host.querySelector('[data-want-phase="acquired"]')!;+ expect(acquired.querySelectorAll('li[data-want-id]')).toHaveLength(3);+ expect(acquired.querySelector('[data-want-pager]')).toBeNull();+});diff --git a/web/app.js b/web/app.jsindex 302412be0..574fc8d64 100644--- a/web/app.js+++ b/web/app.js@@ -238,7 +238,7 @@ function renderCatalogLoading(label='正在读取作品'){挂上时也铺它,键相同就不重画。关注管理的视图偏好经 `followListLayout()` 取:偏好那份存储声明在本行下面,直接读它就是声明前引用,会提升的函数声明才能从这里回去问。排序与方向照地址栏上的那一档。 */const managementPlaceholder=path=>managementSkeletonHtml(path,{followLayout:followListLayout(),- ...(({sort,dir})=>({followSort:sort,followDir:dir}))(followManageParams())});+ ...(({sort,dir,tab})=>({followSort:sort,followDir:dir,followTab:tab}))(followManageParams())});/* 顶部三层只属于首页。深链启动时先画一遍再由路由收起来,等于向管理页和索引页承诺了三条永远不会到货的横条。 */function hideDiscoveryBars(){$('#catalogFilter').style.display='none';syncCatalogFilterScreen()}@@ -1581,16 +1581,19 @@ function feedNewCardHtml(item){.join('<span aria-hidden="true">·</span>');const cover=feedNewCoverHtml(item);// 番号与标题排在同一个两行的标题块里,和资产卡一样:番号加粗打头,标题接在后面截断。- const heading=javTitleHtml({is_jav:true,code:item.code,name:item.code,display_title:item.title||''});+ const name=item.code||String(item.title||'').trim()||'未命名新作';+ const heading=item.code+ ?javTitleHtml({is_jav:true,code:item.code,name:item.code,display_title:item.title||''})+ :esc(name);/* 点击区用自己的类 `.feednewopen`:这一条通向别人的站,不是站内跳转。 */const open=item.link- ?`<a class="feednewopen" href="${esc(item.link)}" target="_blank" rel="noreferrer" aria-label="打开 ${esc(item.code)} 的作品页"></a>`:'';+ ?`<a class="feednewopen" href="${esc(item.link)}" target="_blank" rel="noreferrer" aria-label="打开 ${esc(name)} 的作品页"></a>`:'';return `<article class="card feednewcard${item.read?' isread':''}" data-feed-id="${item.id}">${open}<div class="pic" style="--card-ratio:${COVER_FRONT_RATIO}">${cover}<div class="hovertools feednewtools">- <button type="button" data-feed-action="${item.wanted?'unwant':'want'}" aria-pressed="${!!item.wanted}" title="${item.wanted?'取消想要':'想要'}" aria-label="想要 ${esc(item.code)}">${icon('star')}</button>- <button type="button" data-feed-action="ignore" title="不想看" aria-label="不想看 ${esc(item.code)}">${icon('x')}</button>- <button type="button" data-feed-action="read" title="标为已看过" aria-label="标为已看过 ${esc(item.code)}">${icon('check')}</button></div></div>+ <button type="button" data-feed-action="${item.wanted?'unwant':'want'}" aria-pressed="${!!item.wanted}" title="${item.wanted?'取消想要':'想要'}" aria-label="想要 ${esc(name)}">${icon('star')}</button>+ <button type="button" data-feed-action="ignore" title="不想看" aria-label="不想看 ${esc(name)}">${icon('x')}</button>+ <button type="button" data-feed-action="read" title="标为已看过" aria-label="标为已看过 ${esc(name)}">${icon('check')}</button></div></div><div class="meta"><div class="mtext"><span class="t">${heading}</span><div class="s mono">${label||(item.title?'':'资料还没取到')}</div></div></div></article>`;}@@ -1812,10 +1815,10 @@ function openConfigurationSection(section){`@peach/shell` 里:壳写,路由树的关注元素打开时读。 *//* 关注页一次取一屏。counts 是全库口径(「未看 2292」),groups 只有这一页——两个数并排显示时看起来像自相矛盾,实际是两个口径,所以列表底部要能继续加载。 */-const FOLLOW_PAGE=300;+const FOLLOW_PAGE=100;/* 创作者、来源和标签一起交给服务端。只让状态走服务端、这三个在浏览器里筛的话,药丸上的数字(全库口径)和列表(筛过的这几页)就是两套口径,换个筛选条件- 数字纹丝不动;而且选个冷门创作者,一页 300 条里可能只剩两条,得反复点加载更多。 */+ 数字纹丝不动;而且选个冷门创作者,一页 100 条里可能只剩两条,得反复点加载更多。 */const followPageUrl=offset=>`/api/follow?limit=${FOLLOW_PAGE}&offset=${offset}`+(followFilter?`&status=${followFilter}`:'')diff --git a/web/css/12-cards.css b/web/css/12-cards.cssindex a6f6f7fff..0a5c50606 100644--- a/web/css/12-cards.css+++ b/web/css/12-cards.css@@ -286,6 +286,9 @@ body[data-density="dense"] .card .meta .size{flex:none;white-space:nowrap}/* 「想要」按下时星形填实:同一颗键既是开关也是读数。 */.feednewtools button[aria-pressed="true"] svg{fill:currentColor}.feednewcard .meta .t{font-size:var(--fs-sm)}+/* 番号整段不折行;比卡还宽的长串在卡边收成省略号,不被标题块的溢出裁成半个字。 */+.feednewcard .javidentity{max-width:100%;min-width:0}+.feednewcard .javcode{min-width:0;overflow:hidden;text-overflow:ellipsis}/* 女优名加发行日一行放完,放不下截掉女优名的尾巴:折成两行时断在日期中间,读成两个数。 */.feednewcard .meta .s{flex-wrap:nowrap;white-space:nowrap;min-height:1lh}.feednewcard .meta .s>span{flex:none}