Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 馆藏各页在极端内容下不再裁字、叠压或卡在加载态

longmeidaofe25c25ca2a3
diff --git a/frontend/e2e/card-layout.test.ts b/frontend/e2e/card-layout.test.ts
index b886d4ae5..28fd8825a 100644
--- a/frontend/e2e/card-layout.test.ts
+++ b/frontend/e2e/card-layout.test.ts
@@ -5,12 +5,12 @@ import {launch,requiredEnv,VIEWPORTS} from './harness.ts';
const FRAMES='#grid [data-media-grid] > [data-media-card] [data-media-pic], #grid [data-mix-cover]';
-/** 首页铺 20 张纯白预览图的作品,`size` 是首页版式。 */
-async function openHome(page:Page,size:string){
+/** 首页铺 20 张纯白预览图的作品,`size` 是首页版式;`patch` 按序号改其中几张。 */
+async function openHome(page:Page,size:string,patch:(i:number)=>Record<string,unknown>=()=>({})){
await page.addInitScript(size=>localStorage.setItem('peach.settings.v1',JSON.stringify({detailAutoplay:false,homeLayout:size})),size);
await page.route('**/api/items?*',route=>route.fulfill({json:{items:Array.from({length:20},(_,i)=>({
id:91000+i,name:`示例作品 ${i}`,creator:'示例创作者',is_jav:i%2===0,has_thumb:true,has_cover:false,
- width:1600,height:900,location:'local',duration:120,
+ width:1600,height:900,location:'local',duration:120,...patch(i),
})),total:20,has_more:false}}));
await page.route('**/poster?*',route=>route.fulfill({contentType:'image/svg+xml',body:'<svg xmlns="http://www.w3.org/2000/svg" width="1600" height="900"><rect width="1600" height="900" fill="white"/></svg>'}));
await page.goto(requiredEnv('PEACH_E2E_ORIGIN')+'/',{waitUntil:'load'});
@@ -110,6 +110,57 @@ describe('混排作品的画面框',()=>{
}finally{await context.close()}
});
}
+ it('多选态的勾选圆不压分卷徽标;番号带三枚版本徽标时整组留在标题框内',async()=>{
+ const context=await browser.newContext({viewport:{width:320,height:720}});
+ try{
+ const page=await context.newPage();
+ await openHome(page,'small',i=>i===0?{
+ name:'FC2-PPV-4728193 夏の終わり',code:'FC2-PPV-4728193',display_title:'夏の終わり',edition_badges:['中字','无码','无码破解'],
+ part_group:{key:'p',seed_id:91000,count:128},
+ }:{});
+ const first=page.locator('#grid [data-media-grid] > [data-media-card]').first();
+ await first.click({modifiers:['Control']});
+ await first.locator('[data-media-check]').waitFor();
+ const box=await first.evaluate(card=>{
+ const rect=(selector:string)=>card.querySelector(selector)!.getBoundingClientRect();
+ const title=rect('[data-media-title]');
+ return {
+ group:rect('[data-media-group]').right,check:rect('[data-media-check]').left,
+ count:card.querySelectorAll('[data-media-title] .javedition').length,title:title.right,badges:Math.max(...[...card.querySelectorAll('[data-media-title] .javedition')].map(node=>node.getBoundingClientRect().right)),
+ };
+ });
+ assert.equal(box.count,3);
+ assert.ok(box.group<=box.check,`勾选圆压住了分卷徽标:${JSON.stringify(box)}`);
+ assert.ok(box.badges<=box.title+0.5,`版本徽标越出标题框:${JSON.stringify(box)}`);
+ }finally{await context.close()}
+ });
+ it('十二位共演都没有头像图:网格卡五枚首字母都露在外面,竖屏卡只放两枚,标题照样有宽度',async()=>{
+ const context=await browser.newContext({viewport:{width:1280,height:900}});
+ try{
+ const page=await context.newPage();
+ const names=['七海ひな','桜井まい','白石りん','水瀬ゆい','藤原あや','J','K','L','M','N','O','P'];
+ await openHome(page,'small',()=>({creator:'',performers:names,performer_total:12}));
+ const short=page.locator('[data-media-card][data-variant="short"]').first();
+ await short.waitFor();
+ const measure=(card:Element)=>{
+ const avatars=[...card.querySelectorAll('[data-media-avatars] > [data-media-avatar]')]
+ .filter(node=>getComputedStyle(node).display!=='none');
+ const covered=avatars.filter(node=>{
+ const box=node.getBoundingClientRect();
+ return document.elementFromPoint(box.left+box.width/2,box.top+box.height/2)?.closest('[data-media-avatar]')!==node;
+ }).length;
+ return {shown:avatars.length,covered,text:Math.round(card.querySelector('[data-media-text]')!.getBoundingClientRect().width),card:Math.round(card.getBoundingClientRect().width)};
+ };
+ const grid=await page.locator('#grid [data-media-grid] > [data-media-card]').first().evaluate(measure);
+ assert.equal(grid.shown,5);
+ assert.equal(grid.covered,0,`有首字母被左邻盖住:${JSON.stringify(grid)}`);
+ await short.scrollIntoViewIfNeeded();
+ const portrait=await short.evaluate(measure);
+ assert.equal(portrait.shown,2);
+ assert.equal(portrait.covered,0,JSON.stringify(portrait));
+ assert.ok(portrait.text>=portrait.card*0.6,`竖屏卡的标题列被头像挤窄:${JSON.stringify(portrait)}`);
+ }finally{await context.close()}
+ });
it('Shift 连选几张卡不把中间的文字刷成选区',async()=>{
const context=await browser.newContext({viewport:{width:1280,height:900}});
try{
diff --git a/frontend/e2e/item-detail.test.ts b/frontend/e2e/item-detail.test.ts
index 71224fc7b..c1689b6ec 100644
--- a/frontend/e2e/item-detail.test.ts
+++ b/frontend/e2e/item-detail.test.ts
@@ -523,6 +523,43 @@ describe('作品详情岛', () => {
}
});
+ it('取不到这一条:播放器格照 16:9 撑开,重试提示居中,不塌成一条窄条', { timeout: 60_000 }, async () => {
+ const opened = await openItemPage(browser, `/item/${ITEM.plain}`, DESKTOP);
+ try {
+ const page = opened.page;
+ await page.route((url) => url.pathname === '/api/item', (route) => route.fulfill({ status: 500, json: { error: 'database is locked' } }));
+ await page.goto(new URL('/item/987654', page.url()).toString(), { waitUntil: 'load' });
+ await page.locator('#stage [data-item-placeholder] [data-media-error]').waitFor({ timeout: 15_000 });
+ const box = await page.evaluate(() => {
+ const frame = document.querySelector('#stage [data-item-placeholder]')!.getBoundingClientRect();
+ const note = document.querySelector('#stage [data-item-placeholder] [data-media-error]')!.getBoundingClientRect();
+ return { ratio: frame.width / frame.height, offset: Math.abs((note.top + note.bottom) / 2 - (frame.top + frame.bottom) / 2) };
+ });
+ assert.ok(Math.abs(box.ratio - 16 / 9) < 0.02, `播放器格不是 16:9:${JSON.stringify(box)}`);
+ assert.ok(box.offset < 2, `提示没有竖直居中:${JSON.stringify(box)}`);
+ } finally {
+ await opened.close();
+ }
+ });
+
+ it('长标签单行省略,高度和别的标签一样', { timeout: 60_000 }, async () => {
+ const opened = await openItemPage(browser, `/item/${ITEM.plain}`, MOBILE);
+ try {
+ const page = opened.page;
+ const heights = await page.evaluate(() => {
+ const tag = document.querySelector('#detailTags [data-tag]') as HTMLElement;
+ const before = tag.getBoundingClientRect().height;
+ tag.textContent = 'customer-feedback-from-enterprise-onboarding-customer-feedback-from-enterprise-onboarding';
+ return { before, after: tag.getBoundingClientRect().height, wide: tag.scrollWidth > tag.clientWidth };
+ });
+ assert.equal(heights.after, heights.before, `长标签折行了:${JSON.stringify(heights)}`);
+ assert.equal(heights.wide, true, '长标签应当被省略');
+ assert.deepEqual((await layout(page)).offenders, [], '长标签撑出视口');
+ } finally {
+ await opened.close();
+ }
+ });
+
it('手机 390:详情不横向溢出,侧栏排在播放区下面', { timeout: 60_000 }, async () => {
const opened = await openItemPage(browser, `/item/${ITEM.plain}`, MOBILE);
try {
diff --git a/frontend/e2e/photo-lightbox.test.ts b/frontend/e2e/photo-lightbox.test.ts
index b3a365fe5..87e32b7b7 100644
--- a/frontend/e2e/photo-lightbox.test.ts
+++ b/frontend/e2e/photo-lightbox.test.ts
@@ -23,9 +23,9 @@ async function stubImages(page: Page): Promise<void> {
await page.route(/\/(?:photo-thumb|sample-thumb)\?|\/follow-thumb-stub\//, (route) => route.fulfill(svg(160, 120)));
}
-/** 资料页照片档:一部作品两张样张加三张本地图,墙上五格。 */
-async function openWall(browser: Browser): Promise<Visit> {
- const opened = await visit(browser, '/', DESKTOP);
+/** 资料页照片档:一部作品两张样张加 `locals` 张本地图(默认三张,墙上五格)。 */
+async function openWall(browser: Browser, viewport = DESKTOP, locals = 3): Promise<Visit> {
+ const opened = await visit(browser, '/', viewport);
const { page } = opened;
await page.route(/\/api\/entity\?/, (route) => route.fulfill({ json: {
id: 90_001, kind: 'performer', canonical_name: NAME, aliases: [], display_aliases: [], user_aliases: [],
@@ -34,7 +34,7 @@ async function openWall(browser: Browser): Promise<Visit> {
} }));
await page.route(/\/api\/photos\?/, (route) => {
const offset = Number(new URL(route.request().url()).searchParams.get('offset') || 0);
- const items = offset ? [] : [100, 101, 102].map((id) => ({ id, name: `${id}.jpg`, size: 2_345_678, location: 'local' }));
+ const items = offset ? [] : Array.from({ length: locals }, (_, at) => ({ id: 100 + at, name: `${100 + at}.jpg`, size: 2_345_678, location: 'local' }));
return route.fulfill({ json: {
kind: 'performer', name: NAME, entity_id: 90_001, total: items.length, items, seed: '', has_more: false,
sample_total: 2, sets: [{ id: 'code:SSIS-057', kind: 'code', code: 'SSIS-057', name: '雨の日',
@@ -215,7 +215,7 @@ describe('图片灯箱', () => {
}
});
- it('关注详情的大图打开同一个灯箱:整组三张,在线图写来源、序号与分辨率,没有定位键', { timeout: 60_000 }, async () => {
+ it('关注详情的大图打开同一个灯箱:整组三张,在线图写来源与分辨率,没有定位键', { timeout: 60_000 }, async () => {
const opened = await openFollowItem(browser);
const { page } = opened;
try {
@@ -229,7 +229,9 @@ describe('图片灯箱', () => {
const panel = box.locator('[data-photo-detail]');
await panel.waitFor({ state: 'visible' });
assert.equal((await panel.locator('h2').innerText()).trim(), '帖子图 1.png');
- assert.match(await panel.locator('[data-photo-detail-meta]').innerText(), /第 1 \/ 3 张 · 4000 × 3000/);
+ const meta = await panel.locator('[data-photo-detail-meta]').innerText();
+ assert.match(meta, /^pixivFANBOX · 4000 × 3000 · 121\sKB$/u);
+ assert.doesNotMatch(meta, /第/, '第几张只看底栏的页码,面板不另编一个号');
assert.equal(await panel.locator('[data-photo-reveal]').isVisible(), false, '在线图不该有定位键');
await labelled(box, '关闭').click();
await box.waitFor({ state: 'detached' });
@@ -238,4 +240,31 @@ describe('图片灯箱', () => {
await opened.close();
}
});
+
+ it('320 宽翻到上千张的最后一张:页码一行写完,底栏整条留在屏内', { timeout: 90_000 }, async () => {
+ const opened = await openWall(browser, { name: '320', width: 320, height: 720, mobile: true }, 1287);
+ const { page } = opened;
+ try {
+ await page.locator('[data-photo-cell]').first().click();
+ const box = lightbox(page);
+ await box.waitFor();
+ await page.evaluate(() => {
+ const main = document.querySelector('[data-photo-main]') as HTMLElement & { swiper: { slideTo(at: number, speed: number): void } };
+ main.swiper.slideTo(1288, 0);
+ });
+ const count = box.locator('[data-photo-count]');
+ await page.waitForFunction(() => document.querySelector('[data-photo-count]')?.textContent === '1289 / 1289');
+ const bar = await box.locator('[data-photo-bar]').evaluate((node) => ({
+ line: parseFloat(getComputedStyle(node.querySelector('[data-photo-count]')!).lineHeight) || 16,
+ count: node.querySelector('[data-photo-count]')!.getBoundingClientRect().height,
+ right: Math.max(...[...node.querySelectorAll('button, [data-photo-count]')].map((el) => el.getBoundingClientRect().right)),
+ view: document.documentElement.clientWidth,
+ }));
+ assert.ok(bar.count < bar.line * 2 + 16, `页码折行了:${JSON.stringify(bar)}`);
+ assert.ok(bar.right <= bar.view, `底栏越出视口:${JSON.stringify(bar)}`);
+ assert.equal(await count.isVisible(), true);
+ } finally {
+ await opened.close();
+ }
+ });
});
diff --git a/frontend/src/react/catalog-filter/catalog-filter-page.tsx b/frontend/src/react/catalog-filter/catalog-filter-page.tsx
index 70eb45c50..8cc1a682a 100644
--- a/frontend/src/react/catalog-filter/catalog-filter-page.tsx
+++ b/frontend/src/react/catalog-filter/catalog-filter-page.tsx
@@ -65,7 +65,7 @@ function Glass(props: CatalogFilterProps) {
<FilterGlassRows label="筛选与排序" topLabel="视图与标签"
attrs={{ 'data-filter-frame': '', 'data-catalog-frame': '' }}
className="mx-4" topClassName="gap-1.5 overflow-visible" bottomClassName={props.trash ? 'hidden' : 'min-h-12'}
- bottomRef={bottomRow} busy={!props.count || props.refreshing}
+ bottomRef={bottomRow} busy={props.count === null || props.refreshing}
panes={<span ref={pane} data-view-glide="" aria-hidden="true" />}
top={
<div ref={scroll} data-catalog-scroll="">
@@ -199,8 +199,9 @@ function Head({ count, refreshing, layout, sorts, actions }: CatalogFilterProps)
function Readout({ count }: { count: CatalogFilterProps['count'] }) {
const readout = useRef<HTMLSpanElement>(null);
const skeleton = useRef<HTMLSpanElement>(null);
- const text = count ? `${count.total.toLocaleString()} 个符合 · 显示 ${count.shown}` : '';
+ const text = count ? `${count.total.toLocaleString()} 个符合 · 显示 ${count.shown.toLocaleString()}` : '';
useLayoutEffect(() => {
+ if (count === false) return;
if (!count) { fitSkeleton(skeleton.current); return }
const el = readout.current;
if (!el) return;
@@ -208,6 +209,7 @@ function Readout({ count }: { count: CatalogFilterProps['count'] }) {
lastReadout = text;
popCount(el, text);
}, [count, text]);
+ if (count === false) return <span key="failed" data-catalog-readout="" />;
return count
? <span key="readout" ref={readout} data-catalog-readout="" data-count-readout="" role="status" />
: (
diff --git a/frontend/src/react/catalog-filter/catalog-filter.ts b/frontend/src/react/catalog-filter/catalog-filter.ts
index f9ac76dc8..d1f909559 100644
--- a/frontend/src/react/catalog-filter/catalog-filter.ts
+++ b/frontend/src/react/catalog-filter/catalog-filter.ts
@@ -96,8 +96,8 @@ export interface CatalogFilterProps {
views: readonly CatalogView[];
/** 当前视图:''、fresh、later、flagged、trash。 */
state: string;
- /** 读数。取数期间为空,换成一条微光。 */
- count: { total: number; shown: number } | null;
+ /** 读数。取数期间为空,换成一条微光;`false` 是这一趟取数失败,读数收起,失败与重试由网格那条提示说。 */
+ count: { total: number; shown: number } | null | false;
/** 回收站是待清理队列:读数挂在说明行上,这里没有下排。 */
trash: boolean;
sorts: EntitySortKey[];
diff --git a/frontend/src/react/catalog-grid/catalog-grid-page.tsx b/frontend/src/react/catalog-grid/catalog-grid-page.tsx
index 3de8e7aab..8849b747f 100644
--- a/frontend/src/react/catalog-grid/catalog-grid-page.tsx
+++ b/frontend/src/react/catalog-grid/catalog-grid-page.tsx
@@ -93,6 +93,13 @@ function GridBody(props: CatalogGridProps) {
queueMicrotask(() => { if (live) props.onCount?.(total, shown) });
return () => { live = false };
}, [result.data, total, shown]);
+ const failed = !result.isPending && !result.data;
+ useLayoutEffect(() => {
+ if (!failed) return;
+ let live = true;
+ queueMicrotask(() => { if (live) props.onCountFailed?.() });
+ return () => { live = false };
+ }, [failed]);
const open = useCallback((item: MediaItem, anchor: HTMLElement) => actions.open(item, anchor), [actions]);
const openResource = useCallback(
@@ -191,7 +198,8 @@ export function LoadMore({ entity, load, enabled, children }: {
<>
{entity
? <button ref={attach} type="button" data-entity-more="" {...aria} onClick={() => void run(true)}>{children ?? '载入更多'}</button>
- : <div ref={attach} data-load-more="" {...aria} onClick={() => void run(true)}
+ /* 失败时只留下面那条重试:哨兵收起但不卸下,重试接上之后照旧由它续页。 */
+ : <div ref={attach} data-load-more="" {...aria} hidden={Boolean(state.error)} onClick={() => void run(true)}
dangerouslySetInnerHTML={{ __html: loadingDotsHtml('继续载入中…') }} />}
{state.error ? <RetryNote message={state.error} onRetry={() => void run(true)} /> : null}
</>
diff --git a/frontend/src/react/catalog-grid/types.ts b/frontend/src/react/catalog-grid/types.ts
index e4f239950..e5bd0f397 100644
--- a/frontend/src/react/catalog-grid/types.ts
+++ b/frontend/src/react/catalog-grid/types.ts
@@ -129,6 +129,8 @@ export interface CatalogGridProps {
/** 每接一页报一次:总数与此刻显示的卡数(Mix 与竖屏带不算)。壳据此推筛选条的读数、重画批量条,
* 回收站把读数写在说明行上。 */
onCount?(total: number, shown: number): void;
+ /** 首屏取数失败:没有读数可报,壳据此把筛选条那条读数微光收起。 */
+ onCountFailed?(): void;
/** 空态 HTML。`libraryEmpty` 是整个馆藏都还没有作品。 */
emptyHtml?(state: { trash: boolean; libraryEmpty: boolean }): string;
/** 此刻能不能自动续页:管理区或索引页盖在目录上时不续。 */
diff --git a/frontend/src/react/components/media-card.css b/frontend/src/react/components/media-card.css
index d6b0f0d4f..61a9dc6cc 100644
--- a/frontend/src/react/components/media-card.css
+++ b/frontend/src/react/components/media-card.css
@@ -261,6 +261,8 @@ body[data-surface="/trash"] .peach-react [data-media-card] [data-media-title] {
-webkit-backdrop-filter: blur(10px);
transition: opacity .15s ease;
}
+/* 勾选圆亮出来时占住右上角那 26px:分卷与版本徽标往左让开,「128 卷」不被圆盖住。 */
+.peach-react :is([data-select-mode] [data-media-group], [data-media-card][data-selected] [data-media-group]) { right: 44px; }
.peach-react [data-media-scrub] {
position: absolute;
right: 0;
@@ -506,8 +508,8 @@ body[data-surface="/trash"] .peach-react [data-media-card] [data-media-title] {
.peach-react [data-media-avatars] > :is(:hover, :focus-visible) + * + * { --lift-y: -.81px; --lift-x: 20px; }
.peach-react [data-media-avatars] > :is(:hover, :focus-visible) + * + * + * { --lift-x: 30px; }
.peach-react [data-media-avatars] > :is(:hover, :focus-visible) + * + * + * + * { --lift-x: 40px; }
-/* 接着看那一排的窄卡只放两个头像:第三个挤掉的正好是署名那一行的宽度。 */
-.peach-react [data-variant="next"] [data-media-avatars] > :nth-child(n+3) { display: none; }
+/* 接着看那一排与竖屏带的窄卡只放两个头像:第三个挤掉的正好是署名那一行的宽度。 */
+.peach-react :is([data-variant="next"], [data-variant="short"]) [data-media-avatars] > :nth-child(n+3) { display: none; }
.peach-react [data-media-text] { display: flex; flex: 1; flex-direction: column; gap: 3px; min-width: 0; }
/* 标题两行,高度另用 max-height 封住:番号块是 inline-flex,WebKit 的 line-clamp 遇到非行内
@@ -525,12 +527,17 @@ body[data-surface="/trash"] .peach-react [data-media-card] [data-media-title] {
font-size: var(--fs-md);
line-height: 1.35;
text-align: left;
- word-break: break-all;
+ overflow-wrap: anywhere;
cursor: pointer;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.peach-react span[data-media-title] { cursor: default; }
+/* 番号与版本徽标在别处是一个不折行的整块;卡片标题只有两行,整块比卡宽时会被直接切掉、
+ * 没有省略号。这里拆成行内的几枚徽标,放不下的折到下一行,第二行末尾照样由 line-clamp 收住。
+ * 这两枚类由 `core/jav-title.ts` 挂上,按 `[class~=…]` 认,权重与类选择器相同。 */
+.peach-react [data-media-title] [class~="javidentity"] { display: inline; white-space: normal; }
+.peach-react [data-media-title] [class~="javedition"] { margin-left: 5px; }
.peach-react [data-media-byline] {
display: flex;
flex-wrap: wrap;
@@ -563,11 +570,12 @@ body[data-surface="/trash"] .peach-react [data-media-card] [data-media-title] {
.peach-react [data-flag="seen"] { background: var(--muted); }
.peach-react [data-flag="dispose"] { background: var(--meter); }
.peach-react [data-flag="later"] { background: var(--ink); }
+.peach-react [data-media-why] { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peach-react [data-variant="next"] [data-media-why] { color: var(--loupe); }
.peach-react [data-variant="next"] [data-media-byline] { flex-wrap: nowrap; overflow: hidden; }
.peach-react [data-variant="next"] [data-media-who] { flex: 0 1 auto; max-width: 55%; }
.peach-react [data-variant="next"] [data-media-who-more] { flex: none; white-space: nowrap; }
-.peach-react [data-variant="next"] [data-media-why] { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.peach-react [data-variant="next"] [data-media-why] { flex: 1 1 0; }
.peach-react [data-variant="next"] :is([data-media-size], [data-media-watch-count]) { display: none; }
/* 标签:宁可少放几颗,也要把名字写全。这一行可换行、只有一颗那么高,放不下的整颗落到第二行
diff --git a/frontend/src/react/components/media-card.tsx b/frontend/src/react/components/media-card.tsx
index f5f05bf21..dd5b5fbb3 100644
--- a/frontend/src/react/components/media-card.tsx
+++ b/frontend/src/react/components/media-card.tsx
@@ -35,6 +35,9 @@ const PORTRAIT_RATIO = 9 / 16;
export type MediaCardVariant = 'grid' | 'short' | 'next' | 'resource';
+/** 片名空着时卡片标题与读屏名的兜底,资源卡那一档是「未命名资源」。 */
+const UNNAMED = '未命名视频';
+
/** 雪碧图里的一枚字形,写法同遗留层 `icon()`:尺寸与描边由 `./media-card.css` 按位置给。 */
function Icon({ name }: { name: string }) {
return <svg viewBox="0 0 24 24" aria-hidden="true"><use href={`#i-${name}`} /></svg>;
@@ -160,7 +163,8 @@ function VideoCard({ item, variant, layout, selected, selectMode, seekSeconds, h
const artwork = cardArtwork(item, size, false, layout.javImage);
const identity = size === 'small' ? artwork.html : cardArtwork(item, 'small', false, layout.javImage).html;
const rawName = parts?.title || item.name || '';
- const shownName = helpers.displayName(item, rawName);
+ const shownName = helpers.displayName(item, rawName).trim() || UNNAMED;
+ const titleHtml = helpers.titleHtml(item, rawName).trim() || esc(UNNAMED);
const shownSize = parts?.total_size ?? item.size;
const shownDuration = parts?.total_duration ?? item.duration;
const watched = !parts && Number(item.play_seconds) > 0 && Number(item.duration) > 0
@@ -200,9 +204,9 @@ function VideoCard({ item, variant, layout, selected, selectMode, seekSeconds, h
<div data-media-badge="" dangerouslySetInnerHTML={{ __html: helpers.badgeHtml(item.location || '', item.cost || '') }} />
<span data-media-check=""><Icon name="check" /></span>
<span data-media-trash-mark=""><Icon name="trash" /><b>回收站</b></span>
- {parts ? <span data-media-group="">{`${parts.count} 卷`}</span> : null}
+ {parts ? <span data-media-group="">{`${Number(parts.count).toLocaleString()} 卷`}</span> : null}
{editions
- ? <span data-media-group="" title={editions.editions.join(' · ')}>{`${editions.count} 个版本`}</span>
+ ? <span data-media-group="" title={editions.editions.join(' · ')}>{`${Number(editions.count).toLocaleString()} 个版本`}</span>
: null}
<span data-media-duration="">{fmtDur(shownDuration)}</span>
{watched > 0
@@ -243,7 +247,7 @@ function VideoCard({ item, variant, layout, selected, selectMode, seekSeconds, h
{avatar}
<div data-media-text="">
<button type="button" data-media-title="" data-open=""
- dangerouslySetInnerHTML={{ __html: helpers.titleHtml(item, rawName) }} />
+ dangerouslySetInnerHTML={{ __html: titleHtml }} />
<div data-media-byline="">
{who}
{item.why ? <span data-media-why="">{item.why}</span> : null}
diff --git a/frontend/src/react/entity-body/entity-body-page.tsx b/frontend/src/react/entity-body/entity-body-page.tsx
index c1f591a35..5437df2a4 100644
--- a/frontend/src/react/entity-body/entity-body-page.tsx
+++ b/frontend/src/react/entity-body/entity-body-page.tsx
@@ -69,7 +69,7 @@ const thumbSrc = (item: EntityWallPhoto) => isSample(item)
/** 墙上一格换成灯箱里的一张。本地图片整条当 asset 递进去,详情面板读来源与大小、定位读 id。 */
const wallSlide = (item: EntityWallPhoto): LightboxSlide => isSample(item)
? { src: `/sample-image?${sampleQuery(item)}`, thumb: thumbSrc(item), name: item.name, asset: null,
- source: item.source, position: item.position, total: item.total }
+ source: item.source }
: { src: `/photo?id=${item.id}`, thumb: thumbSrc(item), name: item.name || '', asset: item };
/** 照片视图:名下每部作品的官方样张按发行日从新到旧一段一段铺在前面,每段一行段头;本地图片
diff --git a/frontend/src/react/follow-detail/follow-detail.ts b/frontend/src/react/follow-detail/follow-detail.ts
index d7739e65c..9163b95f2 100644
--- a/frontend/src/react/follow-detail/follow-detail.ts
+++ b/frontend/src/react/follow-detail/follow-detail.ts
@@ -240,19 +240,18 @@ const sized = (media: FollowDetailMedia | null) => (media?.size ? { size: media.
export function detailSlides(item: FollowDetailItem, media: DetailMedia): LightboxSlide[] {
const { images, kind, src, selected } = media;
if (images.length) {
- return images.map((image, index) => ({
+ return images.map((image) => ({
src: `/follow-stream?id=${item.id}&media=${image.index}`,
thumb: image.thumb_url || item.thumb_url || `/follow-stream?id=${item.id}&media=${image.index}`,
name: image.name || item.title, source: mediaSourceLabel(image, item), ...sized(image),
- position: index + 1, total: images.length,
}));
}
if (kind === 'image' && src) {
return [{ src, thumb: item.thumb_url || src, name: item.title, source: mediaSourceLabel(selected, item),
- ...sized(selected), position: 1, total: 1 }];
+ ...sized(selected) }];
}
return item.thumb_url ? [{ src: item.thumb_url, thumb: item.thumb_url, name: item.title,
- source: item.provider_label || item.provider || '在线图片', position: 1, total: 1 }] : [];
+ source: item.provider_label || item.provider || '在线图片' }] : [];
}
/* ── 写完之后 ── */
diff --git a/frontend/src/react/immerse/immerse-island.tsx b/frontend/src/react/immerse/immerse-island.tsx
index b0f7bbf31..9471f5816 100644
--- a/frontend/src/react/immerse/immerse-island.tsx
+++ b/frontend/src/react/immerse/immerse-island.tsx
@@ -623,7 +623,7 @@ function Caption({ shown }: { shown: Shown | null }) {
<a href="#" onClick={openOwner}>{owner?.who ?? ''}</a>
<span>{shown && item ? `· ${fmtDur(item.duration)} · ${item.ctx_orient || ''} · ${shown.index + 1}/${shown.length}` : ''}</span>
</div>
- <button type="button" data-immerse-title="" onClick={openTitle}>{item ? helpers.displayName(item) : ''}</button>
+ <button type="button" data-immerse-title="" onClick={openTitle}>{item ? helpers.displayName(item).trim() || '未命名视频' : ''}</button>
</div>
);
}
diff --git a/frontend/src/react/immerse/immerse.css b/frontend/src/react/immerse/immerse.css
index 3398459d0..fab71223f 100644
--- a/frontend/src/react/immerse/immerse.css
+++ b/frontend/src/react/immerse/immerse.css
@@ -71,8 +71,9 @@ body[data-immerse-open]{overflow:hidden}
[data-immerse-bar]:hover::before,[data-immerse-bar]:hover i,
[data-immerse-bar][data-scrubbing]::before,[data-immerse-bar][data-scrubbing] i{height:9px}
[data-immerse-author]{display:flex;align-items:center;gap:10px;margin-bottom:12px;font-size:var(--fs-md);line-height:1.2}
-[data-immerse-author]>a{color:#f1f1f1;font-weight:600;text-decoration:none;pointer-events:auto}
-[data-immerse-author]>a:hover{color:var(--tungsten);text-decoration:none}[data-immerse-author]>span{color:#aaa;font-size:var(--fs-sm)}
+/* 作者名单行省略、元信息不折:十几位共演时名字收成一截,「· 时长 · 横屏 · 序号」照旧排在后面。 */
+[data-immerse-author]>a{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#f1f1f1;font-weight:600;text-decoration:none;pointer-events:auto}
+[data-immerse-author]>a:hover{color:var(--tungsten);text-decoration:none}[data-immerse-author]>span{flex:none;white-space:nowrap;color:#aaa;font-size:var(--fs-sm)}
[data-immerse-avatar]{position:relative;width:40px;height:40px;flex:none;overflow:hidden;border:0;border-radius:50%;padding:0;
background:#333;color:#f1f1f1;cursor:pointer;pointer-events:auto}
[data-immerse-avatar] img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block}
diff --git a/frontend/src/react/item-detail/item-detail-page.tsx b/frontend/src/react/item-detail/item-detail-page.tsx
index 23d35a548..813cc8f37 100644
--- a/frontend/src/react/item-detail/item-detail-page.tsx
+++ b/frontend/src/react/item-detail/item-detail-page.tsx
@@ -41,6 +41,9 @@ const Glyph = ({ name }: { name: string }) => (
);
const Html = ({ html }: { html: string }) => <span className="contents" dangerouslySetInnerHTML={{ __html: html }} />;
+/** 文件大小:没记下或记成 0 的写「大小未知」,同卡片上那一格。 */
+const sizeText = (size: unknown) => (Number(size) > 0 ? fmtSize(Number(size)) : '大小未知');
+
export function ItemDetailPage(props: ItemDetailProps) {
const { queue: ref, actions } = props;
const queueResult = useQuery({
@@ -135,7 +138,7 @@ function MediaFrame({ item, gate, helpers, actions }: {
) : gate === 'metered' && !started ? (
<div id="gate" data-item-gate="metered" onClick={() => setStarted('clicked')}>
<Html html={badge} />
- <span>点此开始拉流 · {fmtSize(item.size || 0)}</span>
+ <span>点此开始拉流 · {sizeText(item.size)}</span>
</div>
) : null}
</div>
@@ -308,8 +311,10 @@ function Side({ item, queue, write, helpers, actions }: {
{online ? null : <span data-title-state="" aria-live="polite">{write.sourceState}</span>}
<Rating item={item} write={write} />
<div className="mono" data-stage-meta="" data-reveal-line="">
- <span data-spec-item=""><Glyph name="monitor" /><span>{item.width || '?'}×{item.height || '?'}</span></span>
- <span data-spec-item=""><Glyph name="hard-drive" /><span>{fmtSize(item.size || 0)}</span></span>
+ {item.width && item.height
+ ? <span data-spec-item=""><Glyph name="monitor" /><span>{item.width}×{item.height}</span></span>
+ : null}
+ <span data-spec-item=""><Glyph name="hard-drive" /><span>{sizeText(item.size)}</span></span>
{item.release_date ? <span data-spec-item=""><Glyph name="calendar" /><span>{item.release_date}</span></span> : null}
{item.region_label ? (
<button type="button" data-spec-item="" data-open-region={item.region || ''}
@@ -530,7 +535,7 @@ function Tags({ item, write, helpers, actions }: {
<div data-stage-tags="" id="detailTags" data-item-tags="">
{tags.map((tag) => (
<span key={tag.k} data-detail-tag="">
- <button type="button" data-tag={tag.k} onClick={() => actions.openTag(tag.k)}>{helpers.tagLabel(tag.k)}</button>
+ <button type="button" data-tag={tag.k} title={helpers.tagLabel(tag.k)} onClick={() => actions.openTag(tag.k)}>{helpers.tagLabel(tag.k)}</button>
<button type="button" data-remove-tag={tag.k} title="从此视频隐藏该标签"
aria-label={`删除标签 ${helpers.tagLabel(tag.k)}`} {...write.busyAttrs(`tag:${tag.k}`)}
onClick={() => write.removeTag(tag)}><Glyph name="x" /></button>
diff --git a/frontend/src/react/item-detail/item-detail.css b/frontend/src/react/item-detail/item-detail.css
index cbadd476a..fbfc340de 100644
--- a/frontend/src/react/item-detail/item-detail.css
+++ b/frontend/src/react/item-detail/item-detail.css
@@ -14,6 +14,15 @@
* 有两处的类不是岛挂的:来源徽标由壳的 `badgeHtml` 画成 `srcbig`,选择器收起时由
* `dismissMenu` 挂上 `leaving`。这两处用 `[class~=…]` 认,权重和类选择器相同。 */
+/* 作品与队列都没取到时,播放器格里只有那条重试提示:格子照播放器的 16:9 撑开,提示居中,
+ 不塌成一条压着提示的窄条。 */
+.peach-react [data-item-detail] [data-item-placeholder] {
+ display: grid;
+ place-items: center;
+ aspect-ratio: 16 / 9;
+ padding: 16px;
+}
+
/* ── 播放区:没挂载、在线与计费三种说明块 ──
说明块铺满播放器格,不上下留黑;圆角跟着格走(格只圆左上角,右边贴着侧栏)。 */
.peach-react [data-item-detail] [data-item-gate] {
@@ -58,7 +67,8 @@
这一层,`min-width:0` 才让中段省略照旧按剩余宽度算。 */
.peach-react [data-item-detail] [data-queue-head] { display: flex; align-items: center; gap: 5px; margin-top: 0; color: var(--ink); }
.peach-react [data-item-detail] [data-queue-head] b { flex: 1; min-width: 0; }
-.peach-react [data-item-detail] [data-queue-edition] { flex: none; font-style: normal; }
+/* 版本字样最多占一半:长字样自己省略,番号总留得下。 */
+.peach-react [data-item-detail] [data-queue-edition] { flex: 0 1 auto; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-style: normal; }
/* 播放列表的顺序靠拖,每格右上角只剩抓手和移出,压在缩略图上,深色半透明底。 */
.peach-react [data-item-detail] [data-queue-edit] {
position: absolute;
@@ -346,9 +356,11 @@
background: var(--tag-fill);
overflow: hidden;
min-height: 30px;
+ max-width: 100%;
}
.peach-react [data-item-detail] [data-detail-tag] button { border: 0; background: transparent; color: var(--ink-2); cursor: pointer; height: 28px; }
-.peach-react [data-item-detail] [data-detail-tag] [data-tag] { padding: 3px 8px; }
+/* 长标签单行省略:按钮高度定死 28px,折成两行时第二行会被切掉一半。全名在 title 上。 */
+.peach-react [data-item-detail] [data-detail-tag] [data-tag] { min-width: 0; padding: 3px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peach-react [data-item-detail] [data-detail-tag] [data-remove-tag] { width: 28px; padding: 0; display: grid; place-items: center; color: var(--muted); }
.peach-react [data-item-detail] [data-detail-tag] [data-tag]:hover { background: var(--hover); color: var(--ink); }
.peach-react [data-item-detail] [data-detail-tag] [data-remove-tag]:hover {
diff --git a/frontend/src/react/item-detail/item-detail.ts b/frontend/src/react/item-detail/item-detail.ts
index 1989d1d4f..9c9ada487 100644
--- a/frontend/src/react/item-detail/item-detail.ts
+++ b/frontend/src/react/item-detail/item-detail.ts
@@ -433,14 +433,16 @@ const QUEUE_LABEL: Record<QueueKind, string> = { mix: 'Mix', parts: '分卷', ed
* 标题栏又已经写着「版本」——三处说同一件事,这里只留数量。别的队列标题带真信息(播放列表名、
* Mix 种子),不能一起砍。 */
export function queueCopy(queue: DetailQueue): { title: string; summary: string } {
- const count = queue.items.length;
+ const count = queue.items.length.toLocaleString();
const countLabel = queue.kind === 'parts' ? `${count} 卷` : queue.kind === 'editions' ? `${count} 个版本` : `${count} 个视频`;
return { title: QUEUE_LABEL[queue.kind], summary: queue.kind === 'editions' ? countLabel : `${queue.title} · ${countLabel}` };
}
/** 同一部片的几卷共用文件名,标题、女优、厂牌逐字相同:详情标题不写卷号的话,在队列里换一卷,
- * 右侧整栏看上去纹丝不动。卷号说的是「第几份文件」而不是版次,用中性灰。 */
-export const partLabel = (label = '') => /^(?:\d+|[a-h])$/i.test(label) ? `第 ${label} 卷` : label;
+ * 右侧整栏看上去纹丝不动。卷号说的是「第几份文件」而不是版次,用中性灰。数字卷写「第 2 卷」,
+ * 字母卷照番号分卷后缀的写法大写成「A 卷」。 */
+export const partLabel = (label = '') => /^\d+$/.test(label) ? `第 ${label} 卷`
+ : /^[a-h]$/i.test(label) ? `${label.toUpperCase()} 卷` : label;
export const partLabelHtml = (item: DetailItem, queue: DetailQueue | null) =>
(queue?.kind === 'parts' && item.part_label ? `<small class="javedition partlabel">${esc(partLabel(item.part_label))}</small>` : '');
diff --git a/frontend/src/react/photo-lightbox/photo-lightbox-dialog.tsx b/frontend/src/react/photo-lightbox/photo-lightbox-dialog.tsx
index 8d8ee8dd4..c7e2dbdf1 100644
--- a/frontend/src/react/photo-lightbox/photo-lightbox-dialog.tsx
+++ b/frontend/src/react/photo-lightbox/photo-lightbox-dialog.tsx
@@ -81,6 +81,8 @@ function PhotoLightbox({ slides, index, Swiper, host: actions }: {
/* 大图的自然尺寸,到了才知道:面板上的分辨率读它。取不到原图的那几张换成缩略图。 */
const [natural, setNatural] = useState<Record<number, [number, number]>>({});
const [broken, setBroken] = useState<ReadonlySet<number>>(() => new Set());
+ /** 原图和缩略图都取不到的那几张:放一块占位,不露浏览器的破图标。 */
+ const [lost, setLost] = useState<ReadonlySet<number>>(() => new Set());
const [busy, setBusy] = useState(false);
const [status, setStatus] = useState<{ at: number; text: string }>({ at: index, text: '' });
@@ -181,9 +183,12 @@ function PhotoLightbox({ slides, index, Swiper, host: actions }: {
zoom.current?.loaded(img);
};
// 原图取不到时换上这张的缩略图:归档站的原文件主机会拦下代理(pawchive 的 file.
- // 子域挂着 ddos-guard),缩略图由浏览器直接读公开主机。只换一次。
+ // 子域挂着 ddos-guard),缩略图由浏览器直接读公开主机。只换一次,缩略图也取不到就放占位。
const failed = (at: number) => {
- if (broken.has(at) || !slides[at].thumb || slides[at].thumb === slides[at].src) return;
+ if (broken.has(at) || !slides[at].thumb || slides[at].thumb === slides[at].src) {
+ setLost((prev) => new Set(prev).add(at));
+ return;
+ }
setBroken((prev) => new Set(prev).add(at));
};
const apply = (raw: number | 'fit') => zoom.current?.apply(raw);
@@ -207,9 +212,11 @@ function PhotoLightbox({ slides, index, Swiper, host: actions }: {
{slides.map((item, at) => (
<div key={at} className="swiper-slide">
<div className="swiper-zoom-container">
- <img src={broken.has(at) ? item.thumb : item.src} alt={item.name ?? ''} loading="lazy"
- referrerPolicy="no-referrer" onLoad={(event) => loaded(at, event.currentTarget)}
- onError={() => failed(at)} />
+ {lost.has(at)
+ ? <span data-photo-missing="">图片取不到</span>
+ : <img src={broken.has(at) ? item.thumb : item.src} alt={item.name ?? ''} loading="lazy"
+ referrerPolicy="no-referrer" onLoad={(event) => loaded(at, event.currentTarget)}
+ onError={() => failed(at)} />}
</div>
</div>
))}
diff --git a/frontend/src/react/photo-lightbox/photo-lightbox.css b/frontend/src/react/photo-lightbox/photo-lightbox.css
index 94b96ef02..47871053d 100644
--- a/frontend/src/react/photo-lightbox/photo-lightbox.css
+++ b/frontend/src/react/photo-lightbox/photo-lightbox.css
@@ -182,6 +182,17 @@
/* ── 底部工具条 ──
* 详情、页码和缩放操作统一落在底部;多图时整体抬到缩略图条上方。 */
+/* 原图与缩略图都取不到时那一张的占位:一块暗面写一句话,字色同底栏。 */
+.peach-react [data-photo-missing] {
+ display: grid;
+ place-items: center;
+ width: min(480px, 80vw);
+ aspect-ratio: 4 / 3;
+ border-radius: var(--surface-radius);
+ background: rgba(255, 255, 255, .06);
+ color: rgba(255, 255, 255, .62);
+ font-size: var(--fs-sm);
+}
.peach-react [data-photo-bar] {
position: absolute;
right: 14px;
@@ -209,6 +220,7 @@
font-family: "Cascadia Mono", Consolas, ui-monospace, "Microsoft YaHei UI", "PingFang SC", monospace;
font-size: var(--fs-xs);
font-variant-numeric: tabular-nums;
+ white-space: nowrap;
backdrop-filter: blur(16px);
}
@@ -541,6 +553,12 @@
right: 8px;
}
}
+/* 手机最窄那一档放不下「1286 / 1289」加整条缩放:滑条收起,缩放只剩加减键、适应与 1:1。 */
+@media (max-width: 400px) {
+ .peach-react [data-photo-zoom] input {
+ display: none;
+ }
+}
@media (prefers-reduced-motion: reduce) {
.peach-react [data-photo-pagination] .swiper-pagination-bullet {
diff --git a/frontend/src/react/photo-lightbox/photo-lightbox.ts b/frontend/src/react/photo-lightbox/photo-lightbox.ts
index 71f2e2858..30d6fe2dc 100644
--- a/frontend/src/react/photo-lightbox/photo-lightbox.ts
+++ b/frontend/src/react/photo-lightbox/photo-lightbox.ts
@@ -24,9 +24,6 @@ export interface LightboxSlide {
/** 没有 asset 时信息面板第一段:站名或「官方样张」,缺省是「在线图片」。 */
source?: string;
size?: number;
- /** 在所属那一组里的序号与张数,多于一张时面板写「第 n / N 张」。 */
- position?: number;
- total?: number;
}
/** 灯箱要回壳办的事。定位成功由壳发回执,失败回一句原因,写在按钮下面。 */
@@ -136,12 +133,11 @@ export const fmtPhotoSize = (raw: unknown): string => {
export const photoTitle = (slide: LightboxSlide): string => (slide.asset?.name || slide.name) || '未命名图片';
-/** 面板第二行。本地图是来源与大小;别的是来源、序号、分辨率(大图到了才有)和大小。 */
+/** 面板第二行。本地图是来源与大小;别的是来源、分辨率(大图到了才有)和大小。第几张只有底栏那一个编号。 */
export function photoMeta(slide: LightboxSlide, natural: readonly [number, number] | undefined): string {
const asset = slide.asset;
if (asset) return [LOC[asset.location ?? ''] || asset.location || '来源未知', fmtPhotoSize(asset.size)].join(' · ');
- const sequence = (slide.total ?? 0) > 1 ? `第 ${slide.position} / ${slide.total} 张` : '';
const resolution = natural?.[0] && natural[1] ? `${natural[0]} × ${natural[1]}` : '';
- return [slide.source || '在线图片', sequence, resolution, slide.size ? fmtPhotoSize(slide.size) : '']
+ return [slide.source || '在线图片', resolution, slide.size ? fmtPhotoSize(slide.size) : '']
.filter(Boolean).join(' · ');
}
diff --git a/frontend/src/react/playlists/playlists-page.tsx b/frontend/src/react/playlists/playlists-page.tsx
index 1da0bdda0..fbf261f35 100644
--- a/frontend/src/react/playlists/playlists-page.tsx
+++ b/frontend/src/react/playlists/playlists-page.tsx
@@ -23,9 +23,9 @@ import { cx } from '@/utils/cx';
import { errorMessage } from '../../api';
import type { PlaylistsProps } from '../bundle';
import { EmptyState } from '../components/empty-state';
+import { RetryNote } from '../components/grid-reveal';
import { MixCard } from '../components/mix-card';
import { ModalFrame } from '../components/modal-frame';
-import { Note } from '../components/note';
import { spriteGlyph } from '../components/sprite-glyph';
import { busyProps } from '../settings/use-action';
import {
@@ -174,14 +174,7 @@ export function PlaylistsPage({ openPlaylist, openEntity, canFlip, toast, revisi
}, [revision]);
const data = playlists.data;
- if (!data) {
- return (
- <div className="mx-auto w-full max-w-board">
- <Note tone="error" title="播放列表读取失败">{playlists.error ? errorMessage(playlists.error) : '未取得播放列表,请刷新页面重试。'}</Note>
- </div>
- );
- }
- const items = data.items ?? [];
+ const items = data?.items ?? [];
const remove = (row: PlaylistRow) => {
void confirmModal({
@@ -206,21 +199,27 @@ export function PlaylistsPage({ openPlaylist, openEntity, canFlip, toast, revisi
</div>
<CreateForm toast={toast} />
</header>
- {items.length
+ {/* 读取失败时页头与新建框照常在,提示与重试键落在列表的位置上。 */}
+ {!data
+ ? (playlists.isError
+ ? <RetryNote message={errorMessage(playlists.error) || '播放列表读取失败'} onRetry={() => void playlists.refetch()} />
+ : null)
+ : items.length
? (
<div data-playlist-grid="" className="card-grid-cover gap-4.5">
{items.map((row) => {
const resume = resumeAssetId(row);
+ const name = row.name.trim() || '未命名播放列表';
return (
- <MixCard key={row.id} data-playlist-card={String(row.id)} name={row.name}
+ <MixCard key={row.id} data-playlist-card={String(row.id)} name={name}
caption={row.source_kind === 'mix' ? '由 Mix 保存' : '手动播放列表'}
count={row.item_count}
poster={row.preview_asset_id ? posterUrl(row.preview_asset_id) : null}
flipImages={async () => (row.preview_ids || []).map(posterUrl)}
canFlip={canFlip} faces={row.faces || []} onOpenEntity={openEntity}
{...(resume ? { onOpen: () => openPlaylist(row.id, resume) } : {})}
- openLabel={`打开播放列表 ${row.name}`}
- menu={<PlaylistMenu name={row.name} onRename={() => setRenaming(row)} onDelete={() => remove(row)} />} />
+ openLabel={`打开播放列表 ${name}`}
+ menu={<PlaylistMenu name={name} onRename={() => setRenaming(row)} onDelete={() => remove(row)} />} />
);
})}
</div>
diff --git a/frontend/src/react/search/search-page.tsx b/frontend/src/react/search/search-page.tsx
index e841f0b59..faad9490c 100644
--- a/frontend/src/react/search/search-page.tsx
+++ b/frontend/src/react/search/search-page.tsx
@@ -50,7 +50,7 @@ const modelOf = (s: Store): MenuModel => menuModel({
query: s.query, history: s.history, picks: s.picks, suggestFor: s.suggestFor, groups: s.groups, tabs: s.tabs,
kind: s.kind,
});
-const hasContent = (m: MenuModel) => !!(m.tabs || m.recent || m.left.length || m.right.length);
+const hasContent = (m: MenuModel) => !!(m.tabs || m.recent || m.left.length || m.right.length || m.empty);
const Sprite = ({ name }: { name: string }) => (
<svg viewBox="0 0 24 24" aria-hidden="true"><use href={`#i-${name}`} /></svg>
@@ -125,6 +125,7 @@ export function SearchPage(props: SearchProps) {
{model.tabs ? <Tabs tabs={model.tabs} kind={s.kind} onPick={op.pickKind} wire={props.helpers.wireScroller} /> : null}
{model.recent ? section(model.recent) : null}
{columns(model.left, model.right)}
+ {model.empty ? <p data-search-empty="" role="status">没有找到</p> : null}
</div>
);
}
@@ -377,7 +378,7 @@ function Row({ entry, active, helpers, onPick, onPeek, onRemove }: {
return (
<div data-search-option="work" data-open-item={item.id} {...shared}>
<Cover card={item.card} helpers={helpers} />
- <span data-search-meta=""><span data-search-name="">{item.value}</span><span data-search-sub="">{byline}</span></span>
+ <span data-search-meta=""><span data-search-name=""><span>{item.value}</span></span><span data-search-sub="">{byline}</span></span>
</div>
);
}
diff --git a/frontend/src/react/search/search.css b/frontend/src/react/search/search.css
index 521634408..eb41fda96 100644
--- a/frontend/src/react/search/search.css
+++ b/frontend/src/react/search/search.css
@@ -23,6 +23,10 @@
letter-spacing: .14em;
}
+/* 这个词一条补全都没有时的那一行,排在搜索记录下面,字色同组标题。 */
+.peach-react [data-search-empty] { margin: 0; padding: 9px 10px; color: var(--muted); font-size: var(--fs-sm); }
+.peach-react [data-search-group] + [data-search-empty] { border-top: 1px solid var(--line-soft); margin-top: 7px; }
+
.peach-react [data-search-option] {
width: 100%;
height: 38px;
@@ -137,9 +141,9 @@
.peach-react [data-search-sub] { color: var(--muted); font-size: var(--fs-xs); }
/* 小封面和卡片同一个 3:4 容器(壳给的 `.pic`,比例从这里继承),取景换算读的就是这个比例。
- * 宽 36 刚好排下不加字距的「无预览」:封面那一格里只有它是 span,图都是 <img>。 */
+ * 「无预览」在 36px 宽里按 10px、不加字距排,三个字两边各留一点边:封面那一格里只有它是 span,图都是 <img>。 */
.peach-react [data-search-pic] { --card-ratio: .75; display: block; flex: none; border-radius: var(--badge-radius); }
-.peach-react [data-search-pic] > span > span { letter-spacing: 0; }
+.peach-react [data-search-pic] > span > span { font-size: 10px; letter-spacing: 0; }
.peach-react [data-search-option="work"] > [data-search-pic] { width: 36px; }
/* 行里的 span 一律截断裁切,这一排要让出焦点环。 */
.peach-react [data-search-option] [data-search-peeks] {
diff --git a/frontend/src/react/search/search.ts b/frontend/src/react/search/search.ts
index bb816b503..cad184bd4 100644
--- a/frontend/src/react/search/search.ts
+++ b/frontend/src/react/search/search.ts
@@ -126,6 +126,8 @@ export interface MenuModel {
/** 两栏:左栏身份和词,右栏作品。空输入时是记录与推荐两组短词。 */
left: MenuSection[];
right: MenuSection[];
+ /** 这个词的补全已经回来、一条都没有:栏里写一行「没有找到」,分得清是没结果还是还没搜。 */
+ empty: boolean;
options: SearchOption[];
}
@@ -156,7 +158,7 @@ export function menuModel({ query, history, picks, suggestFor, groups, tabs, kin
if (!query) {
const recent = matching.length ? { label: '搜索记录', options: matching.map((value) => add({ type: 'history', value })) } : null;
const suggested = picks.length ? { label: '推荐', options: picks.map((value) => add({ type: 'pick', value })) } : null;
- return { tabs: null, recent: null, left: recent ? [recent] : [], right: suggested ? [suggested] : [], options };
+ return { tabs: null, recent: null, left: recent ? [recent] : [], right: suggested ? [suggested] : [], empty: false, options };
}
const fresh = suggestFor === query;
const recent = !kind && matching.length
@@ -169,7 +171,8 @@ export function menuModel({ query, history, picks, suggestFor, groups, tabs, kin
});
const left = shown.filter((group) => !SUGGEST_RIGHT_KINDS.has(group.kind)).map(section);
const right = shown.filter((group) => SUGGEST_RIGHT_KINDS.has(group.kind)).map(section);
- return { tabs: fresh && tabs.length > 1 ? [...tabs] : null, recent, left, right, options };
+ const empty = fresh && !shown.some((group) => group.items.length);
+ return { tabs: fresh && tabs.length > 1 ? [...tabs] : null, recent, left, right, empty, options };
}
/** 空输入时从词池里洗出几条推荐,搜过的不再推。每画一次下拉栏洗一次;删一条记录不算重画,
diff --git a/frontend/src/react/stage/stage.css b/frontend/src/react/stage/stage.css
index 79e48bceb..d00e8b314 100644
--- a/frontend/src/react/stage/stage.css
+++ b/frontend/src/react/stage/stage.css
@@ -140,7 +140,7 @@ body[data-detail-open] [class~=glowlayer]::before{animation-play-state:paused,pa
图片详情和合集详情右侧的背景一起截短。所有详情分支共用这层结构。 */
[data-stage-side-content]{box-sizing:border-box;width:100%;height:100%;max-height:76vh;padding:18px;display:flex;gap:0;
flex-direction:column;overflow-y:auto;overflow-x:hidden}
-[data-stage-title]{font-size:var(--fs-lg);line-height:1.4;word-break:break-all;margin-bottom:8px}
+[data-stage-title]{font-size:var(--fs-lg);line-height:1.4;overflow-wrap:anywhere;margin-bottom:8px}
[data-stage-meta]{display:flex;gap:9px;flex-wrap:wrap;color:var(--muted);margin-bottom:18px}
[data-stage-tags]{position:relative;display:flex;flex-wrap:wrap;align-items:center;gap:7px;margin:0 0 18px}
[data-stage-actions]{display:flex;align-items:center;gap:0;margin:0 0 12px;padding:0;border:1px solid var(--border-10);border-radius:var(--control-radius);background:var(--overlay-5);width:max-content;overflow:hidden;flex:none}
diff --git a/frontend/test/react/catalog-filter.test.tsx b/frontend/test/react/catalog-filter.test.tsx
index 7fa294ac1..155bac04b 100644
--- a/frontend/test/react/catalog-filter.test.tsx
+++ b/frontend/test/react/catalog-filter.test.tsx
@@ -44,6 +44,18 @@ describe('空馆藏', () => {
});
});
+describe('读数', () => {
+ it('取数期间是一条微光;这一趟失败时收起,不留着一直转的微光', async () => {
+ const waiting = await mount(<CatalogFilterPage {...props({ count: null })} />);
+ expect(count(waiting, '[data-skeleton="count"]')).toBe(1);
+ document.body.innerHTML = '';
+ const failed = await mount(<CatalogFilterPage {...props({ count: false })} />);
+ expect(count(failed, '[data-skeleton="count"]')).toBe(0);
+ expect(count(failed, '[data-count-readout]')).toBe(0);
+ expect(failed.querySelector('[data-catalog-readout]')?.textContent).toBe('');
+ });
+});
+
describe('续页', () => {
it('上一份名单要的那页还在路上时换了名单,新名单照样续页,旧的那页回来不进这一排', async () => {
// 一排一枚铺不满一行:没溢出就一直停在右端,每次画完都要下一页。
diff --git a/frontend/test/react/catalog-grid.test.tsx b/frontend/test/react/catalog-grid.test.tsx
index e4284071c..d62836e3b 100644
--- a/frontend/test/react/catalog-grid.test.tsx
+++ b/frontend/test/react/catalog-grid.test.tsx
@@ -169,6 +169,12 @@ describe('作品卡', () => {
expect([plain.onOpen, selecting.onOpen].every((fn) => fn.mock.calls.length === 0)).toBe(true);
});
+ it('片名空着时标题与读屏名写「未命名视频」', async () => {
+ const { host } = await render(item(12, { name: '' }));
+ expect(host.querySelector('[data-media-title]')?.textContent).toBe('未命名视频');
+ expect(host.querySelector('[data-media-open]')?.getAttribute('aria-label')).toBe('打开 未命名视频详情');
+ });
+
it('大小不明写「大小未知」,看过几次写出来,标签取作品自己的标签、至多三枚', async () => {
const { host } = await render(item(11, { size: 0, play_count: 3, performers: ['甲'], tags: ['a', 'b', 'c', 'd'] }));
expect(host.querySelector('[data-media-size]')?.textContent).toBe('大小未知');
diff --git a/frontend/test/react/entity-body.test.tsx b/frontend/test/react/entity-body.test.tsx
index 1173d5c16..fe7f7b449 100644
--- a/frontend/test/react/entity-body.test.tsx
+++ b/frontend/test/react/entity-body.test.tsx
@@ -183,7 +183,7 @@ describe('照片墙', () => {
expect(slides).toHaveLength(7);
expect(slides[3]).toEqual({
src: '/sample-image?code=SSIS-001&n=1', thumb: '/sample-thumb?code=SSIS-001&n=1', name: 'SSIS-001 样张 1',
- asset: null, source: 'DMM', position: 1, total: 2,
+ asset: null, source: 'DMM',
});
expect(slides[5]).toEqual({
src: '/photo?id=101', thumb: '/photo-thumb?id=101', name: '101.jpg', asset: { id: 101, name: '101.jpg' },
diff --git a/frontend/test/react/immerse.test.tsx b/frontend/test/react/immerse.test.tsx
index 7f28c2237..5b0d085f3 100644
--- a/frontend/test/react/immerse.test.tsx
+++ b/frontend/test/react/immerse.test.tsx
@@ -295,6 +295,13 @@ describe('片单与起播', () => {
expect(gets(fetcher, '/api/item?id=')).toBe(1);
});
+ it('片名空着时标题写「未命名视频」', async () => {
+ serve({ draws: [[1, 2, 3].map((id) => row(id))] });
+ host.displayName.mockImplementation(() => '');
+ await open(1);
+ expect(q('[data-immerse-title]')!.textContent).toBe('未命名视频');
+ });
+
it('深链的那一条不在这一批里:取它的详情插到最前,地址栏落回同一条', async () => {
const fetcher = serve({ draws: [[1, 2, 3, 4, 5, 6].map((id) => row(id))] });
await open(42);
diff --git a/frontend/test/react/item-detail.test.tsx b/frontend/test/react/item-detail.test.tsx
index f31fbf514..2ef84b626 100644
--- a/frontend/test/react/item-detail.test.tsx
+++ b/frontend/test/react/item-detail.test.tsx
@@ -122,10 +122,24 @@ describe('停在队列哪一条', () => {
expect(host.textContent).not.toContain('第 特典');
});
+ it('字母分卷照番号后缀大写成「A 卷」', async () => {
+ serve();
+ const ref = { kind: 'parts', seedId: 1 } as const;
+ queryClient.setQueryData(queueKey(ref), queue('parts', [1, 2], {
+ items: [row(1, { part_label: 'a' }), row(2, { part_label: 'B' })],
+ }));
+ const { host } = await show(item(1), { queue: ref });
+ expect(host.querySelector('[data-queue-item="1"]')?.textContent).toContain('A 卷');
+ expect(host.querySelector('[data-queue-item="2"]')?.textContent).toContain('B 卷');
+ expect(host.textContent).not.toContain('第 a 卷');
+ });
+
it('队列头:版次队列只写数量,其余带上标题', () => {
expect(queueCopy(queue('editions', [1, 2]))).toEqual({ title: '版本', summary: '2 个版本' });
expect(queueCopy(queue('parts', [1, 2, 3], { title: '分卷 · PCH-021' }))).toEqual({ title: '分卷', summary: '分卷 · PCH-021 · 3 卷' });
expect(queueCopy(queue('playlist', [1], { title: '周末片单' }))).toEqual({ title: '播放列表', summary: '周末片单 · 1 个视频' });
+ const many = Array.from({ length: 1284 }, (_, i) => i + 1);
+ expect(queueCopy(queue('parts', many, { title: '分卷' })).summary).toBe('分卷 · 1,284 卷');
});
it('拖动之后的新顺序:挪到目标前面或后面', () => {
@@ -409,6 +423,13 @@ describe('侧栏怎么读', () => {
expect(host.querySelector('#ratioTxt')?.textContent).toBe('0%');
});
+ it('没有宽高时规格行不写分辨率,大小没记下写「大小未知」', async () => {
+ serve();
+ const { host } = await show(item(1, { width: null, height: null, size: 0 } as Partial<DetailItem>));
+ expect([...host.querySelectorAll('[data-stage-meta] [data-spec-item]')].map(glyph)).toEqual(['#i-hard-drive']);
+ expect(host.querySelector('[data-stage-meta]')?.textContent).toBe('大小未知');
+ });
+
it('身份按类分组、组标题在上;没有实体 id 的只写名字;厂牌装了标识才要 icon 变体;系列是带图标的链接', async () => {
serve();
const { host, actions: done } = await show(item(1, {
diff --git a/frontend/test/react/photo-lightbox.test.tsx b/frontend/test/react/photo-lightbox.test.tsx
index fadaed176..dd362984a 100644
--- a/frontend/test/react/photo-lightbox.test.tsx
+++ b/frontend/test/react/photo-lightbox.test.tsx
@@ -84,11 +84,11 @@ const local = (id: number, extra: Record<string, unknown> = {}): LightboxSlide =
src: `/photo?id=${id}`, thumb: `/photo-thumb?id=${id}`, name: `${id}.jpg`,
asset: { id, name: `${id}.jpg`, location: 'local', size: 2 * 1024 * 1024, ...extra },
});
-const sample = (n: number, total: number): LightboxSlide => ({
+const sample = (n: number): LightboxSlide => ({
src: `/sample-image?code=SSIS-057&n=${n}`, thumb: `/sample-thumb?code=SSIS-057&n=${n}`,
- name: `SSIS-057 样张 ${n}`, asset: null, source: 'DMM', position: n, total,
+ name: `SSIS-057 样张 ${n}`, asset: null, source: 'DMM',
});
-const WALL = [sample(1, 2), sample(2, 2), local(100), local(101), local(102)];
+const WALL = [sample(1), sample(2), local(100), local(101), local(102)];
const q = <T extends Element = HTMLElement>(box: Element, selector: string) => box.querySelector<T>(selector)!;
const labelled = (box: Element, label: string) => q<HTMLButtonElement>(box, `[aria-label="${label}"]`);
@@ -204,13 +204,15 @@ describe('翻页', () => {
expect(q(box, '[data-photo-detail] h2').textContent).toBe('101.jpg');
});
- it('原图取不到换上这张的缩略图,只换一次', async () => {
+ it('原图取不到换上这张的缩略图,只换一次;缩略图也取不到就换成占位', async () => {
const box = await open(0, WALL);
- const img = q<HTMLImageElement>(box, '[data-photo-main] img');
+ const slide = q(box, '[data-photo-main] .swiper-slide');
+ const img = q<HTMLImageElement>(slide, 'img');
await act(async () => { img.dispatchEvent(new Event('error')) });
expect(img.getAttribute('src')).toBe('/sample-thumb?code=SSIS-057&n=1');
await act(async () => { img.dispatchEvent(new Event('error')) });
- expect(img.getAttribute('src')).toBe('/sample-thumb?code=SSIS-057&n=1');
+ expect(slide.querySelector('img')).toBeNull();
+ expect(slide.querySelector('[data-photo-missing]')?.textContent).toBe('图片取不到');
});
it('灯箱量到新尺寸就让两条轮播重量,缩放按上一次的目标重算', async () => {
@@ -365,15 +367,16 @@ describe('信息面板', () => {
expect(status.textContent).toBe('');
});
- it('样张与在线图不出定位键:写来源、第几张,大图到了补上分辨率;没名字写「未命名图片」', async () => {
- const box = await open(0, [sample(1, 2), { src: '/follow-stream?id=5&media=0', thumb: '/t.jpg', size: 3000 }]);
+ it('样张与在线图不出定位键:写来源,大图到了补上分辨率,第几张只看底栏;没名字写「未命名图片」', async () => {
+ const box = await open(0, [sample(1), { src: '/follow-stream?id=5&media=0', thumb: '/t.jpg', size: 3000 }]);
const meta = q(box, '[data-photo-detail-meta]');
expect(q<HTMLButtonElement>(box, '[data-photo-reveal]').hidden).toBe(true);
- expect(meta.textContent).toBe('DMM · 第 1 / 2 张');
+ expect(meta.textContent).toBe('DMM');
+ expect(q(box, '[data-photo-count]').textContent).toBe('1 / 2');
const img = q<HTMLImageElement>(box, '[data-photo-main] img');
Object.defineProperties(img, { naturalWidth: { value: 1600 }, naturalHeight: { value: 1200 } });
await act(async () => { img.dispatchEvent(new Event('load')) });
- expect(meta.textContent).toBe('DMM · 第 1 / 2 张 · 1600 × 1200');
+ expect(meta.textContent).toBe('DMM · 1600 × 1200');
await main().go(1);
expect(q(box, '[data-photo-detail] h2').textContent).toBe('未命名图片');
expect(meta.textContent).toBe('在线图片 · 3\u00a0KB');
diff --git a/frontend/test/react/playlists.test.tsx b/frontend/test/react/playlists.test.tsx
index 1fc3361f5..bf9f4357d 100644
--- a/frontend/test/react/playlists.test.tsx
+++ b/frontend/test/react/playlists.test.tsx
@@ -99,6 +99,22 @@ describe('首屏', () => {
expect(queryClient.getQueryData<{ items: PlaylistRow[] }>(PLAYLISTS_KEY)?.items).toHaveLength(2);
});
+ it('读取失败时页头与新建框照常在,列表的位置上是原因和重试键;重试成功后画出列表', async () => {
+ let fail = true;
+ serve({ 'GET /api/playlists': () => (fail ? { status: 500, body: { error: '数据库被锁住' } } : { body: { items: [row(1)] } }) });
+ const host = await mount(<QueryClientProvider client={queryClient}><Shell {...props()} /></QueryClientProvider>);
+ await settle();
+ expect(host.querySelector('h2')?.textContent).toBe('播放列表');
+ expect(host.querySelector('[data-playlist-create]')).not.toBeNull();
+ const note = host.querySelector('[data-media-error]')!;
+ expect(note.textContent).toContain('数据库被锁住');
+ fail = false;
+ await click(note.querySelector('[data-note-action]'));
+ await settle();
+ expect(card(host, 1)).not.toBeNull();
+ expect(host.querySelector('[data-media-error]')).toBeNull();
+ });
+
it('没有列表时是整页空态,图标取播放列表字形', async () => {
const host = await open([]);
const empty = host.querySelector('[data-empty-state]')!;
@@ -109,6 +125,12 @@ describe('首屏', () => {
});
describe('卡片', () => {
+ it('名称只有空白时标题与读屏名写「未命名播放列表」', async () => {
+ const host = await open([row(1, { name: ' ' })]);
+ expect(card(host, 1).textContent).toContain('未命名播放列表');
+ expect(card(host, 1).querySelector('[data-mix-open]')?.getAttribute('aria-label')).toBe('打开播放列表 未命名播放列表');
+ });
+
it('上千条的徽标带千分位', async () => {
const host = await open([row(1, { item_count: 98765 })]);
expect(card(host, 1).querySelector('[data-mix-badge]')?.textContent).toBe('98,765 个视频');
diff --git a/frontend/test/react/search.test.tsx b/frontend/test/react/search.test.tsx
index bf8b1eb08..8cc1f5f8d 100644
--- a/frontend/test/react/search.test.tsx
+++ b/frontend/test/react/search.test.tsx
@@ -38,6 +38,13 @@ describe('下拉栏里摆什么', () => {
expect(one.options.map((o) => o.value)).toEqual(['七海の夏']);
});
+ it('这个词的补全回来了却一条没有才算「没有找到」,还在路上的不算', () => {
+ expect(menuModel({ ...base, query: 'zzz', suggestFor: 'zzz' }).empty).toBe(true);
+ expect(menuModel({ ...base, query: 'zzz', suggestFor: 'zz' }).empty).toBe(false);
+ expect(menuModel({ ...base, query: '七海', suggestFor: '七海', groups: [performer] }).empty).toBe(false);
+ expect(menuModel({ ...base, query: '' }).empty).toBe(false);
+ });
+
it('作品一类单独排在右栏;只命中一类时没有页签', () => {
const model = menuModel({ ...base, query: 'ABW', suggestFor: 'ABW', groups: [asset], tabs: [asset] });
expect([model.left.length, model.right[0]?.kind, model.tabs]).toEqual([0, 'asset', null]);
diff --git a/web/app.js b/web/app.js
index 73caa0349..302412be0 100644
--- a/web/app.js
+++ b/web/app.js
@@ -3077,7 +3077,7 @@ function catalogGridProps(){
mix:home&&!trash,
/* JAV 模式不插竖屏带:主列表的 exclude_vertical 管不到它,它是独立请求、独立插入的。 */
shorts:home&&!javActive()&&state.orient!=='竖屏'&&!trash,
- countRow:$('#count'),onCount:paintCatalogCount,
+ countRow:$('#count'),onCount:paintCatalogCount,onCountFailed:()=>paintCatalogFilter({count:false}),
emptyHtml:({trash:inTrash,libraryEmpty})=>inTrash
?emptyState('trash','回收站是空的','删掉的内容会先到这里;确认不再需要后再清空。')
:catalogEmptyHtml({jav:javActive()&&!libraryEmpty,configurable:runtimeConfigurable,filtered:!libraryEmpty}),