Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(web): 实体组页面在极端内容下不再撑破、漏字或空白

longmeidao3be1a8933ea9
diff --git a/frontend/e2e/entity-filter.test.ts b/frontend/e2e/entity-filter.test.ts
index 8b717b657..ef4702105 100644
--- a/frontend/e2e/entity-filter.test.ts
+++ b/frontend/e2e/entity-filter.test.ts
@@ -208,7 +208,7 @@ describe('实体页筛选浮层', () => {
await page.locator('[data-entity-tag="中出"]').click();
assert.equal(await page.locator('[data-entity-tag="中出"]').getAttribute('aria-pressed'), 'true');
await page.locator('[data-entity-combo] [data-combo-chip]', { hasText: '中出' }).waitFor();
- await page.locator('[data-entity-readout]', { hasText: '视频 · 24 · 中出' }).waitFor({ timeout: 15_000 });
+ await page.locator('[data-entity-readout]', { hasText: '视频 · 24 · 已选 1 个标签' }).waitFor({ timeout: 15_000 });
assert.match(decodeURIComponent(page.url()), /[?&]tag=中出/);
await page.getByRole('button', { name: '撤掉 中出' }).click();
await page.locator('[data-entity-readout]', { hasText: /^视频 · 24$/ }).waitFor({ timeout: 15_000 });
@@ -243,7 +243,7 @@ describe('实体页筛选浮层', () => {
await page.waitForFunction(() => document.querySelector('[data-local-wall]')?.getAttribute('data-layout') === 'fixed');
await segment(page, '图片布局', 'masonry').click();
await page.locator('[data-media-view="videos"]').click();
- await page.locator('[data-entity-readout]', { hasText: '视频 · 24 · 中出' }).waitFor({ timeout: 15_000 });
+ await page.locator('[data-entity-readout]', { hasText: '视频 · 24 · 已选 1 个标签' }).waitFor({ timeout: 15_000 });
assert.equal(await page.locator('[data-entity-tag]').count(), TAGS.length);
assert.equal(await page.locator('[data-entity-combo] [data-combo-chip]').count(), 1);
assert.deepEqual(unexpected(opened), []);
@@ -360,13 +360,13 @@ describe('实体页筛选浮层', () => {
assert.doesNotMatch(page.url(), /[?&]media=/);
const before = stubs.itemQueries.length;
await page.locator('[data-entity-tag="中出"]').click();
- await page.locator('[data-entity-readout]', { hasText: '视频 · 24 · 中出' }).waitFor({ timeout: 15_000 });
+ await page.locator('[data-entity-readout]', { hasText: '视频 · 24 · 已选 1 个标签' }).waitFor({ timeout: 15_000 });
await settle(page);
assert.equal(stubs.itemQueries.length - before, 1, `加一枚标签发了 ${stubs.itemQueries.length - before} 次作品请求`);
await page.locator('[data-media-view="photos"]').click();
await page.locator('[data-entity-readout]', { hasText: /^照片/ }).waitFor({ timeout: 15_000 });
await page.locator('[data-media-view="videos"]').click();
- await page.locator('[data-entity-readout]', { hasText: '视频 · 24 · 中出' }).waitFor({ timeout: 15_000 });
+ await page.locator('[data-entity-readout]', { hasText: '视频 · 24 · 已选 1 个标签' }).waitFor({ timeout: 15_000 });
await settle(page);
assert.equal(stubs.itemQueries.length - before, 1, '切照片再切回视频又取了一遍作品');
assert.deepEqual(unexpected(opened), []);
@@ -374,4 +374,24 @@ describe('实体页筛选浮层', () => {
await opened.close();
}
});
+
+ it('选了六枚长标签,读数只报个数,两种宽度下页面都不被撑宽', { timeout: 60_000 }, async () => {
+ const long = Array.from({ length: 6 }, (_, at) => `とても長い日本語のタグ名その${at + 1}・途中で切れない`);
+ for (const viewport of [DESKTOP, PHONE]) {
+ const opened = await openPerformer(browser, viewport, `?tag=${encodeURIComponent(long.join(','))}`);
+ try {
+ const { page } = opened;
+ await page.locator('[data-entity-readout]', { hasText: '视频 · 24 · 已选 6 个标签' }).waitFor({ timeout: 15_000 });
+ const width = await page.evaluate(() => ({
+ page: document.documentElement.scrollWidth, view: window.innerWidth,
+ readout: document.querySelector('[data-entity-filter-glass] [data-entity-readout]')!.textContent,
+ }));
+ assert.ok(width.page <= width.view, `${viewport.name}:页面被撑到 ${width.page}px(视口 ${width.view})`);
+ assert.ok(!long.some((tag) => width.readout?.includes(tag)), `${viewport.name}:读数里又列了标签名`);
+ assert.deepEqual(unexpected(opened), []);
+ } finally {
+ await opened.close();
+ }
+ }
+ });
});
diff --git a/frontend/src/card-art/framing.ts b/frontend/src/card-art/framing.ts
index 0255be94f..1cb6835bd 100644
--- a/frontend/src/card-art/framing.ts
+++ b/frontend/src/card-art/framing.ts
@@ -8,7 +8,7 @@ import { SKELETON_REVEAL_DELAY } from '@peach/legacy/ui';
import { PANEL_ASPECT, panelFrame, relayoutJavImages, type JavLayout } from '../jav-artwork';
import { faceFrame } from './face-frame';
-import { faceSourceScale, nativeImageFit } from './native-image';
+import { faceSourceScale, markClamp, nativeImageFit } from './native-image';
const devicePixels = () => window.devicePixelRatio || 1;
@@ -228,6 +228,18 @@ export function frameCachedImages(node: Element): void {
export function fitNativeImage(img: HTMLImageElement): void {
const box = img.closest<HTMLElement>('[data-fit-native]');
if (!box || !img.naturalWidth) return;
+ /* 超扁、超高的标识另走一条:短边撑到下限、长边两头裁掉(`[data-native-clamp]` 换成 cover),
+ 不补底——那一圈模糊放大的是一道线,只会糊成一大块。 */
+ const clamp = box.dataset.fitNative === 'mark'
+ ? markClamp(img.naturalWidth, img.naturalHeight, box.clientWidth, box.clientHeight) : null;
+ box.dataset.nativeClamp = String(!!clamp);
+ if (clamp) {
+ box.dataset.nativeSmall = 'false';
+ box.style.setProperty('--markw', clamp.width + 'px');
+ box.style.setProperty('--markh', clamp.height + 'px');
+ box.style.setProperty('--markbg', 'none');
+ return;
+ }
// 版式切换会改变框的大小,每次按屏幕像素密度重新判断。
const { small, width, height } = nativeImageFit(img.naturalWidth, img.naturalHeight, box.clientWidth, box.clientHeight, devicePixels());
box.dataset.nativeSmall = String(small);
diff --git a/frontend/src/card-art/native-image.ts b/frontend/src/card-art/native-image.ts
index 127fb5df1..33f4f04e3 100644
--- a/frontend/src/card-art/native-image.ts
+++ b/frontend/src/card-art/native-image.ts
@@ -25,3 +25,17 @@ export function nativeImageFit(width: number, height: number, frameWidth: number
const scale = valid ? Math.min(1, frameWidth / width, frameHeight / height) : 1;
return { small, width: width * scale, height: height * scale };
}
+
+/** 标识按框 contain 之后,短边至少占框短边的这一份。10:1 的字标在方框里正好落在这条线上。 */
+export const MARK_MIN_SHORT = 0.1;
+
+/** 超扁、超高的标识(实测 1378×42、42×600)按框 contain 只剩一道线:短边撑到 `MARK_MIN_SHORT`,
+ * 长边仍按框,摆的时候 cover,裁掉的是长边两头。比例正常的标识返回 `null`,照常 contain。 */
+export function markClamp(width: number, height: number, frameWidth: number, frameHeight: number) {
+ if (![width, height, frameWidth, frameHeight].every(value => Number.isFinite(value) && value > 0)) return null;
+ const scale = Math.min(frameWidth / width, frameHeight / height);
+ const shownWidth = width * scale, shownHeight = height * scale;
+ const floor = Math.min(frameWidth, frameHeight) * MARK_MIN_SHORT;
+ if (Math.min(shownWidth, shownHeight) >= floor) return null;
+ return shownHeight < shownWidth ? { width: shownWidth, height: floor } : { width: floor, height: shownHeight };
+}
diff --git a/frontend/src/crop-geometry.ts b/frontend/src/crop-geometry.ts
index c4457c1d4..af291bc67 100644
--- a/frontend/src/crop-geometry.ts
+++ b/frontend/src/crop-geometry.ts
@@ -193,3 +193,16 @@ export function toNatural(value: number, rendered: number, natural: number): num
if (!(rendered > 0)) return 0;
return (value * natural) / rendered;
}
+
+/** 框在屏幕上的短边小于这么多 CSS 像素时,改大小那枚角柄挪到框外。角柄 12px,框只比它
+ * 大一点时整块都被角柄盖住,按下去只能改大小、拖不动框。 */
+export const HANDLE_ROOM = 36;
+
+/** 角柄该不该放到框外:`rect` 是 `boxPercent` 的百分比,`shown` 是图当前的显示尺寸。
+ * 显示尺寸还没量到时不挪。 */
+export function handleOutside(
+ rect: { width: number; height: number }, shown: CropSize | null,
+): boolean {
+ if (!shown || !(shown.width > 0) || !(shown.height > 0)) return false;
+ return Math.min((rect.width / 100) * shown.width, (rect.height / 100) * shown.height) < HANDLE_ROOM;
+}
diff --git a/frontend/src/react/avatar-picker/avatar-picker-page.tsx b/frontend/src/react/avatar-picker/avatar-picker-page.tsx
index c49bcb6a7..7a96c2749 100644
--- a/frontend/src/react/avatar-picker/avatar-picker-page.tsx
+++ b/frontend/src/react/avatar-picker/avatar-picker-page.tsx
@@ -154,6 +154,10 @@ function PickerBody({ kind, entityId, name, onPicked, close }: AvatarPickerProps
|| (listing.error ? errorMessage(listing.error) : '');
const busy = submit.isPending || opening.isPending;
const index = cropping ? '' : indexNote(data);
+ // 只有候选那一份没取到时提示旁边给「重试」:提交和取封面失败,重来的是那颗键自己。
+ const listingFailed = !!problem && !!listing.error && problem === errorMessage(listing.error);
+ // 候选取完是空的(或没取到)时不留网格那一带:两条分隔线之间空着一块,读起来像还在等。
+ const showGrid = listing.isPending || choices.length > 0;
return (
<>
{/* 头部:左边一个方图标槽,右边标题加一句说明,右上角是关闭键。 */}
@@ -164,13 +168,18 @@ function PickerBody({ kind, entityId, name, onPicked, close }: AvatarPickerProps
<Heading slot="title" className="text-title-3-semibold text-text-primary">
{cropping ? '框出头像那一块' : '更换头像'}
</Heading>
- {!cropping && choices.length ? <Chip color="soft">{choices.length} 张可选</Chip> : null}
+ {!cropping && choices.length ? <Chip color="soft">{choices.length.toLocaleString()} 张可选</Chip> : null}
</div>
<p className="text-body-2-regular text-text-secondary">
{cropping ? cropNote(cropping.choice) : pickerNote(name, data)}
</p>
{index ? <Note tone="neutral">{index}</Note> : null}
- {problem ? <Note tone="error">{problem}</Note> : null}
+ {problem ? (
+ <Note tone="error" action={listingFailed ? (
+ <Button variant="secondary" size="small" {...busyProps(listing.isFetching)}
+ onClick={() => { if (!listing.isFetching) void listing.refetch() }}>重试</Button>
+ ) : undefined}>{problem}</Note>
+ ) : null}
</div>
<IconButton icon={RiCloseLine} size="small" aria-label="关闭" onClick={close} />
</div>
@@ -182,6 +191,7 @@ function PickerBody({ kind, entityId, name, onPicked, close }: AvatarPickerProps
{/* 候选网格是这一屏唯一会滚的层:头部和底下那排操作再长也不动。上下各留 16px:
只留上边的话,最后一排图贴着底下那条线。外面这一层只为放那条覆盖式滚动条的
轨道,它按 `absolute` 铺,得有一个只裹着滚动块本身的定位祖先。 */}
+ {showGrid ? (
<div className="relative flex min-h-0 flex-1 flex-col">
<div ref={grid} className="flex min-h-0 flex-1 flex-col overflow-y-auto border-t border-separator-border px-5 py-4">
{/* 候选回来之前摆同一种格子的占位,格子外框、比例与标签那一行都和真格子一样,
@@ -212,13 +222,14 @@ function PickerBody({ kind, entityId, name, onPicked, close }: AvatarPickerProps
: null}
{/* 合演封面上最大那张脸多半是领衔的另一位,格子不围着它取景,这里标出人数。 */}
{sharedCast(choice)
- ? <span className="absolute top-1 right-1"><Chip variant="caption" color="gray">{choice.cast} 人</Chip></span>
+ ? <span className="absolute top-1 right-1"><Chip variant="caption" color="gray">{choice.cast.toLocaleString()} 人</Chip></span>
: null}
</button>
))}
</div>
</div>
</div>
+ ) : null}
{/* 番号、手填地址和本机文件跟候选是并列的几条路,不是候选看完之后的补充,所以摆在
固定的那一块里:网格再长也不会把它们推到看不见的地方。 */}
<div className="flex shrink-0 flex-col gap-3 border-t border-separator-border p-5">
@@ -240,7 +251,8 @@ function PickerBody({ kind, entityId, name, onPicked, close }: AvatarPickerProps
{/* 原生文件选择器长相不可控,按钮归 BoardUI,输入框只留着接文件。 */}
<input ref={file} type="file" accept="image/png,image/jpeg" tabIndex={-1} aria-hidden
className="hidden" onChange={pickFile} />
- <div className="flex min-w-0 flex-1 items-center gap-2">
+ {/* 地址一行至少 224px:窄屏下和「从本机选图片」挤不进一行就整行换下去,输入框不被压成一条缝。 */}
+ <div className="flex min-w-0 flex-1 basis-56 items-center gap-2">
<div className="min-w-0 flex-1">
<Input type="url" aria-label="图片地址" placeholder="https://…" value={url} onChange={setUrl} />
</div>
@@ -263,25 +275,28 @@ function PickerBody({ kind, entityId, name, onPicked, close }: AvatarPickerProps
function ChoiceImage({ src, choice }: { src: string; choice: AvatarChoice }) {
const image = useRef<HTMLImageElement>(null);
const [revealed, setRevealed] = useState(false);
+ const [lost, setLost] = useState(false);
/* 缓存里的图可能在挂上 `onLoad` 之前就已经解码完,那一次 `load` 不会再来。 */
useEffect(() => {
if (image.current?.complete && image.current.naturalWidth) setRevealed(true);
}, []);
const size = { width: choice.width, height: choice.height };
const place = framesItself(choice) ? windowStyle(choiceFrame(choice, size, TILE_ASPECT), size) : null;
- const shown = revealed ? true : undefined;
+ const shown = revealed || lost ? true : undefined;
return (
- <span className="relative block w-full aspect-avatar-choice overflow-hidden">
- {/* 取不到图也要揭开:骨架停在那儿就读成还在等。 */}
- <img ref={image} loading="lazy" alt="" src={src} data-revealed={shown}
- onLoad={() => setRevealed(true)} onError={() => setRevealed(true)}
+ <span data-choice-lost={lost || undefined}
+ className="relative block w-full aspect-avatar-choice overflow-hidden">
+ {/* 取不到图时揭开骨架、撤掉图:骨架停在那儿读成还在等,留着图就是一枚破图标。
+ 格子剩一块空底,名字和来源照旧在下面那行与 title 里。 */}
+ {lost ? null : <img ref={image} loading="lazy" alt="" src={src} data-revealed={shown}
+ onLoad={() => setRevealed(true)} onError={() => setLost(true)}
className={place
? 'reveal-content absolute max-w-none top-(--tile-top) left-(--tile-left) h-(--tile-height) w-(--tile-width)'
: 'reveal-content absolute inset-0 size-full object-cover'}
style={place ? {
'--tile-top': place.top, '--tile-left': place.left,
'--tile-height': place.height, '--tile-width': place.width,
- } as CSSProperties : undefined} />
+ } as CSSProperties : undefined} />}
<span aria-hidden data-revealed={shown}
className="reveal-skeleton pointer-events-none absolute inset-0 skeleton-sheen" />
</span>
diff --git a/frontend/src/react/avatar-picker/avatar-picker.ts b/frontend/src/react/avatar-picker/avatar-picker.ts
index 093e767de..4a8ab8c6c 100644
--- a/frontend/src/react/avatar-picker/avatar-picker.ts
+++ b/frontend/src/react/avatar-picker/avatar-picker.ts
@@ -126,13 +126,21 @@ export async function sendAvatarPick(
await sendBytes(`${AVATAR_PICK_URL}${query(kind, id)}&name=${encodeURIComponent(file.name)}${box}`, file);
}
+/** 说明里点名的别名个数。再多就是一大段字,把候选网格挤得只剩一排。 */
+const NOTE_NAMES = 2;
+
/** 说明只留一句:这一屏已经用图说清了在选什么,多一行字就是多一行要读的东西。
- * 按哪个名字找到的要说——找错人是这里唯一会出的大错,而名字是唯一的线索。 */
+ * 按哪个名字找到的要说——找错人是这里唯一会出的大错,而名字是唯一的线索。名字多时点名
+ * 前两个,余下的只报个数,每一格按谁找到的在格子的 title 里。 */
export function pickerNote(name: string, data: AvatarChoices | undefined): string {
// 候选在路上时网格里是 Skeleton,这里不再另写一句「正在读取」。
if (!data) return name;
const elsewhere = data.matched_names.filter((one) => one !== name);
- if (elsewhere.length) return `${name}:图库里按「${elsewhere.join('」「')}」找到的。`;
+ if (elsewhere.length) {
+ const named = `「${elsewhere.slice(0, NOTE_NAMES).join('」「')}」`;
+ const more = elsewhere.length > NOTE_NAMES ? `等 ${elsewhere.length.toLocaleString()} 个名字` : '';
+ return `${name}:图库里按${named}${more}找到的。`;
+ }
return data.choices.length
? `${name}:换上的那张留在本机,随时能换回来。`
: `${name}:图库里没有这个名字,用下面两种方式换。`;
@@ -156,7 +164,7 @@ export const sharedCast = (choice: AvatarChoice): boolean => choice.cast > 1;
export const cropNote = (choice: AvatarChoice): string =>
sharedCast(choice)
- ? `${choice.label}:${choice.cast} 人合演,先找到她自己的脸,再拖动方框选一块。`
+ ? `${choice.label}:${choice.cast.toLocaleString()} 人合演,先找到她自己的脸,再拖动方框选一块。`
: `${choice.label}:拖动方框选一块,滚轮或角上那枚方块改大小。`;
const SOURCE_LABELS: Record<string, string> = {
@@ -177,5 +185,5 @@ export function baseLabel(ref: string): string {
export const choiceDetail = (choice: AvatarChoice): string =>
`${SOURCE_LABELS[choice.source] || choice.source} · ${choice.label}`
+ (choice.width ? ` · ${choice.width}×${choice.height}` : '')
- + (sharedCast(choice) ? ` · ${choice.cast} 人合演` : '')
+ + (sharedCast(choice) ? ` · ${choice.cast.toLocaleString()} 人合演` : '')
+ (choice.found_by ? ` · 按「${choice.found_by}」找到` : '');
diff --git a/frontend/src/react/crop/crop-frame.tsx b/frontend/src/react/crop/crop-frame.tsx
index f8289b9bd..970e57ef0 100644
--- a/frontend/src/react/crop/crop-frame.tsx
+++ b/frontend/src/react/crop/crop-frame.tsx
@@ -13,7 +13,7 @@ import type {
} from 'react';
import {
- boxPercent, clampBox, isUsableSize, moveBox, resizeFromCorner, scaleBox, toNatural,
+ boxPercent, clampBox, handleOutside, isUsableSize, moveBox, resizeFromCorner, scaleBox, toNatural,
type CropBox, type CropSize,
} from '../../crop-geometry';
@@ -39,8 +39,17 @@ export function CropFrame({ src, aspect, box, size, onBox, onSize, label }: Crop
const image = useRef<HTMLImageElement>(null);
const drag = useRef<{ mode: 'move' | 'resize'; x: number; y: number; box: CropBox } | null>(null);
const [failed, setFailed] = useState(false);
+ /* 图当前的显示尺寸,只用来判断框在屏幕上够不够大、角柄放框里还是框外。 */
+ const [shown, setShown] = useState<CropSize | null>(null);
useEffect(() => { setFailed(false) }, [src]);
+ useEffect(() => {
+ const node = image.current;
+ if (!node) return undefined;
+ const observer = new ResizeObserver(() => setShown({ width: node.clientWidth, height: node.clientHeight }));
+ observer.observe(node);
+ return () => observer.disconnect();
+ }, []);
/** 显示像素的位移 → 源图像素。图片按 `max-w-full` 缩放,两个轴的比例一样。 */
const scale = useCallback((dx: number, dy: number) => {
@@ -101,6 +110,7 @@ export function CropFrame({ src, aspect, box, size, onBox, onSize, label }: Crop
}
const rect = box && size ? boxPercent(clampBox(box, size, aspect), size) : null;
+ const outside = rect ? handleOutside(rect, shown) : false;
/* 位置只经自定义属性进 CSS:六个百分数挂在容器上,压暗块与框本身各自用类名取用,
样式仍然全在类里(`docs/FRONTEND.md`)。 */
const frame = rect ? {
@@ -127,7 +137,8 @@ export function CropFrame({ src, aspect, box, size, onBox, onSize, label }: Crop
<div aria-hidden className="pointer-events-none absolute inset-x-0 bottom-0 top-(--crop-b) bg-scrim" />
<div aria-hidden className="pointer-events-none absolute left-0 top-(--crop-t) h-(--crop-h) w-(--crop-l) bg-scrim" />
<div aria-hidden className="pointer-events-none absolute right-0 left-(--crop-r) top-(--crop-t) h-(--crop-h) bg-scrim" />
- {/* 框本身。整块可拖,右下角那枚小方块改大小;方向键与加减号做同样两件事。 */}
+ {/* 框本身。整块可拖,右下角那枚小方块改大小;方向键与加减号做同样两件事。
+ 框在屏幕上很小(极扁、极长的图)时角柄整枚挪到框外右下,框里留给拖动。 */}
<div role="group" tabIndex={0} aria-label={label} data-crop-box
onPointerDown={start('move')} onPointerMove={move}
onPointerUp={end} onPointerCancel={end} onKeyDown={keys}
@@ -136,9 +147,9 @@ export function CropFrame({ src, aspect, box, size, onBox, onSize, label }: Crop
onBox(scaleBox(box, event.deltaY > 0 ? WHEEL_STEP : 1 / WHEEL_STEP, size, aspect));
}}
className="absolute left-(--crop-l) top-(--crop-t) h-(--crop-h) w-(--crop-w) cursor-move touch-none outline-none ring-2 ring-border-focus-ring ring-inset focus-visible:ring-4">
- <span data-crop-handle onPointerDown={start('resize')} onPointerMove={move}
- onPointerUp={end} onPointerCancel={end}
- className="absolute -right-1.5 -bottom-1.5 size-3 cursor-nwse-resize touch-none rounded-xs border border-separator-border bg-background-full" />
+ <span data-crop-handle data-outside={outside || undefined} onPointerDown={start('resize')}
+ onPointerMove={move} onPointerUp={end} onPointerCancel={end}
+ className="absolute -right-1.5 -bottom-1.5 data-outside:-right-3.5 data-outside:-bottom-3.5 size-3 cursor-nwse-resize touch-none rounded-xs border border-separator-border bg-background-full" />
</div>
</>
)}
diff --git a/frontend/src/react/entity-body/entity-body-page.tsx b/frontend/src/react/entity-body/entity-body-page.tsx
index 5437df2a4..d2c65531d 100644
--- a/frontend/src/react/entity-body/entity-body-page.tsx
+++ b/frontend/src/react/entity-body/entity-body-page.tsx
@@ -7,6 +7,7 @@ import { Fragment, useCallback, useMemo, useState } from 'react';
import { CatalogGridPage, LoadMore } from '../catalog-grid/catalog-grid-page';
import { useSkeletonReveal } from '../components/grid-reveal';
+import { PAGE_SIZE } from '../index/index-data';
import { PeopleGrid } from '../index/index-people';
import { openPhotoLightbox } from '../photo-lightbox/photo-lightbox-dialog';
import type { LightboxSlide } from '../photo-lightbox/photo-lightbox';
@@ -23,12 +24,28 @@ export function EntityBodyPage(props: EntityBodyProps) {
return null;
}
-/** 名册一格点开进这个人(或这个厂牌)的资料页,取图同索引页那条回落链。 */
+/** 名册一页摆几格,同索引页名册一页的格数。 */
+const ROSTER_PAGE = PAGE_SIZE.people;
+
+/** 名册一格点开进这个人(或这个厂牌)的资料页,取图同索引页那条回落链。
+ *
+ * 名单随资料一次下来,大事务所有上千人;一次全画出来就是上千个头像格和上千次取图。先摆一页,
+ * 余下的走作品区同一枚「载入更多」,滚到附近自己接下一页。 */
function Roster({ roster, props }: { roster: EntityRoster; props: EntityBodyProps }) {
const { helpers, actions } = props;
const cell = useMemo(() => ({ personAvatar: helpers.personAvatar, openEntity: actions.openEntity }),
[helpers, actions]);
- return <PeopleGrid kind={roster.kind} items={roster.people} layout={roster.layout} props={cell} />;
+ const [shown, setShown] = useState<number>(ROSTER_PAGE);
+ const people = useMemo(() => roster.people.slice(0, shown), [roster.people, shown]);
+ const loadMore = useCallback(async () => { setShown((count) => count + ROSTER_PAGE) }, []);
+ return (
+ <>
+ <PeopleGrid kind={roster.kind} items={people} layout={roster.layout} props={cell} />
+ {shown < roster.people.length
+ ? <LoadMore key={shown} entity load={loadMore} enabled={() => true} />
+ : null}
+ </>
+ );
}
/** 作品区:外面这一层只管「壳还在取」时的骨架,列表到了就是卡片网格的 entity 模式,
@@ -109,7 +126,7 @@ function PhotoSection({ photos, props }: { photos: EntityPhotos; props: EntityBo
{groups.map(({ set, from }) => (
<Fragment key={set.code}>
<GroupHead label={set.code} title={set.name}
- meta={[`${set.site_label || '官方'} 样张`, set.release_date, `${set.n} 张`].filter(Boolean).join(' · ')} />
+ meta={[`${set.site_label || '官方'} 样张`, set.release_date, `${set.n.toLocaleString()} 张`].filter(Boolean).join(' · ')} />
<div {...wallAttrs}>{wall.slice(from, from + set.n).map((item, i) => cell(item, from + i))}</div>
</Fragment>
))}
diff --git a/frontend/src/react/entity-filter/entity-filter.css b/frontend/src/react/entity-filter/entity-filter.css
index bfecc62d1..9343d3a14 100644
--- a/frontend/src/react/entity-filter/entity-filter.css
+++ b/frontend/src/react/entity-filter/entity-filter.css
@@ -194,6 +194,13 @@
letter-spacing: normal;
white-space: nowrap;
}
+/* 资料页这一行的读数可以让位:右边那排排序键放不下时它截成省略号,不把页面撑宽。 */
+.peach-react [data-entity-filter-glass] [data-entity-readout] {
+ flex: 0 1 auto;
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
.peach-react [data-entity-sorts] {
display: flex;
@@ -331,6 +338,8 @@
max-width: none;
overflow: visible;
}
+ /* 整条在横滚,读数不用让位:让位的话它会先被挤成 0 宽。 */
+ .peach-react [data-entity-filter-glass] [data-entity-readout] { flex: none; }
}
/* 窄屏往下滚时浮层让出顶栏下沿,往回滚再落下来;`--filter-free-top` 与标记由壳的
diff --git a/frontend/src/react/entity-hero/entity-hero-page.tsx b/frontend/src/react/entity-hero/entity-hero-page.tsx
index 609e6db32..bc71fae63 100644
--- a/frontend/src/react/entity-hero/entity-hero-page.tsx
+++ b/frontend/src/react/entity-hero/entity-hero-page.tsx
@@ -23,7 +23,7 @@ import { Glyph } from './glyph';
import { FeedSwitch, MorePop } from './hero-pop';
import { NamePicker } from './name-picker';
import {
- agencyOf, companyFactRows, entityFeedTip, entryMarks, factRows, heroLinks, isCompany, isPeople, nameChoices, nameLine, shownTags,
+ COMPANY_ALIASES_SHOWN, agencyOf, companyFactRows, entityFeedTip, entryMarks, factRows, heroLinks, isCompany, isPeople, nameChoices, nameLine, shownTags,
type EntityHeroActions, type EntityHeroData, type EntityHeroHelpers, type EntityHeroProps,
type HeroCostar, type HeroFollow, type LinkMark, type LinkView,
} from './entity-hero';
@@ -72,11 +72,17 @@ export function EntityHeroPage({ kind, name, entity, feedNew, feedHost, actions,
<AliasLine kind={kind} entity={entity} actions={actions} />
{entity.related_identities?.length ? (
<div className="flex min-w-0 flex-wrap gap-2 text-caption-1-regular text-text-secondary">
- {entity.related_identities.map((identity) => (
- <button type="button" key={identity.id} className="text-text-primary underline" onClick={() => actions.openEntity(identity.kind, identity.canonical_name)}>
- {identity.relation === 'same_person' ? '同一人' : '关联账号'}:{identity.canonical_name}
- </button>
- ))}
+ {/* 账号名常是一长串无空格的英文,窄屏下得能在任意处折行。 */}
+ {entity.related_identities.map((identity) => {
+ const text = `${identity.relation === 'same_person' ? '同一人' : '关联账号'}:${identity.canonical_name}`;
+ return (
+ <button type="button" key={identity.id} title={text}
+ className="min-w-0 max-w-full text-text-primary underline wrap-anywhere"
+ onClick={() => actions.openEntity(identity.kind, identity.canonical_name)}>
+ {text}
+ </button>
+ );
+ })}
</div>
) : null}
{links.length ? (
@@ -159,8 +165,8 @@ function AliasLine({ kind, entity, actions }: { kind: string; entity: EntityHero
<Glyph name="id-card" />
<span data-alias-names="" title="别名">{line.names.map((one, at) => <span key={at}>{one}</span>)}</span>
{line.rest > 0 ? (
- <MorePop id="entityAliasPop" hook="alias" rest={line.rest} label={`另外 ${line.rest} 个别名`}
- heading={`${line.total} 个别名`}>
+ <MorePop id="entityAliasPop" hook="alias" rest={line.rest} label={`另外 ${line.rest.toLocaleString()} 个别名`}
+ heading={`${line.total.toLocaleString()} 个别名`}>
<dl>
{(entity.name_groups?.groups || []).map((group, at) => (
<NameGroup key={at} label={group.label} names={group.names} />
@@ -186,7 +192,25 @@ function AliasLine({ kind, entity, actions }: { kind: string; entity: EntityHero
{agencyNode ? <span data-meta-item="" title="事务所"><Glyph name="briefcase" /><span>{agencyNode}</span></span> : null}
{maker ? <span data-meta-item="" title="片商"><Glyph name="clapperboard" /><a href={entityPath('studio', maker.name)} data-studio-link={maker.name}
onClick={go('studio', maker.name)}>{maker.name}</a></span> : null}
- {aliases.length ? <div data-meta-item="names" data-company-names={kind === 'studio' || kind === 'agency' ? '' : undefined}><Glyph name="id-card" /><span data-alias-names="" title="别名">{aliases.map((name, at) => <span key={at}>{name}</span>)}</span></div> : null}
+ {aliases.length ? <CompanyAliases aliases={aliases} wide={kind === 'studio' || kind === 'agency'} /> : null}
+ </div>
+ );
+}
+
+/** 公司别名:先列几个,余下的收进「+N」,浮层里一个名字一行。片商改过几轮名、挂过一串
+ * label 时别名能有三十多个,全摊开会占掉资料卡十几行。 */
+function CompanyAliases({ aliases, wide }: { aliases: string[]; wide: boolean }) {
+ const { shown, rest } = shownTags(aliases, COMPANY_ALIASES_SHOWN);
+ return (
+ <div data-meta-item="names" data-company-names={wide ? '' : undefined}>
+ <Glyph name="id-card" />
+ <span data-alias-names="" title="别名">{shown.map((name, at) => <span key={at}>{name}</span>)}</span>
+ {rest ? (
+ <MorePop id="entityAliasPop" hook="alias" rest={rest} label={`另外 ${rest.toLocaleString()} 个别名`}
+ heading={`${aliases.length.toLocaleString()} 个别名`}>
+ <dl><NameGroup names={aliases.map((name) => ({ name }))} /></dl>
+ </MorePop>
+ ) : null}
</div>
);
}
@@ -246,12 +270,15 @@ function IdentityMeta({ entity }: { entity: EntityHeroData }) {
);
}
+/** 浮层里的一组名字:一个名字一行,读音排在它下面一行。串成一段的话,名字和读音分不清各属于谁。 */
function NameGroup({ label, names }: { label?: string; names: { name: string; reading?: string }[] }) {
return (
<>
{label ? <dt>{label}</dt> : null}
<dd data-wide={label ? undefined : ''}>
- {names.map((entry, at) => <span key={at}>{entry.name}{entry.reading ? <small>{entry.reading}</small> : null}</span>)}
+ {names.map((entry, at) => (
+ <span key={at} data-pop-name="">{entry.name}{entry.reading ? <small>{entry.reading}</small> : null}</span>
+ ))}
</dd>
</>
);
@@ -272,10 +299,11 @@ function FactTags({ tags }: { tags: string[] }) {
const { shown, rest } = shownTags(tags);
return (
<>
- {shown.map((tag) => <span key={tag} data-fact-tag="">{tag}</span>)}
+ {shown.map((tag) => <span key={tag} data-fact-tag="" title={tag}>{tag}</span>)}
{rest ? (
- <MorePop id="entityTagPop" hook="fact" rest={rest} label={`另外 ${rest} 个标签`} heading={`${tags.length} 个标签`}>
- <div data-fact-tags="">{tags.map((tag) => <span key={tag} data-fact-tag="">{tag}</span>)}</div>
+ <MorePop id="entityTagPop" hook="fact" rest={rest} label={`另外 ${rest.toLocaleString()} 个标签`}
+ heading={`${tags.length.toLocaleString()} 个标签`}>
+ <div data-fact-tags="">{tags.map((tag) => <span key={tag} data-fact-tag="" title={tag}>{tag}</span>)}</div>
</MorePop>
) : null}
</>
@@ -310,8 +338,9 @@ function HeroLinkView({ link }: { link: LinkView }) {
);
case 'private':
return (
- <span data-link="private" title={link.label}>
- <LinkIcon mark={{ globe: true }} /><span data-link-label="">来源 · {link.label}</span>
+ <span data-link="private" title={link.sources ? link.sources.join('\n') : link.label}>
+ <LinkIcon mark={{ globe: true }} />
+ <span data-link-label="">{link.sources ? link.label : `来源 · ${link.label}`}</span>
</span>
);
default:
diff --git a/frontend/src/react/entity-hero/entity-hero.css b/frontend/src/react/entity-hero/entity-hero.css
index 5a7ee664a..de98f2fbc 100644
--- a/frontend/src/react/entity-hero/entity-hero.css
+++ b/frontend/src/react/entity-hero/entity-hero.css
@@ -58,6 +58,8 @@
* 挂加号的宿主叠成和圆框一样大、一样位置的一块,高度与居中取圆框同一个 `--portrait-size`,加号的
* `right/bottom` 就量在圆框上;它盖在脸上,不接指针。不用 `transform` 居中:它会给弹层的
* `fixed` 遮罩另起包含块。 */
+/* 头像跟身份那一列竖向居中,但这一格最高只比圆框多 64px:身份列被几十条外链撑高时,
+ * 拉伸到上限就停、贴着行顶,圆框离卡顶至多 32px,不会被居中挤出首屏。 */
.peach-react [data-entity-portrait-wrap] {
position: relative;
display: flex;
@@ -65,6 +67,7 @@
align-items: center;
width: max-content;
max-width: 100%;
+ max-height: calc(var(--portrait-size) + 64px);
}
.peach-react [data-entity-portrait-wrap] > [data-avatar-picker] {
position: absolute;
@@ -116,6 +119,10 @@
margin: auto;
object-fit: contain;
}
+/* 超扁、超高的标识:短边已撑到下限(`markClamp`),cover 裁掉长边两头。 */
+.peach-react [data-entity-portrait][data-native-clamp="true"] img { object-fit: cover; }
+/* 没有人脸取景的竖长头像偏上取:脸多在画面上半截。有取景时 `facePos` 的内联样式盖过这一条。 */
+.peach-react [data-entity-portrait="round"] img { object-position: 50% 25%; }
/* ── 身份 ── */
.peach-react [data-entity-identity] { min-width: 0; max-width: 100%; }
@@ -192,8 +199,7 @@
stroke-linecap: round;
stroke-linejoin: round;
}
-.peach-react [data-alias-names] > span + span::before,
-.peach-react [data-hero-pop] dd > span + span::before {
+.peach-react [data-alias-names] > span + span::before {
margin: 0 6px;
color: var(--muted);
content: "·";
@@ -261,9 +267,17 @@
margin: 0;
}
.peach-react [data-hero-pop] dt { color: var(--muted); white-space: nowrap; }
-.peach-react [data-hero-pop] dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
+.peach-react [data-hero-pop] dd {
+ display: grid;
+ gap: 4px;
+ min-width: 0;
+ margin: 0;
+ overflow-wrap: anywhere;
+}
.peach-react [data-hero-pop] dd[data-wide] { grid-column: 1 / -1; }
-.peach-react [data-hero-pop] small { margin-left: 4px; color: var(--muted); font-size: inherit; }
+/* 一个名字一行,读音小一档排在名字下面。 */
+.peach-react [data-pop-name] { display: grid; }
+.peach-react [data-hero-pop] small { color: var(--muted); font-size: var(--fs-xs); line-height: 1.4; }
/* ── 资料表 ── */
.peach-react [data-entity-facts] {
@@ -302,7 +316,12 @@
.peach-react [data-entity-facts] dd[data-fact="clip"] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 站上的标签只是读数,不是这一页的筛选(那排在下面的筛选条里),所以是标签的脸、不接点击。 */
.peach-react :is(dd[data-fact="tags"], [data-fact-tags]) { display: flex; flex-wrap: wrap; gap: 6px; }
+/* 一枚标签至多一行宽,超长的截成省略号,全文在 title 里。 */
.peach-react [data-fact-tag] {
+ box-sizing: border-box;
+ max-width: 100%;
+ overflow: hidden;
+ text-overflow: ellipsis;
padding: 0 var(--tag-pad-x);
border: 1px solid var(--line);
border-radius: var(--tag-radius);
diff --git a/frontend/src/react/entity-hero/entity-hero.ts b/frontend/src/react/entity-hero/entity-hero.ts
index 7f79b7eb1..dbeeb7694 100644
--- a/frontend/src/react/entity-hero/entity-hero.ts
+++ b/frontend/src/react/entity-hero/entity-hero.ts
@@ -185,7 +185,7 @@ export type LinkMark = { brand: string } | { site: string } | { globe: true };
export type LinkView =
| { type: 'icon'; url: string; title: string; mark: LinkMark }
| { type: 'gone'; title: string }
- | { type: 'private'; label: string }
+ | { type: 'private'; label: string; sources?: string[] }
| { type: 'url'; url: string; title: string; text: string; mark: LinkMark };
const siteMark = (link: HeroLink): LinkMark => ({ site: linkMarkUrl(link) });
@@ -215,7 +215,18 @@ export function heroLinks(entity: EntityHeroData, kind: string): LinkView[] {
}
return { type: 'url', url, title: x.label || '', text: officialLinkText(x, kind, names), mark: siteMark(x) };
});
- return [...pills, ...links];
+ return [...pills, ...foldPrivate(links)];
+}
+
+/** 不公开的来源点不开,只是「记过这么一处」:两处以上收成排在末尾的一枚「N 个不公开来源」,
+ * 各处的名字进 title。夹在图标中间一处占一整行,会把一排图标外链切成好几段。 */
+function foldPrivate(links: LinkView[]): LinkView[] {
+ const hidden = links.filter((link): link is Extract<LinkView, { type: 'private' }> => link.type === 'private');
+ if (hidden.length < 2) return links;
+ return [
+ ...links.filter((link) => link.type !== 'private'),
+ { type: 'private', label: `${hidden.length.toLocaleString()} 个不公开来源`, sources: hidden.map((link) => link.label) },
+ ];
}
/** 看片的那一行:站点自己的横向标识。 */
@@ -248,8 +259,10 @@ export function companyFactRows(profile: EntityHeroData['company_profile']): Fac
export function factRows(p: HeroProfile | null | undefined): FactRow[] {
if (!p) return [];
const rows: FactRow[] = [];
+ // 年龄由服务端按生日算、与生日成对下发;只拿到生日时那一行只写生日。
if (p.birth_date) rows.push({ glyph: 'cake', label: '生日', parts: [
- { text: p.birth_date, tone: 'num' }, { text: `· ${p.age} 岁`, tone: 'sub' }] });
+ { text: p.birth_date, tone: 'num' },
+ ...(Number.isFinite(p.age) ? [{ text: `· ${p.age} 岁`, tone: 'sub' as const }] : [])] });
const size = ([['T', p.height], ['B', p.bust], ['W', p.waist], ['H', p.hip]] as const)
.filter(([, value]) => value).map(([letter, value]) => `${letter}${value}`).join(' · ');
const cup = p.cup ? `${size ? '· ' : ''}${p.cup} 罩杯` : '';
@@ -265,9 +278,13 @@ export function factRows(p: HeroProfile | null | undefined): FactRow[] {
return rows;
}
-/** 标签那一格只列前几个,余下的收进「+N」;只多出一个时直接列出来,「+1」和那一个标签一样宽。 */
-export function shownTags(tags: string[]): { shown: string[]; rest: number } {
- const cut = tags.length > FACT_TAGS_SHOWN + 1 ? FACT_TAGS_SHOWN : tags.length;
+/** 公司页名字下面那一行先列几个别名,余下的收进「+N」。 */
+export const COMPANY_ALIASES_SHOWN = 3;
+
+/** 标签那一格只列前几个,余下的收进「+N」;只多出一个时直接列出来,「+1」和那一个标签一样宽。
+ * 公司别名按 `COMPANY_ALIASES_SHOWN` 用同一条规则。 */
+export function shownTags(tags: string[], limit = FACT_TAGS_SHOWN): { shown: string[]; rest: number } {
+ const cut = tags.length > limit + 1 ? limit : tags.length;
return { shown: tags.slice(0, cut), rest: tags.length - cut };
}
diff --git a/frontend/src/react/entity-hero/hero-pop.tsx b/frontend/src/react/entity-hero/hero-pop.tsx
index 8a45d36f7..69a7c0476 100644
--- a/frontend/src/react/entity-hero/hero-pop.tsx
+++ b/frontend/src/react/entity-hero/hero-pop.tsx
@@ -7,12 +7,19 @@ import { useEffect, useRef, useState, type ReactNode, type RefObject } from 'rea
import { Glyph } from './glyph';
-/** 把 `pop` 摆到 `anchor` 下方,放不下翻上方,左右夹在视口内 8px。 */
+/** 把 `pop` 摆到 `anchor` 下方,放不下翻上方,左右夹在视口内 8px。两边都放不下时摆到空间大的
+ * 那一边,高度压到那一边真正剩下的空间、浮层里自己滚:浮层从不横跨锚点,盖住「+N」那一下
+ * 指针就落在浮层上,按钮再也点不到。 */
export function placePop(anchor: Element, pop: HTMLElement): void {
+ pop.style.removeProperty('max-height');
const at = anchor.getBoundingClientRect(), box = pop.getBoundingClientRect();
pop.style.left = `${Math.max(8, Math.min(innerWidth - box.width - 8, at.left))}px`;
const below = at.bottom + 8;
- pop.style.top = `${below + box.height <= innerHeight - 8 ? below : Math.max(8, at.top - box.height - 8)}px`;
+ const roomBelow = innerHeight - 8 - below, roomAbove = at.top - 16;
+ const downward = box.height <= roomBelow || (box.height > roomAbove && roomBelow >= roomAbove);
+ const room = Math.max(0, downward ? roomBelow : roomAbove);
+ if (box.height > room) pop.style.maxHeight = `${room}px`;
+ pop.style.top = `${downward ? below : at.top - 8 - Math.min(box.height, room)}px`;
}
const isOpen = (pop: HTMLElement | null) => !!pop?.isConnected && pop.matches(':popover-open');
diff --git a/frontend/src/react/entity-page/entity-page-view.tsx b/frontend/src/react/entity-page/entity-page-view.tsx
index 14e4e33f9..96fe1e922 100644
--- a/frontend/src/react/entity-page/entity-page-view.tsx
+++ b/frontend/src/react/entity-page/entity-page-view.tsx
@@ -11,9 +11,13 @@ import { api } from '@peach/legacy/core';
import { tagLabel } from '@peach/legacy/tags';
import { confirmModal } from '@peach/legacy/ui';
+import { Button } from '@/components/base/buttons/button';
+
import { errorMessage } from '../../api';
import type { MediaCardLayout } from '../catalog-grid/types';
+import { EmptyState } from '../components/empty-state';
import { RetryNote } from '../components/grid-reveal';
+import { spriteGlyph } from '../components/sprite-glyph';
import type { EntityBodyActions, EntityPhotos, EntityRoster } from '../entity-body/entity-body';
import { EntityBodyPage } from '../entity-body/entity-body-page';
import type {
@@ -66,7 +70,7 @@ const newSeed = () => String(((Date.now() ^ (Math.random() * 1e9 | 0)) >>> 0) %
function photoReadout(page: PhotoPage, codeSets: number) {
return `照片 · ${[
page.total || !codeSets ? `${(page.total || 0).toLocaleString()} 张` : '',
- codeSets ? `样张 ${(page.sample_total || 0).toLocaleString()} 张 · ${codeSets} 部作品` : '',
+ codeSets ? `样张 ${(page.sample_total || 0).toLocaleString()} 张 · ${codeSets.toLocaleString()} 部作品` : '',
].filter(Boolean).join(' · ')}`;
}
@@ -315,13 +319,22 @@ function EntityLoaded(props: EntityPageProps & { entity: EntityPageData }) {
back: inSet, shuffle: !!wallPage.total, layout: props.photoLayout, layouts: props.photoLayouts,
setId: inSet ? Number(wallPage.id) : 0,
} : null;
+ /* 名下一部作品都没有(或筛完一部不剩)时正文是空态,下排那排排序键与换一批没有东西可排,不出。 */
+ const combo = helpers.comboItems(filters);
+ const filtered = combo.length > 0 || !!filters.state;
+ const worksEmpty = view === 'videos' && !!items.data && !(items.data.items || []).length;
+ const showAll = () => actions.route(
+ // 键名与壳的 `clearAll` 同一组,外加观看状态。
+ { ...filters, state: '', tag: '', creator: '', studio: '', owner: '' }, EMPTY_MEDIA);
let readout = '';
let busy = false;
if (view === 'people') readout = `${kind === 'studio' ? '厂牌' : '艺人'} · ${roster.length.toLocaleString()}`;
else if (view === 'videos') {
busy = !items.data;
- const labels = tagList(filters.tag).map((tag) => tagLabel(tag));
- readout = `视频 · ${(items.data?.work_total ?? items.data?.total ?? 0).toLocaleString()}${labels.length ? ` · ${labels.join(' · ')}` : ''}`;
+ /* 选了哪几枚标签由上面那条交集条一枚一枚列着,读数只报个数:标签名再列一遍,几枚长标签
+ 就能把这一行撑出页面。 */
+ const picked = tagList(filters.tag).length;
+ readout = `视频 · ${(items.data?.work_total ?? items.data?.total ?? 0).toLocaleString()}${picked ? ` · 已选 ${picked.toLocaleString()} 个标签` : ''}`;
} else if (wallPage && !wallPage.error) {
readout = inSet ? `${wallPage.title} · ${(wallPage.total || 0).toLocaleString()} 张`
: photoReadout(wallPage, codeSetsOf(wallPage).length);
@@ -346,12 +359,13 @@ function EntityLoaded(props: EntityPageProps & { entity: EntityPageData }) {
feedHost={entityId ? hosts.feed : null} jav={javPage} actions={heroActions} helpers={heroHelpers} />
{createPortal(
<EntityFilterPage kind={kind} name={name} view={view} views={views} state={filters.state || ''}
- states={props.states} tags={tags} combo={helpers.comboItems(filters)} readout={readout} busy={busy}
- video={video} photo={photo} actions={filterActions} helpers={filterHelpers} />,
+ states={props.states} tags={tags} combo={combo} readout={readout} busy={busy}
+ video={worksEmpty ? null : video} photo={photo} actions={filterActions} helpers={filterHelpers} />,
hosts.filter)}
{createPortal(
view === 'videos' && items.isError
? <RetryNote message={errorMessage(items.error)} onRetry={() => { void items.refetch() }} />
+ : worksEmpty ? <WorksEmpty filtered={filtered} onShowAll={showAll} />
: (
<EntityBodyPage kind={kind} name={name} view={view} roster={rosterProps} items={items.data ?? null}
revision={itemsRevision} fetchPage={fetchPage} photos={photos} photoSize={props.photoSize}
@@ -364,3 +378,17 @@ function EntityLoaded(props: EntityPageProps & { entity: EntityPageData }) {
</>
);
}
+
+/** 作品区一部也没有。筛完一部不剩时给一条回到全部视频的路:观看状态与交集条上的筛选一起撤掉。 */
+function WorksEmpty({ filtered, onShowAll }: { filtered: boolean; onShowAll(): void }) {
+ return filtered ? (
+ <EmptyState icon={spriteGlyph('search')} title="没有符合条件的视频"
+ actions={<Button variant="secondary" onClick={onShowAll}>查看全部视频</Button>}>
+ 清除筛选后查看名下全部视频。
+ </EmptyState>
+ ) : (
+ <EmptyState icon={spriteGlyph('film')} title="还没有视频">
+ 署上这个名字的视频入库后会显示在这里。
+ </EmptyState>
+ );
+}
diff --git a/frontend/src/react/index/index-data.ts b/frontend/src/react/index/index-data.ts
index 84ea90946..d41963ba0 100644
--- a/frontend/src/react/index/index-data.ts
+++ b/frontend/src/react/index/index-data.ts
@@ -219,7 +219,7 @@ export const flatItems = <T>(data: InfiniteData<IndexPage<T>> | undefined): T[]
data ? data.pages.flatMap((page) => page.items) : [];
/** 读数:取到几条,后面还有就带一个加号。 */
-export const countText = (count: number, more: boolean) => `${count}${more ? '+' : ''} 项`;
+export const countText = (count: number, more: boolean) => `${count.toLocaleString()}${more ? '+' : ''} 项`;
/** 一枚标签的类型色键(`../styles.css` 的 `[data-tag-cat]`)。在线那一套取上游 tag_type,
* 加 `r34-` 前缀与本地同名的类分开:本地的 `artist` 是橙色,在线的是红色。 */
@@ -227,9 +227,9 @@ export const tagColorKey = (online: boolean, cat: string | undefined) =>
online ? `r34-${cat || 'unknown'}` : cat || 'general';
/** 格子底下那个读数。事务所数的是人:它名下的视频是成员拍的,只报视频数会让它唯一独有的
- * 读数消失;数字带单位,否则读不出是人还是片。 */
+ * 读数消失。数字一律带单位,同一排格子才读得出数的是人还是片,单独一个「0」也不像漏了字。 */
export const personReadout = (kind: IndexKind, item: IndexPerson) =>
- kind === 'agencies' ? `${(item.members || 0).toLocaleString()} 人` : item.n.toLocaleString();
+ kind === 'agencies' ? `${(item.members || 0).toLocaleString()} 人` : `${(item.n || 0).toLocaleString()} 个视频`;
const COLLATOR = { numeric: true, sensitivity: 'base' } as const;
diff --git a/frontend/src/react/index/index-page.tsx b/frontend/src/react/index/index-page.tsx
index 0d55196fd..7a1645e5a 100644
--- a/frontend/src/react/index/index-page.tsx
+++ b/frontend/src/react/index/index-page.tsx
@@ -210,7 +210,7 @@ export function IndexPage(props: IndexProps) {
}
if (result.isError) {
return (
- <EmptyState icon={spriteGlyph('search')} title={`没能读取${title}`}
+ <EmptyState icon={spriteGlyph('alert')} title={`没能读取${title}`}
actions={<Button variant="secondary" onClick={() => void result.refetch()}>重试</Button>}>
{requestErrorMessage(result.error)}
</EmptyState>
@@ -232,7 +232,8 @@ export function IndexPage(props: IndexProps) {
</h2>
{isPeople(kind) ? (
<span data-index-count="" className="text-caption-1-regular leading-5 whitespace-nowrap text-text-secondary tabular-nums">
- {result.isPending ? '' : readout}
+ {/* 没取到就没有读数:「0 项」读起来是「名册是空的」,和报错说的是两件事。 */}
+ {result.isPending || result.isError ? '' : readout}
</span>
) : null}
{isPeople(kind) ? <LayoutSwitch kind={kind} layout={layout} onChange={changeLayout} /> : null}
diff --git a/frontend/src/react/index/index-people.css b/frontend/src/react/index/index-people.css
index 497282240..8612b601d 100644
--- a/frontend/src/react/index/index-people.css
+++ b/frontend/src/react/index/index-people.css
@@ -15,6 +15,10 @@
color: var(--muted);
font-family: Bahnschrift, "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}
+/* 超扁、超高的标识:`fitNativeImage` 已把短边撑到下限,这里 cover 把长边两头裁掉。 */
+.peach-react [data-index-grid] [data-person-ring][data-native-clamp="true"] img {
+ object-fit: cover;
+}
.peach-react [data-index-grid] [data-index-readout] {
color: var(--muted);
}
diff --git a/frontend/src/react/index/index-people.tsx b/frontend/src/react/index/index-people.tsx
index 97d613c23..59fd0abad 100644
--- a/frontend/src/react/index/index-people.tsx
+++ b/frontend/src/react/index/index-people.tsx
@@ -43,7 +43,7 @@ function Cell(
className: `${CELL} ${big ? 'items-stretch text-left' : 'items-center text-center'}`,
})}>
{children}
- <span data-index-name="" className="text-body-medium break-all text-text-primary">{name}</span>
+ <span data-index-name="" className="text-body-medium wrap-anywhere text-text-primary">{name}</span>
<span data-index-readout="" className="text-caption-1-regular">{readout}</span>
</button>
);
diff --git a/frontend/src/react/index/index-tags.tsx b/frontend/src/react/index/index-tags.tsx
index 73bee3d8b..d2c660095 100644
--- a/frontend/src/react/index/index-tags.tsx
+++ b/frontend/src/react/index/index-tags.tsx
@@ -36,7 +36,7 @@ function AlphaTag({ tag, actions }: { tag: TagEntry; actions: TagActions }) {
const pressed = actions.picked.has(tag.k);
return (
<button type="button" data-alpha-tag="" data-k={tag.k} data-tag-cat={tagColorKey(actions.online, tag.cat)}
- aria-pressed={pressed} onClick={() => actions.press(tag.k)}
+ aria-pressed={pressed} title={tag.label} onClick={() => actions.press(tag.k)}
className="flex h-9 min-w-0 cursor-pointer items-center gap-2.25 rounded-lg px-2.5 text-left text-body-regular text-text-secondary outline-none hover:text-text-primary focus-visible:ring-2 focus-visible:ring-border-focus-ring">
<Dot />
<span className="min-w-0 flex-1 truncate">{tag.label}</span>
@@ -150,7 +150,7 @@ export function TagDock(
{ count: number; match: 'any' | 'all'; onMatch(match: 'any' | 'all'): void; onClear(): void; onApply(): void },
) {
return (
- <SelectionDock visible={count > 0} label="所选标签操作" count={`已选 ${count} 个标签`}>
+ <SelectionDock visible={count > 0} label="所选标签操作" count={`已选 ${count.toLocaleString()} 个标签`}>
<Checkbox isSelected={match === 'any'} onChange={(on) => onMatch(on ? 'any' : 'all')}>
<span className="flex flex-col">
<span className="text-body-medium">广泛匹配</span>
diff --git a/frontend/test/card-art/framing.test.ts b/frontend/test/card-art/framing.test.ts
index 82adeb06a..195bafd76 100644
--- a/frontend/test/card-art/framing.test.ts
+++ b/frontend/test/card-art/framing.test.ts
@@ -175,6 +175,23 @@ describe('fitNativeImage:比框还小的图原尺寸摆', () => {
expect(box.style.getPropertyValue('--markw')).toBe('100%');
expect(box.style.getPropertyValue('--markbg')).toBe('none');
});
+
+ it('超扁的标识短边撑到下限、不补模糊底;人像框不走这一条', () => {
+ const host = mount('<span data-fit-native="mark"><img src="/logo?studio=b"></span>'
+ + '<span data-fit-native="portrait"><img src="/avatar?p=c"></span>');
+ const [mark, portrait] = [...host.querySelectorAll<HTMLElement>('[data-fit-native]')];
+ for (const box of [mark!, portrait!]) {
+ Object.defineProperty(box, 'clientWidth', { value: 180 });
+ Object.defineProperty(box, 'clientHeight', { value: 180 });
+ }
+ fitNativeImage(sized(mark!.querySelector('img')!, 1378, 42));
+ expect(mark!.dataset.nativeClamp).toBe('true');
+ expect(mark!.style.getPropertyValue('--markw')).toBe('180px');
+ expect(mark!.style.getPropertyValue('--markh')).toBe('18px');
+ expect(mark!.style.getPropertyValue('--markbg')).toBe('none');
+ fitNativeImage(sized(portrait!.querySelector('img')!, 1378, 42));
+ expect(portrait!.dataset.nativeClamp).toBe('false');
+ });
});
describe('加载微光', () => {
diff --git a/frontend/test/card-art/native-image.test.ts b/frontend/test/card-art/native-image.test.ts
index 44d3477bc..f51c7462c 100644
--- a/frontend/test/card-art/native-image.test.ts
+++ b/frontend/test/card-art/native-image.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
-import { nativeImageFit, faceSourceScale } from '../../src/card-art/native-image';
+import { markClamp, MARK_MIN_SHORT, nativeImageFit, faceSourceScale } from '../../src/card-art/native-image';
it('544×724 的旧人像不能使用 2184×1468 封面的焦点', () => {
expect(faceSourceScale(544, 724, 2184, 1468)).toBe(0);
@@ -51,3 +51,20 @@ describe('头像和标识的小图补底', () => {
expect(nativeImageFit(0, 0, 180, 240).small).toBe(false);
});
});
+
+describe('超扁、超高的标识撑出最小短边', () => {
+ it('1378×42 的横条短边撑到框短边的下限,长边仍按框', () => {
+ expect(markClamp(1378, 42, 180, 180)).toEqual({ width: 180, height: 180 * MARK_MIN_SHORT });
+ });
+ it('42×600 的竖条同理撑宽', () => {
+ expect(markClamp(42, 600, 180, 180)).toEqual({ width: 180 * MARK_MIN_SHORT, height: 180 });
+ });
+ it('10:1 的字标和方形标识照常 contain', () => {
+ expect(markClamp(400, 40, 180, 180)).toBeNull();
+ expect(markClamp(120, 120, 180, 180)).toBeNull();
+ });
+ it('尺寸没量到时不动', () => {
+ expect(markClamp(0, 0, 180, 180)).toBeNull();
+ expect(markClamp(1378, 42, 0, 0)).toBeNull();
+ });
+});
diff --git a/frontend/test/crop-geometry.test.ts b/frontend/test/crop-geometry.test.ts
index 209612825..621969530 100644
--- a/frontend/test/crop-geometry.test.ts
+++ b/frontend/test/crop-geometry.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest';
import {
- boxPercent, centeredBox, clampBox, defaultPanelBox, frameWithin, MIN_CROP_EDGE, moveBox,
+ boxPercent, centeredBox, clampBox, defaultPanelBox, frameWithin, handleOutside, HANDLE_ROOM, MIN_CROP_EDGE, moveBox,
previewStyle, resizeFromCorner, scaleBox, toNatural, windowStyle,
} from '../src/crop-geometry';
@@ -122,3 +122,20 @@ describe('框换算成样式', () => {
expect(toNatural(100, 0, 800)).toBe(0);
});
});
+
+describe('角柄放哪儿', () => {
+ it('框在屏幕上够大时角柄压在框角上', () => {
+ expect(handleOutside({ width: 50, height: 50 }, { width: 400, height: 400 })).toBe(false);
+ });
+ it('4000×200 的图只剩 20px 高,框比角柄大不了多少,角柄挪到框外', () => {
+ // 方框占满图高:屏幕上 20×20。
+ expect(handleOutside({ width: 5, height: 100 }, { width: 400, height: 20 })).toBe(true);
+ });
+ it('只看短边:长条框哪怕很长也要挪', () => {
+ expect(handleOutside({ width: 100, height: 100 }, { width: 600, height: HANDLE_ROOM - 1 })).toBe(true);
+ });
+ it('图的显示尺寸还没量到时不挪', () => {
+ expect(handleOutside({ width: 5, height: 5 }, null)).toBe(false);
+ expect(handleOutside({ width: 5, height: 5 }, { width: 0, height: 0 })).toBe(false);
+ });
+});
diff --git a/frontend/test/react/avatar-picker.test.tsx b/frontend/test/react/avatar-picker.test.tsx
index a9544e5b9..b6df0fff0 100644
--- a/frontend/test/react/avatar-picker.test.tsx
+++ b/frontend/test/react/avatar-picker.test.tsx
@@ -283,6 +283,55 @@ it('过期的图库索引说出多久没更新,不说成还没取过', async (
expect(dialog()?.textContent).not.toContain('还没取过');
});
+it('按好多个名字找到时说明只点名前两个,余下的报个数', async () => {
+ const names = ['葵つかさ', '葵ツカサ', 'あおいつかさ', 'Aoi Tsukasa', '葵司 (AV女優)'];
+ server(listing([choice({ found_by: names[4] })], { matched_names: names }));
+ await openPicker();
+ const note = dialog()?.textContent || '';
+ expect(note).toContain('图库里按「葵つかさ」「葵ツカサ」等 5 个名字找到的');
+ expect(note).not.toContain('あおいつかさ');
+ // 没点名的那几个照旧落在各自格子的 title 里。
+ expect(cells()[0]?.getAttribute('title')).toContain('按「葵司 (AV女優)」找到');
+});
+
+it('一张候选也没有时不留网格那一带,手填那两条路照旧在', async () => {
+ server(listing([], { matched_names: [] }));
+ await openPicker();
+ expect(document.querySelector('[role="listbox"]')).toBeNull();
+ expect(buttonNamed('从本机选图片')).not.toBeNull();
+ expect(document.querySelector('input[aria-label="图片地址"]')).not.toBeNull();
+});
+
+it('候选没取到时原因旁边有「重试」,点了再取一遍', async () => {
+ let fail = true;
+ const fetched = vi.fn(async () => (fail
+ ? { ok: false, status: 500, json: async () => ({ error: '候选读不出来' }) }
+ : { ok: true, status: 200, json: async () => listing([choice()]) }));
+ vi.stubGlobal('fetch', fetched);
+ await openPicker();
+ expect(dialog()?.querySelector('[role="alert"]')?.textContent).toContain('候选读不出来');
+ expect(document.querySelector('[role="listbox"]')).toBeNull();
+ fail = false;
+ await click(buttonNamed('重试'));
+ await settle();
+ expect(fetched).toHaveBeenCalledTimes(2);
+ expect(cells()).toHaveLength(1);
+ expect(dialog()?.querySelector('[role="alert"]')).toBeNull();
+});
+
+it('提交失败的原因旁边不给「重试」:重来的是那颗提交键自己', async () => {
+ vi.stubGlobal('fetch', vi.fn(async (_input: string, init?: RequestInit) => (
+ init?.method === 'POST'
+ ? { ok: false, status: 400, json: async () => ({ error: '只接受指向公网的 https 地址' }) }
+ : { ok: true, status: 200, json: async () => listing([choice()]) }
+ )));
+ await openPicker();
+ await click(cells()[0]);
+ await settle();
+ expect(dialog()?.querySelector('[role="alert"]')).not.toBeNull();
+ expect(buttonNamed('重试')).toBeNull();
+});
+
it('合演作品的格子标出人数,框选时提醒先找到她自己的脸', async () => {
server(listing([choice({
ref: 'asset:11:cover', source: 'asset', label: 'DVAJ-495', crop: true,
@@ -318,7 +367,7 @@ it('候选回来之前网格里是同一种格子的骨架,回来之后换成
expect(cells()).toHaveLength(1);
});
-it('一格的图到了才揭开,取不到也揭开', async () => {
+it('一格的图到了才揭开,取不到时撤掉图、揭开空底', async () => {
server(listing([choice(), choice({ ref: 'sha256:abc', source: 'history', label: 'twitter' })]));
await openPicker();
const [first, second] = cells();
@@ -328,7 +377,10 @@ it('一格的图到了才揭开,取不到也揭开', async () => {
await act(async () => { first?.querySelector('img')?.dispatchEvent(new Event('load')) });
expect(layers(first).map((one) => one.hasAttribute('data-revealed'))).toEqual([true, true]);
await act(async () => { second?.querySelector('img')?.dispatchEvent(new Event('error')) });
- expect(second?.querySelector('img')?.hasAttribute('data-revealed')).toBe(true);
+ expect(second?.querySelector('img')).toBeNull();
+ expect(second?.querySelector('[data-choice-lost]')).not.toBeNull();
+ expect(second?.querySelector('.reveal-skeleton')?.hasAttribute('data-revealed')).toBe(true);
+ expect(second?.textContent).toContain('twitter');
});
it('封面格子在取景区里取一块 3:4,图库人像照旧铺满', async () => {
diff --git a/frontend/test/react/entity-body.test.tsx b/frontend/test/react/entity-body.test.tsx
index fe7f7b449..5157be538 100644
--- a/frontend/test/react/entity-body.test.tsx
+++ b/frontend/test/react/entity-body.test.tsx
@@ -82,7 +82,7 @@ describe('名册', () => {
expect(ring?.dataset.fitNative).toBe('portrait');
expect(ring?.style.getPropertyValue('--face')).toBe('40% 20%');
expect([...host.querySelectorAll('[data-index-cell]')].map((cell) => cell.querySelector('[data-index-readout]')?.textContent))
- .toEqual(['12', '3']);
+ .toEqual(['12 个视频', '3 个视频']);
await click(host.querySelector('[data-index-cell][data-k="小湊よつ葉"]'));
expect(given.actions.openEntity).toHaveBeenCalledWith('performer', '小湊よつ葉');
expect(host.querySelector('[data-entity-grid]')).toBeNull();
@@ -99,6 +99,18 @@ describe('名册', () => {
await click(host.querySelector('[data-index-cell]'));
expect(given.actions.openEntity).toHaveBeenCalledWith('studio', 'S1 NO.1 STYLE');
});
+
+ it('上千人的名册先摆 120 格,「载入更多」一次再接 120 格,摆完就收起', async () => {
+ const people = Array.from({ length: 250 }, (_, at) => ({ k: `艺人${at}`, n: 1 }));
+ const host = await open(props({ kind: 'agency', view: 'people', roster: { kind: 'performers', people, layout: 'big' } }));
+ const count = () => host.querySelectorAll('[data-index-cell]').length;
+ expect(count()).toBe(120);
+ await click(host.querySelector('[data-entity-more]'));
+ expect(count()).toBe(240);
+ await click(host.querySelector('[data-entity-more]'));
+ expect(count()).toBe(250);
+ expect(host.querySelector('[data-entity-more]')).toBeNull();
+ });
});
describe('作品网格', () => {
diff --git a/frontend/test/react/entity-hero.test.tsx b/frontend/test/react/entity-hero.test.tsx
index a92ceff4e..c15c7714b 100644
--- a/frontend/test/react/entity-hero.test.tsx
+++ b/frontend/test/react/entity-hero.test.tsx
@@ -150,6 +150,24 @@ describe('排版用的纯函数', () => {
]);
});
+ it('生日写了而年龄没下发时只写生日,不拼出「undefined 岁」', () => {
+ const [birth] = factRows({ birth_date: '1990-08-14' });
+ expect(birth?.parts.map((part) => part.text)).toEqual(['1990-08-14']);
+ });
+
+ it('两处以上不公开来源合并成一枚排在末尾,各处名字留给 title;只有一处照旧', () => {
+ const links = heroLinks(performer({ links: [
+ { link_id: 1, clickable: false, label: '私人记录' },
+ { link_id: 2, link_kind: 'social', clickable: true, label: 'X', url: 'https://x.com/aoi' },
+ { link_id: 3, clickable: false, label: '论坛帖' },
+ { link_id: 4, clickable: false, label: '群聊截图' },
+ ] }), 'performer');
+ expect(links.map((link) => link.type)).toEqual(['icon', 'private']);
+ expect(links[1]).toEqual({ type: 'private', label: '3 个不公开来源', sources: ['私人记录', '论坛帖', '群聊截图'] });
+ expect(heroLinks(performer({ links: [{ link_id: 1, clickable: false, label: '私人记录' }] }), 'performer'))
+ .toEqual([{ type: 'private', label: '私人记录' }]);
+ });
+
it('公司页的官网保留名字,指回自家的写「官方网站」', () => {
const [site] = heroLinks({
id: 1, canonical_name: 'S1 NO.1 STYLE', asset_count: 1,
@@ -181,6 +199,28 @@ describe('画出什么', () => {
expect(performerLine).not.toContain('事务所');
});
+ it('公司别名先列三个,余下的收进「+N」,浮层里一个名字一行', async () => {
+ const names = Array.from({ length: 30 }, (_, at) => `旧レーベル${at + 1}`);
+ const host = await open(props({ kind: 'studio', name: 'S1', entity: {
+ id: 3, canonical_name: 'S1', asset_count: 9, display_aliases: names,
+ } }));
+ const inline = host.querySelectorAll('[data-company-names] [data-alias-names] > span');
+ expect([...inline].map((one) => one.textContent)).toEqual(['旧レーベル1', '旧レーベル2', '旧レーベル3']);
+ expect(host.querySelector('[data-hero-more="alias"]')?.textContent).toBe('+27');
+ const pop = document.getElementById('entityAliasPop')!;
+ expect(pop.querySelectorAll('[data-pop-name]')).toHaveLength(30);
+ });
+
+ it('合并后的不公开来源写个数,各处名字一行一个放进 title', async () => {
+ const host = await open(props({ entity: performer({ links: [
+ { link_id: 1, clickable: false, label: '私人记录' },
+ { link_id: 3, clickable: false, label: '论坛帖' },
+ ] }) }));
+ const chip = host.querySelector('[data-link="private"]');
+ expect(chip?.textContent).toContain('2 个不公开来源');
+ expect(chip?.getAttribute('title')).toBe('私人记录\n论坛帖');
+ });
+
it('纯图标外链的名字在 title 与读屏名称里;站点圆标由本机给、不带来源页地址,取不到时交兜底链撤掉;官网写字', async () => {
const host = await open(props({ entity: performer({ links: [
{ link_id: 3, link_kind: 'official', clickable: true, label: 'New Actor eXperience', url: 'https://www.nax.co.jp/talent/aoi' },
diff --git a/frontend/test/react/entity-page.test.tsx b/frontend/test/react/entity-page.test.tsx
index cee0d33bd..9686abd56 100644
--- a/frontend/test/react/entity-page.test.tsx
+++ b/frontend/test/react/entity-page.test.tsx
@@ -227,7 +227,8 @@ describe('换筛选与视图', () => {
await settle();
expect(page.calls('/api/items').map((url) => url.searchParams.get('tag'))).toEqual([null, '巨乳']);
expect(cards(page.props)).toEqual(['7']);
- expect(readout(page.props)).toBe('视频 · 1 · 巨乳');
+ // 选了哪几枚由交集条列着,读数只报个数:标签名再列一遍,几枚长标签就能把这一行撑出页面。
+ expect(readout(page.props)).toBe('视频 · 1 · 已选 1 个标签');
expect(page.props.hosts.filter.querySelector('[data-entity-tag="巨乳"]')?.getAttribute('aria-pressed')).toBe('true');
await push({ filters: {} });
await settle();
@@ -235,6 +236,24 @@ describe('换筛选与视图', () => {
expect(cards(page.props)).toEqual(['1', '2', '3']);
});
+ it('名下一部视频也没有:正文是空态,下排不出排序键', async () => {
+ const page = await open({ entity: entity({ asset_count: 0 }), items: () => items([]) });
+ expect(page.props.hosts.body.textContent).toContain('还没有视频');
+ expect(page.props.hosts.body.querySelector('[data-media-grid]')).toBeNull();
+ expect(page.props.hosts.filter.querySelector('[data-entity-sort]')).toBeNull();
+ expect(buttonNamed('查看全部视频', page.props.hosts.body)).toBeNull();
+ });
+
+ it('筛完一部不剩:空态给一条回到全部视频的路,撤掉观看状态与交集条上的筛选', async () => {
+ const page = await open({ items: (query) => items(query.get('tag') ? [] : [1, 2, 3]) },
+ { filters: { tag: '巨乳', state: 'fresh', sort: 'new' } });
+ expect(page.props.hosts.body.textContent).toContain('没有符合条件的视频');
+ await click(buttonNamed('查看全部视频', page.props.hosts.body));
+ expect(page.props.actions.route).toHaveBeenCalledWith(
+ expect.objectContaining({ sort: 'new', tag: '', state: '', creator: '', studio: '', owner: '' }),
+ expect.objectContaining({ media: 'videos' }));
+ });
+
it('视图键与观看状态不自己改地址:交给壳写好再推回来;照片已在首屏取过,切过去不请求', async () => {
const page = await open({ photos: () => photos(4) });
await click(page.props.hosts.filter.querySelector('[data-media-view="photos"]'));
diff --git a/frontend/test/react/index-page.test.tsx b/frontend/test/react/index-page.test.tsx
index 65f91b769..e73ba6115 100644
--- a/frontend/test/react/index-page.test.tsx
+++ b/frontend/test/react/index-page.test.tsx
@@ -176,6 +176,29 @@ describe('名册', () => {
expect(given.openEntity).toHaveBeenCalledWith('performer', '甲');
});
+ it('格子底下的作品数带单位、按千分位写;页头读数同样分位', async () => {
+ seed(indexKey('performers', ''), [person('甲', { n: 128400 }), person('乙', { n: 0 })]);
+ const host = await open(props());
+ expect(cells(host)[0]?.textContent).toContain('128,400 个视频');
+ expect(cells(host)[1]?.textContent).toContain('0 个视频');
+ });
+
+ it('名册没读到时页头不写「0 项」,空态配出错的字形', async () => {
+ vi.stubGlobal('fetch', vi.fn(async () => ({ ok: false, status: 500, json: async () => ({ error: '读不出来' }) })));
+ const host = await open(props());
+ await settle();
+ expect(host.textContent).toContain('没能读取');
+ expect(host.querySelector('[data-index-count]')?.textContent ?? '').toBe('');
+ expect(host.textContent).not.toContain('0 项');
+ });
+
+ it('字母表里截断的标签名悬停看得到全名', async () => {
+ const long = 'とても長い日本語のタグ名がここに続いて途中で切れてしまうもの';
+ seed(indexKey('tags', '', 'all'), [tag(long)]);
+ const host = await open(props({ kind: 'tags' }));
+ expect(alphaTag(host, long)?.getAttribute('title')).toBe(long);
+ });
+
it('换版式写回偏好、按圆框取头像,并把已经加载完的图重量一遍', async () => {
seed(indexKey('performers', ''), [person('甲')]);
const given = props();