Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 保持关注骨架样式契约并统一头像决策引用

longmeidao73186ae2e995
diff --git a/frontend/src/board-skeleton.ts b/frontend/src/board-skeleton.ts
index 0efea5344..2090cddf6 100644
--- a/frontend/src/board-skeleton.ts
+++ b/frontend/src/board-skeleton.ts
@@ -32,7 +32,7 @@ const followCheck = (label = '') => `<span class="group inline-flex items-center
interface FollowToolbar { table: boolean; sort: SortKey; dir: SortDir }
const followToolbar = ({ table, sort, dir }: FollowToolbar) => {
const name = SORT_OPTIONS.find(([key]) => key === sort)![1];
- return `<div class="flex flex-wrap items-center gap-2 follow-skeleton-toolbar"><span class="contents max-sm:flex max-sm:min-w-0 max-sm:flex-1 max-sm:flex-col"><h3 class="mr-auto text-title-2-medium text-text-primary">关注列表</h3><span class="text-body-2-regular text-text-secondary">${text('132px')}</span></span>${islandButton({ glyph: 'refresh-cw', label: '检查全部', compact: true, attrs: WAITING })}<span data-follow-toolbar-controls class="contents max-sm:flex max-sm:w-full max-sm:items-center max-sm:gap-2"><span data-button-group role="group">${islandButton({ variant: 'ghost', glyph: 'layout-grid', attrs: `aria-pressed="${!table}"` })}${islandButton({ variant: 'ghost', glyph: 'table', attrs: `aria-pressed="${table}"` })}</span>${islandSelect(name)}${islandButton({ variant: 'secondary', glyph: dir === 'asc' ? 'arrow-up' : 'arrow-down' })}${table ? '' : islandButton({ variant: 'secondary', glyph: 'chevron-up', label: '全部收起', compact: true, attrs: WAITING })}</span></div>`;
+ return `<div class="flex flex-wrap items-center gap-2 ui-follow-skeleton-toolbar"><span class="contents max-sm:flex max-sm:min-w-0 max-sm:flex-1 max-sm:flex-col"><h3 class="mr-auto text-title-2-medium text-text-primary">关注列表</h3><span class="text-body-2-regular text-text-secondary">${text('132px')}</span></span>${islandButton({ glyph: 'refresh-cw', label: '检查全部', compact: true, attrs: WAITING })}<span data-follow-toolbar-controls class="contents max-sm:flex max-sm:w-full max-sm:items-center max-sm:gap-2"><span data-button-group role="group">${islandButton({ variant: 'ghost', glyph: 'layout-grid', attrs: `aria-pressed="${!table}"` })}${islandButton({ variant: 'ghost', glyph: 'table', attrs: `aria-pressed="${table}"` })}</span>${islandSelect(name)}${islandButton({ variant: 'secondary', glyph: dir === 'asc' ? 'arrow-up' : 'arrow-down' })}${table ? '' : islandButton({ variant: 'secondary', glyph: 'chevron-up', label: '全部收起', compact: true, attrs: WAITING })}</span></div>`;
};
/** 行尾那对动作键:检查这一条的更新、移除这一条,与 React `SourceRow` 同为小号次级纯图标键。 */
const followRowActions = () => `<span class="flex shrink-0 items-center gap-1">${islandButton({ variant: 'secondary', size: 'small', glyph: 'refresh-cw', attrs: WAITING })}${islandButton({ variant: 'secondary', size: 'small', glyph: 'trash', attrs: WAITING })}</span>`;
@@ -65,7 +65,7 @@ const followTable = (rows: number, { sort, dir }: { sort: SortKey; dir: SortDir
/** 分页行:条数与页码要等数据,每页几条是这台浏览器的偏好,照最终的字样写出来。 */
const followPager = (table: boolean, size: number) => `<div class="flex flex-wrap items-center justify-between gap-3"><span class="text-body-2-regular text-text-secondary">${text('111px')}</span>${islandSelect(`每页 ${size} ${table ? '条' : '位'}`, { size: 'sm' })}${block(204, 32)}</div>`;
/** 关注列表以外的页签:内容各不相同、要等数据才知道长什么样,只画那张填充卡和几行占位。 */
-const followPanel = () => `<div class="min-w-0 bg-background-secondary-default rounded-2xl shadow-card flex flex-col gap-4 px-6 py-5 max-sm:px-4 follow-skeleton-surface"><h3 class="text-title-2-medium text-text-primary">${text('120px')}</h3>${['72%', '56%', '64%', '40%'].map((width) => `<span class="text-body-medium">${text(width)}</span>`).join('')}</div>`;
+const followPanel = () => `<div class="min-w-0 bg-background-secondary-default rounded-2xl shadow-card flex flex-col gap-4 px-6 py-5 max-sm:px-4 ui-follow-skeleton-surface"><h3 class="text-title-2-medium text-text-primary">${text('120px')}</h3>${['72%', '56%', '64%', '40%'].map((width) => `<span class="text-body-medium">${text(width)}</span>`).join('')}</div>`;
type FollowSkeletonOptions = { followLayout?: string; followPageSize?: number; followSort?: string; followDir?: string; followTab?: string };
const followList = (options: FollowSkeletonOptions) => {
const tab = followTabKey(options.followTab);
@@ -76,7 +76,7 @@ const followList = (options: FollowSkeletonOptions) => {
const content = table
? followTable(size, order)
: `${followCheck('全选本页')}<div class="flex flex-col gap-3">${followAuthor(3)}${followAuthor(4)}${followAuthor(3)}</div>`;
- return `<div class="peach-react"><div class="mx-auto flex w-full max-w-board flex-col gap-8">${followReadings()}<div class="flex flex-col gap-6">${followTabs(tab)}<div class="flex flex-col gap-4"><div class="min-w-0 bg-background-secondary-default rounded-2xl shadow-card flex flex-col gap-4 px-6 py-5 max-sm:px-4 follow-skeleton-surface" data-layout="${table ? 'table' : 'default'}">${followToolbar({ table, ...order })}${content}${followPager(table, size)}</div></div></div></div></div>`;
+ return `<div class="peach-react"><div class="mx-auto flex w-full max-w-board flex-col gap-8">${followReadings()}<div class="flex flex-col gap-6">${followTabs(tab)}<div class="flex flex-col gap-4"><div class="min-w-0 bg-background-secondary-default rounded-2xl shadow-card flex flex-col gap-4 px-6 py-5 max-sm:px-4 ui-follow-skeleton-surface" data-layout="${table ? 'table' : 'default'}">${followToolbar({ table, ...order })}${content}${followPager(table, size)}</div></div></div></div></div>`;
};
/** 详情骨架外层 `[data-skeleton="detail"]` 里面那一格:舞台岛自己画外层,里面照这一份写。格子与详情栏
diff --git a/frontend/test/board-skeleton.test.ts b/frontend/test/board-skeleton.test.ts
index af9619788..36ff65565 100644
--- a/frontend/test/board-skeleton.test.ts
+++ b/frontend/test/board-skeleton.test.ts
@@ -29,7 +29,7 @@ describe('Board 页面骨架', () => {
['/activity', '.activitysection', 3],
['/duplicates', '[data-duplicate-group] .duplicate-row', 4],
['/quality-goals', '.peach-react .card-grid-cover > li', 6],
- ['/follow-manage', '.peach-react .follow-skeleton-surface .follow-skeleton-author', 3],
+ ['/follow-manage', '.peach-react .ui-follow-skeleton-surface .follow-skeleton-author', 3],
['/configuration', '.peach-react .configpage section', 2],
['/playlists', '.playlistcards > .playlistcard', 6],
] as const)('%s 复用最终内容容器', (path, selector, count) => {
@@ -61,13 +61,13 @@ describe('Board 页面骨架', () => {
it('关注骨架选中地址栏 `?tab=` 那一枚页签,列表以外的页签不画关注列表的工具行', () => {
const feeds = follow({ followTab: 'feeds' });
expect(feeds.querySelector('[data-section-items] [aria-selected=true]')?.textContent).toBe('JAV 订阅源');
- expect(feeds.querySelector('.follow-skeleton-toolbar')).toBeNull();
- expect(feeds.querySelector('.follow-skeleton-surface')).not.toBeNull();
+ expect(feeds.querySelector('.ui-follow-skeleton-toolbar')).toBeNull();
+ expect(feeds.querySelector('.ui-follow-skeleton-surface')).not.toBeNull();
expect(follow({ followTab: 'wants' }).querySelector('[data-section-items] [aria-selected=true]')?.textContent).toBe('JAV 入库');
expect(follow({ followTab: 'nope' }).querySelector('[data-section-items] [aria-selected=true]')?.textContent).toBe('关注列表');
});
it('关注骨架的工具行按 Board UI 最终变体画:检查全部是主按钮,视图切换是按版式选中的按钮组', () => {
- const toolbar = follow().querySelector('.follow-skeleton-toolbar')!;
+ const toolbar = follow().querySelector('.ui-follow-skeleton-toolbar')!;
const check = toolbar.querySelector(':scope > button')!;
expect(check.textContent).toBe('检查全部');
expect(check.classList.contains('bg-button-primary')).toBe(true);
@@ -82,7 +82,7 @@ describe('Board 页面骨架', () => {
});
it('排序框与方向键跟着地址栏上的排序', () => {
const toolbar = (options: Parameters<typeof boardPageSkeleton>[1]) =>
- follow(options).querySelector('.follow-skeleton-toolbar')!;
+ follow(options).querySelector('.ui-follow-skeleton-toolbar')!;
const arrow = (root: Element) => root.querySelector('button[aria-haspopup]')!.parentElement!
.nextElementSibling!.querySelector('use')?.getAttribute('href');
expect(arrow(toolbar({}))).toBe('#i-arrow-down');
@@ -101,7 +101,7 @@ describe('Board 页面骨架', () => {
}
const head = root.querySelector('.follow-skeleton-author [data-follow-author-header]')!;
expect([...head.querySelectorAll('button')].map((button) => button.textContent)).toEqual(['', '全选', '收起']);
- expect(root.querySelector('.follow-skeleton-surface > .group')?.textContent).toBe('全选本页');
+ expect(root.querySelector('.ui-follow-skeleton-surface > .group')?.textContent).toBe('全选本页');
expect(root.querySelector('[data-selection-dock]')).toBeNull();
});
it('口味骨架画在 React 岛里,按浏览器记录那一页排', () => {
@@ -123,14 +123,14 @@ describe('Board 页面骨架', () => {
expect([...table.querySelectorAll('[data-sort-indicator][data-direction]')].map((mark) => [mark.parentElement!.textContent, mark.getAttribute('data-direction')]))
.toEqual([['上次检查', 'descending']]);
expect(root.querySelector('.follow-skeleton-author')).toBeNull();
- expect(root.querySelector('.follow-skeleton-toolbar')?.textContent).not.toContain('全部收起');
+ expect(root.querySelector('.ui-follow-skeleton-toolbar')?.textContent).not.toContain('全部收起');
});
it('表格骨架的行数跟着每页条数走', () => {
localStorage.setItem('peach.settings.v1', JSON.stringify({ followPageSize: 40 }));
try {
const root = follow({ followLayout: 'table' });
expect(root.querySelectorAll('.follow-skeleton-table tbody tr')).toHaveLength(40);
- expect(root.querySelector('.follow-skeleton-surface > :last-child button[aria-haspopup]')?.textContent).toBe('每页 40 条');
+ expect(root.querySelector('.ui-follow-skeleton-surface > :last-child button[aria-haspopup]')?.textContent).toBe('每页 40 条');
} finally { localStorage.removeItem('peach.settings.v1') }
});
});
diff --git a/src/peach/web_catalog.py b/src/peach/web_catalog.py
index 0f5acefa3..32b779b1b 100644
--- a/src/peach/web_catalog.py
+++ b/src/peach/web_catalog.py
@@ -465,7 +465,7 @@ def attach_avatar_availability(contract: WebContract, rows, key="rep",
发布账号缺少本人或出演职业依据(不过 `work_portrait_predicate`)时,代表作画面照样
当头像,同时标 `avatar_stand_in`:那是代表作画面,不是账号本人。资料页、索引、搜索、
- 口味榜与统计都从这里拿这个标志(ADR-0096)。
+ 口味榜与统计都从这里拿这个标志(ADR-0099)。
"""
ids = sorted({int(row[key]) for row in rows if row.get(key)})
paths: dict[int, str | None] = {}