Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 补齐发现筛选标签骨架与卡片指针边界

longmeidao0e53f7e54020
diff --git a/docs/JAV_DISCOVERY.md b/docs/JAV_DISCOVERY.md
index 9e150f7f6..77e69cc7d 100644
--- a/docs/JAV_DISCOVERY.md
+++ b/docs/JAV_DISCOVERY.md
@@ -4,6 +4,8 @@
卡片的版本标签保留在标题中;推荐档位、其他来源和内容标签在左对齐的一栏中展示。JAV 馆藏元信息包含人物、发行日期与文件大小。4K 根据实际媒体尺寸显示,无码与字幕标签使用已记录的版本属性,不依据封面推断。来源记录保留完整出演资料,明确登记的男优不参与展示、口味与推荐。来源头像与详情使用同一查询缓存。
+发现筛选栏等待查询时,标签和读数使用占位;范围、版式与排序控件即时显示。首屏与页面内加载态复用同一组标签占位,标签的高度和横向排列与实际控件一致。
+
已取得的公开静态头像地址保存在来源资料边车,读取头像直接复用图片下载与解码,不要求再次取得完整作品详情;带查询参数或签名的地址不保存。卡片只为进入视口的人物读取来源头像。已打开的作品详情使用六小时查询缓存,陈旧详情先显示已有资料,再后台更新。
想要清单优先显示已有查询缓存,并在需要时后台更新;待找提供「全部」「有磁链」「没磁链」分段筛选,筛选使用已保存的资源状态,不触发来源查询。
@@ -44,7 +46,7 @@
## 来源提示
-作品详情与馆藏视频共用标题折叠、人物和厂牌身份格、规格图标与标签筛选样式。人物按来源或规范资料的明确性别分为女优、男优及性别未确认的出演者;不凭姓名或头像推断。来源与评论评分按小数比例填充五颗星,来源评分同时显示原始分数;评论日期显示年月日。来源标签遵循本机归一规则和已登记分类。人物优先显示本地头像与取景,缺少本地图时可显示该作品来源名单对应的头像。
+作品详情与馆藏视频共用标题折叠、人物和厂牌身份格、规格图标与标签筛选样式。人物按来源或规范资料的明确性别分为女优及性别未确认的出演者;男优仅保留来源记录,不凭姓名或头像推断性别。来源与评论评分按小数比例填充五颗星,来源评分同时显示原始分数;评论日期显示年月日。来源标签遵循本机归一规则和已登记分类。人物优先显示本地头像与取景,缺少本地图时可显示该作品来源名单对应的头像。
封面与预览图复用关注详情的左右切换和圆点。缩略图条常驻主图下方,横向滚动并支持点击、键盘切换;只有进入可见范围的小图才读取。来源提供可信视频预览时,可切换至视频;播放器复用视频详情的播放、进度、音量、设置和全屏控件,等待用户播放,切回图片或关闭详情时停止。视频的缩略图与媒体 indicator 都在播放器下方。未提供视频入口的作品只显示图片。「作品来源」使用按钮打开新标签页。已建档厂牌打开规范资料页,未建档厂牌进入馆藏厂牌筛选;来源大小写差异和日英组合写法复用既有解析规则,投影到唯一已有身份。评论和资源通过带对象图标与箭头的标题展开、收起;详情画框按视口预留高度,右侧内容在框内滚动。想要和下载操作服从账本的实际只读状态。
diff --git a/frontend/e2e/jav-recommendations.test.ts b/frontend/e2e/jav-recommendations.test.ts
index 257befef2..2d4cc5701 100644
--- a/frontend/e2e/jav-recommendations.test.ts
+++ b/frontend/e2e/jav-recommendations.test.ts
@@ -50,6 +50,14 @@ describe('JAV 推荐与加载结构', () => {
const pendingFilter = await page.locator('[data-jav-filter]').boundingBox();
const pendingBottom = await page.locator('[data-jav-filter] [data-filter-row="bottom"]').boundingBox();
const pendingSize = await page.locator('[data-jav-filter] [data-entity-layout]').boundingBox();
+ const tagPlaceholders = page.locator('[data-jav-filter] [data-catalog-tags] [data-skeleton="tag"]');
+ assert.equal(await tagPlaceholders.count(), 6);
+ const pendingTags = await tagPlaceholders.evaluateAll(nodes => nodes.map(node => {
+ const style = getComputedStyle(node), box = node.getBoundingClientRect();
+ return { height: box.height, y: box.y, pointer: style.pointerEvents, position: style.position, overflow: style.overflow };
+ }));
+ assert.ok(pendingTags.every(chip => chip.height === (viewport.mobile ? 36 : 30) && chip.y === pendingTags[0].y && chip.pointer === 'none'), JSON.stringify(pendingTags));
+ assert.ok(pendingTags.every(chip => chip.position === 'relative' && chip.overflow === 'hidden'), '标签光效在各自占位内定位和裁切');
const avatarShape = await page.locator('[data-jav-skeleton-avatar]').first().evaluate(node => {
const style = getComputedStyle(node); return { width: style.width, height: style.height, radius: style.borderRadius };
});
@@ -105,6 +113,8 @@ describe('JAV 推荐与加载结构', () => {
const controls = await page.locator('[data-jav-filter] [data-entity-sorts]').boundingBox();
assert.ok(liveSize && controls && liveSize.x >= controls.x && liveSize.x + liveSize.width <= controls.x + controls.width);
assert.equal(await page.locator('[data-jav-filter] [data-catalog-tag]').first().evaluate(node => getComputedStyle(node).borderStyle), 'dashed');
+ assert.equal(await tagPlaceholders.count(), 0);
+ assert.equal(await page.locator('[data-jav-filter] [data-catalog-tag]').first().evaluate(node => node.getBoundingClientRect().height), pendingTags[0].height);
const heights = await cards.evaluateAll(nodes => nodes.map(node => node.getBoundingClientRect().height));
if (!viewport.mobile) assert.ok(Math.max(...heights) - Math.min(...heights) <= 1, JSON.stringify(heights));
assert.ok(skeletonCard && Math.abs(skeletonCard.height - heights[0]!) <= 2, JSON.stringify({ skeletonCard, heights }));
diff --git a/frontend/src/jav-skeleton.ts b/frontend/src/jav-skeleton.ts
index cca33bf25..2d00ba009 100644
--- a/frontend/src/jav-skeleton.ts
+++ b/frontend/src/jav-skeleton.ts
@@ -7,6 +7,12 @@ const text = (width: string) => `<span data-jav-skeleton-text class="skeleton bl
const cover = (classes: string) => `<span data-jav-skeleton-cover class="skeleton ${classes}"></span>`;
export const JAV_RECOMMENDATION_GRID = 'w-full min-w-0';
+/** 查询中的标签沿用筛选条的高度与横向布局。 */
+export function javTagSkeleton(): string {
+ return ['w-20', 'w-16', 'w-24', 'w-20', 'w-16', 'w-24'].map(width =>
+ `<span data-skeleton="tag" aria-hidden="true" class="skeleton-sheen relative block h-7.5 flex-none rounded-(--tag-radius) ${width}"></span>`).join('');
+}
+
/** 占位复用推荐卡与想要行的宽度、封面比例和列数。 */
export function javContentSkeleton(tab: string, layout = javLayout()): string {
if (tab === 'wants') return `<div class="flex w-full flex-col gap-8" data-skeleton="jav-wants">${text('5em')}${Array.from({ length: 3 }, () => `<div class="flex min-w-0 gap-4 rounded-2lg bg-background-secondary-default p-6">${cover('block w-card-cover shrink-0 aspect-card-cover rounded-2lg max-sm:w-24')}<div class="flex min-w-0 flex-1 flex-col gap-3">${text('80%')}${text('60%')}${text('40%')}</div></div>`).join('')}</div>`;
@@ -30,13 +36,13 @@ export function javPageSkeleton(tab: string): string {
: `<section class="flex min-w-0 flex-col gap-4">${javFilterSkeleton()}<div data-jav-metadata class="flex min-w-0 flex-wrap items-center justify-between gap-3">${islandButton({ variant: 'secondary', size: 'small', label: '更新资料', attrs: 'disabled data-skeleton-action' })}</div>${javContentSkeleton(tab)}</section>`}</div></div>`;
}
-/** 首屏筛选控件使用首页的两排容器;只有读数依赖查询。 */
+/** 首屏筛选控件使用首页的两排容器;标签和读数依赖查询。 */
function javFilterSkeleton(): string {
const scope = (key: string, label: string) => `<button type="button" data-entity-tag="${key}" data-entity-press="" aria-pressed="${key === 'external'}" class="flex h-7.5 flex-none items-center gap-1.75 rounded-lg border border-dashed border-(--glass-low) bg-transparent px-2.5 text-body-2-regular leading-5 whitespace-nowrap text-inherit">${label}</button>`;
const size = (value: string, glyph: string) => `<span data-glass-segment="" ${javLayout() === value ? 'data-selected="true"' : ''} class="flex size-7.5 flex-none items-center justify-center rounded-lg text-(--glass-text)/62">${islandGlyph(glyph, 'size-4')}</span>`;
return `<div data-filter-glass data-glass-pane data-filter-frame data-jav-filter data-catalog-frame class="sticky top-topbar z-10 mb-5.5 flex flex-col">
<div data-filter-row="top" class="flex h-12 min-w-0 items-center overscroll-x-contain px-3 py-2 gap-1.5 overflow-visible">
- <div data-catalog-scroll><div data-catalog-views>${scope('external', '库外发现')}${scope('library', '馆藏探索')}<span data-entity-sep aria-hidden="true"></span></div><div data-catalog-tags></div></div>
+ <div data-catalog-scroll><div data-catalog-views>${scope('external', '库外发现')}${scope('library', '馆藏探索')}<span data-entity-sep aria-hidden="true"></span></div><div data-catalog-tags>${javTagSkeleton()}</div></div>
</div>
<div data-filter-row="bottom" aria-busy="true" class="flex min-h-12 min-w-0 items-center gap-3 px-3 py-2">
<span data-catalog-readout><span data-skeleton="count" class="relative inline-block h-3.5 w-37.5 rounded-md align-middle skeleton-sheen"></span></span>
diff --git a/frontend/src/react/catalog-filter/catalog-filter.css b/frontend/src/react/catalog-filter/catalog-filter.css
index 020ecb90b..9686fb280 100644
--- a/frontend/src/react/catalog-filter/catalog-filter.css
+++ b/frontend/src/react/catalog-filter/catalog-filter.css
@@ -254,6 +254,7 @@
@media (pointer: coarse) {
.peach-react [data-catalog-frame] > [data-filter-row="top"] { height: 52px; }
.peach-react :is([data-catalog-view], [data-catalog-tag]) { height: 36px; }
+ .peach-react [data-catalog-tags] > [data-skeleton="tag"] { height: 36px; }
}
/* ── 下排 ──
diff --git a/frontend/src/react/follow-feed/follow-feed.css b/frontend/src/react/follow-feed/follow-feed.css
index 25493accb..6ad560729 100644
--- a/frontend/src/react/follow-feed/follow-feed.css
+++ b/frontend/src/react/follow-feed/follow-feed.css
@@ -309,6 +309,7 @@
--card-meta-tags: calc(var(--fs-xs) * 1.45 + var(--tag-pad-y) * 2 + 2px + 3px);
}
.peach-react [data-follow-labels] { grid-column: 1 / -1; }
+.peach-react [data-follow-item] [data-media-meta] > [data-follow-labels] { pointer-events: none; }
.peach-react [data-follow-list]:not([data-follow-wall]) [data-follow-item] [data-media-meta] {
min-height: calc(var(--card-meta-block) + 16px);
contain-intrinsic-block-size: auto var(--card-meta-block);
diff --git a/frontend/src/react/jav/jav-page.tsx b/frontend/src/react/jav/jav-page.tsx
index 2040125e2..bd744b1f5 100644
--- a/frontend/src/react/jav/jav-page.tsx
+++ b/frontend/src/react/jav/jav-page.tsx
@@ -9,7 +9,7 @@ import { coverUrl } from '@peach/card-art';
import { relayoutCovers } from '../../card-art/framing';
import { wireHorizontalScroller } from '../../ui-kit/scroll';
import { DiscoveryFaces } from './discovery-faces';
-import { javContentSkeleton, JAV_RECOMMENDATION_GRID } from '../../jav-skeleton';
+import { javContentSkeleton, javTagSkeleton, JAV_RECOMMENDATION_GRID } from '../../jav-skeleton';
import { errorMessage } from '../../api';
import { CloudDownloadDialog, type DownloadPrefill } from '../activity/cloud-download-dialog';
import { Note } from '../components/note';
@@ -103,8 +103,8 @@ function Discover({ readOnly, receipt, resource, query, navigate, clearText }: {
{([['external', '库外发现'], ['library', '馆藏探索']] as const).map(([key, label]) =>
<FilterPill key={key} data-entity-tag={key} data-entity-press="" pressed={scope === key} onPress={() => { setScope(key); setTag('') }}>{label}</FilterPill>)}
<span data-entity-sep="" aria-hidden="true" />
- </div><div data-catalog-tags="">
- {tags.map(name => <FilterPill key={name} data-catalog-tag={name} data-entity-press="" pressed={tag === name} onPress={() => setTag(tag === name ? '' : name)}>
+ </div><div data-catalog-tags="" dangerouslySetInnerHTML={waiting ? { __html: javTagSkeleton() } : undefined}>
+ {waiting ? null : tags.map(name => <FilterPill key={name} data-catalog-tag={name} data-entity-press="" pressed={tag === name} onPress={() => setTag(tag === name ? '' : name)}>
{name}<span data-count-badge="">{all.filter(item => item.tags?.includes(name)).length}</span>
</FilterPill>)}
</div></div>} bottom={<>