Skip to content

armgit / peach

Public Imported from GitHub
0

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

feat(ui): 带范围的重试统一叫「立即重试」

longmeidao865c36a0ebaa
diff --git a/docs/FRONTEND.md b/docs/FRONTEND.md
index 4b39b8582..4e44bea1e 100644
--- a/docs/FRONTEND.md
+++ b/docs/FRONTEND.md
@@ -127,7 +127,7 @@ Peach 按 [ADR-0031](adr/0031-frontend-react-boardui-tailwind.md) 接入 React +
- `entity` 由资料页正文 `entity-body`(`frontend/src/react/entity-body/`)直接渲染在它的作品视图里,不另挂岛:第一页随资料页首屏一起取来,续页由资料页按查询键取。同一块的另两个视图是名册(索引页的 `PeopleGrid`)与照片墙(样张分段在前、本地图片在后;直接打开 React 灯箱(`photo-lightbox/`),定位源文件调 `actions.revealSource`)。
- `items` 挂在 `#nrow` 上:壳手上已有那一批,岛只画卡。
- 馆藏表格由 `catalog-list-page.tsx` 渲染,默认依次显示名称、时长、分辨率、体积、星级评分和观看次数。「显示列」可开启番号、高潮计数、观看时间、入库时间和发行时间;全部列按身份、媒体规格、个人记录、时间信息排列。隐藏某列仍可按该字段排序。名称过长时省略显示,悬停可查看全文。拖动表头分隔线调整列宽;键盘操作时聚焦分隔线,按 Enter 进入调整,再用左右方向键改变宽度,按 Enter 或 Tab 结束。列宽与显示选择保存在当前浏览器;「重置列宽」恢复默认宽度,「恢复默认显示」恢复默认列。桌面和手机均在表格内横向滚动,不扩大页面宽度。
-- 表格的表头和行分隔线铺满外框,右侧余量由独立空白列承接,保存的列宽保持不变。鼠标按住非控件区域可左右拖动所有数据表格,滚轮维持浏览器行为。馆藏表格只在手动开启多选后显示勾选框,底部「取消」清空选择并退出多选。评分与详情页共用 `RatingStars`:点击星星保存,再点当前星级取消;保存失败时在原单元格显示原因和「重试评分」,成功回执提供撤销。
+- 表格的表头和行分隔线铺满外框,右侧余量由独立空白列承接,保存的列宽保持不变。鼠标按住非控件区域可左右拖动所有数据表格,滚轮维持浏览器行为。馆藏表格只在手动开启多选后显示勾选框,底部「取消」清空选择并退出多选。评分与详情页共用 `RatingStars`:点击星星保存,再点当前星级取消;保存失败时在原单元格显示原因和「立即重试」(无障碍名称「立即重试评分」),成功回执提供撤销。
- 所有数据表格共用 `TableColumnControls`、`useTablePreferences` 和 `DataTableFrame`,提供显示列、恢复默认显示、重置列宽及鼠标/键盘调整列宽。各表单独保存浏览器偏好;身份列与勾选列保留,其余列可隐藏,排序菜单继续列出可排序字段。馆藏、关注来源、JAV 订阅源、两张别名表和数据管理表均使用这套组件。
- 关注来源与 JAV 订阅源的表头提供「全选本页」,再次点击取消本页选择。表格链接只占文字或图标本身的范围;管理表空白处用于选择行。关注卡片每条来源的站点图标放在行首,JAV 订阅源站点复用缓存的 `SiteLabel` 图标。
- 已保存别名的「修改统一名称」打开改名对话框,可输入名称或直接选用已有别名。`POST /api/follow/author-alias` 接受 `action: "rename"`、`canonical_key` 和 `canonical`;原名称保留为别名,关联的创作者名称及作品创作者字段在同一事务中同步。名称冲突或关联多个创作者档案时返回错误并回滚。
diff --git a/docs/SOURCING.md b/docs/SOURCING.md
index d255d9611..d579d70a7 100644
--- a/docs/SOURCING.md
+++ b/docs/SOURCING.md
@@ -183,7 +183,7 @@ Wiki 与视频作品资料无关。
- 上一趟存下的原始快照(`<Peach 数据目录>/sources/library-metadata/<番号>-<来源>.json`)还新鲜就直接用,不发请求。
有效期与「说过没有」的记忆同为 7 天,两边同时到期,才不会出现「没有」已过期而「有」还压着旧值。
- 「重试未完成项」要的就是新答复,强制重问。
+ 错误提示里的「立即重试」只补未完成项,要的就是新答复,强制重问。
- 「说过没有」按站记(`state/library-metadata-misses.json`,`library_processing._MissCache`):一档里说过没有
的站摘掉,全档都说过才整档跳过。文件记着每站第一次出现的时刻;「封面没有」那条的链上有一站晚于它接入,
这条就不作数。有码番号的记忆不会因为 FC2 链上接了新站而作废。
diff --git a/frontend/e2e/catalog-table-layout.test.ts b/frontend/e2e/catalog-table-layout.test.ts
index 22c5be843..4e7fbed66 100644
--- a/frontend/e2e/catalog-table-layout.test.ts
+++ b/frontend/e2e/catalog-table-layout.test.ts
@@ -49,7 +49,7 @@ describe('馆藏表格宽屏与选择操作', () => {
await row.getByRole('group', { name: '未评分', exact: true }).waitFor();
await row.getByRole('button', { name: '评为 2 星', exact: true }).click();
await row.getByText('示例评分失败', { exact: true }).waitFor();
- await row.getByRole('button', { name: '重试评分', exact: true }).click();
+ await row.getByRole('button', { name: '立即重试评分', exact: true }).click();
await row.getByRole('group', { name: '评分 2 / 5', exact: true }).waitFor();
await page.locator('[data-sonner-toast]').filter({ hasText: '已评 2 星' }).getByRole('button', { name: '撤销', exact: true }).click();
await row.getByRole('group', { name: '未评分', exact: true }).waitFor();
diff --git a/frontend/e2e/item-gallery.test.ts b/frontend/e2e/item-gallery.test.ts
index 51a03c476..870058466 100644
--- a/frontend/e2e/item-gallery.test.ts
+++ b/frontend/e2e/item-gallery.test.ts
@@ -171,7 +171,7 @@ describe('馆藏 JAV 官方预览', () => {
await page.route('**/api/jav/image?*', route => route.fulfill({ json: { ok: false, image: '', message: '图片未取得' } }));
await page.goto(new URL(`/assets/${COVER_ONLY_ITEM.id}`, page.url()).href);
const frame = page.locator('[data-item-gallery]');
- const retry = frame.getByRole('button', { name: '重试样图', exact: true });
+ const retry = frame.getByRole('button', { name: '立即重试样图', exact: true });
await retry.waitFor();
assert.equal(await retry.getAttribute('title'), '来源暂不可用');
assert.ok(await page.locator('[data-stage-side-content]').isVisible());
diff --git a/frontend/e2e/jav-discovery-metadata.test.ts b/frontend/e2e/jav-discovery-metadata.test.ts
index fb3027a1e..6fb26b206 100644
--- a/frontend/e2e/jav-discovery-metadata.test.ts
+++ b/frontend/e2e/jav-discovery-metadata.test.ts
@@ -69,7 +69,7 @@ describe('发现资料与排序', () => {
await page.waitForTimeout(2200);
assert.equal(requests.length, count, '停止后没有自动重启或轮询');
completed = true;
- await page.getByRole('button', { name: '重新读取资料', exact: true }).click();
+ await page.getByRole('button', { name: '立即重试读取作品资料', exact: true }).click();
await page.getByRole('button', { name: '更新资料', exact: true }).waitFor({ state: 'visible' });
await settle(page);
assert.equal(details, 0);
diff --git a/frontend/src/react/catalog-grid/catalog-table-controls.tsx b/frontend/src/react/catalog-grid/catalog-table-controls.tsx
index e66a51e3e..1cbd0667f 100644
--- a/frontend/src/react/catalog-grid/catalog-table-controls.tsx
+++ b/frontend/src/react/catalog-grid/catalog-table-controls.tsx
@@ -24,7 +24,7 @@ export function CatalogRating({ item, actions }: { item: MediaItem; actions: Pic
};
return <div data-catalog-rating="" role="group" aria-label={label} title={label}>
<RatingStars value={score} onRate={rate} busyStar={action.busy ? Number(action.busy) : undefined} />
- {action.error ? <Note tone="error" action={<Button variant="secondary" size="small" onClick={() => rate(lastStar.current)}>重试评分</Button>}>
+ {action.error ? <Note tone="error" action={<Button variant="secondary" size="small" aria-label="立即重试评分" onClick={() => rate(lastStar.current)}>立即重试</Button>}>
{action.error}
</Note> : null}
</div>;
diff --git a/frontend/src/react/data-cleanup/link-manager.tsx b/frontend/src/react/data-cleanup/link-manager.tsx
index cb5e2d245..5bb081e56 100644
--- a/frontend/src/react/data-cleanup/link-manager.tsx
+++ b/frontend/src/react/data-cleanup/link-manager.tsx
@@ -189,7 +189,7 @@ export function LinkManager() {
value={Math.min(prune.job?.checked || 0, prune.job?.total || 0)} total={prune.job?.total} />
: null}
</>;
- const pickedLabel = selectedRetryable.length ? `重试选中的 ${selectedRetryable.length} 条` : '重试选中的链接';
+ const pickedLabel = `立即重试所选(${selectedRetryable.length})`;
result = done || gone.length || unclear.length ? (
<div className={RESULT_PANEL}>
{pruned?.status === 'complete' ? <Note tone="success" title="完成">{pruneText(pruned)}</Note> : null}
@@ -207,12 +207,12 @@ export function LinkManager() {
</LinkTable>
<LinkTable title="本次未访问成功" items={unclear} hint={UNCLEAR_HINT}
picked={picked} onPick={setPicked} footer={retryable.length
- ? <Button leadingIcon={RETRY} {...busyProps(running)}
- onClick={() => run(retryable.map((item) => item.id))}>{`全部重试(${retryable.length})`}</Button>
+ ? <Button variant="primary" leadingIcon={RETRY} {...busyProps(running)}
+ onClick={() => run(retryable.map((item) => item.id))}>{`立即重试全部(${retryable.length})`}</Button>
: null}>
{retryable.length
? <>
- <Button leadingIcon={RETRY} disabled={!selectedRetryable.length} {...busyProps(running)}
+ <Button variant="secondary" leadingIcon={RETRY} disabled={!selectedRetryable.length} {...busyProps(running)}
onClick={() => run(selectedRetryable)}>{pickedLabel}</Button>
</>
: null}
diff --git a/frontend/src/react/item-detail/item-detail-page.tsx b/frontend/src/react/item-detail/item-detail-page.tsx
index b7775ae7b..0f6c1d326 100644
--- a/frontend/src/react/item-detail/item-detail-page.tsx
+++ b/frontend/src/react/item-detail/item-detail-page.tsx
@@ -185,7 +185,7 @@ function MediaFrame({ item, gate, helpers, actions, autoplay, onEnded }: {
{item.is_jav && item.code && !item.sample_images?.length && (source.isPending || source.error || source.data?.state === 'partial') ?
<div data-item-samples-state="">{source.isPending ? <span data-skeleton="samples" role="status" aria-label="正在读取样图" className="relative block h-12 w-20 skeleton-sheen" />
: <Button variant="secondary" {...busyProps(source.isFetching)} title={source.data?.message || requestErrorMessage(source.error)}
- onClick={() => { refreshSamples.current = true; void source.refetch() }}>重试样图</Button>}</div> : null}
+ aria-label="立即重试样图" onClick={() => { refreshSamples.current = true; void source.refetch() }}>立即重试</Button>}</div> : null}
{gate === 'offline' ? <OfflineGate item={item} badge={badge} helpers={helpers} actions={actions} />
: gate === 'disc' ? (
<div role="status" data-item-gate="disc">
diff --git a/frontend/src/react/jav/jav-page.tsx b/frontend/src/react/jav/jav-page.tsx
index 724b66e04..14f712f9d 100644
--- a/frontend/src/react/jav/jav-page.tsx
+++ b/frontend/src/react/jav/jav-page.tsx
@@ -147,7 +147,7 @@ function Discover({ readOnly, receipt, resource, query, navigate, clearText }: {
label={`正在读取作品资料 · ${metadata.completed} / ${metadata.total} 部`} value={metadata.completed} total={metadata.total} /></div> : null}
{metadata && metadata.status !== 'running' && (metadata.status !== 'complete' || metadata.failed > 0)
? <Note tone="neutral" action={<Button variant="secondary" {...busyProps(metadataAction.busy === 'retry')}
- onClick={() => updateMetadata('retry')}>重新读取资料</Button>}>{metadata.message || `作品资料 ${metadata.completed} / ${metadata.total} 部`}</Note> : null}
+ aria-label="立即重试读取作品资料" onClick={() => updateMetadata('retry')}>立即重试</Button>}>{metadata.message || `作品资料 ${metadata.completed} / ${metadata.total} 部`}</Note> : null}
{metadataAction.error ? <Note tone="error">{metadataAction.error}</Note> : null}
{!waiting && !discoveries.error && !items.length ? <EmptyState icon={RiCompassLine} title={query || tag ? '没有符合条件的推荐' : '暂无匹配口味的作品'}
actions={<><ButtonLink size="small" href="/taste" variant="secondary">查看口味</ButtonLink>
diff --git a/frontend/src/react/library-processing/library-processing-card.tsx b/frontend/src/react/library-processing/library-processing-card.tsx
index e6acb26fb..442bb1ea7 100644
--- a/frontend/src/react/library-processing/library-processing-card.tsx
+++ b/frontend/src/react/library-processing/library-processing-card.tsx
@@ -81,7 +81,7 @@ function Outcome(
{failed
? <Note tone="error" className="gap-0 p-3"
action={retryable
- ? <Button variant="primary" size="small" onClick={onRetry}>重试未完成项</Button>
+ ? <Button variant="secondary" size="small" aria-label="立即重试未完成项" onClick={onRetry}>立即重试</Button>
: null}
extra={details
/* 三层东西叠在同一块红底上:一句结论、一份清单、一条日志地址。各自之间
@@ -181,7 +181,7 @@ export function LibraryProcessingCard(props: LibraryProcessingProps) {
? <LinkButton href="/review" size="small" trailingIcon={RiArrowRightLine}>复核资料</LinkButton>
: null}
{/* 两个入口并存,各自答的不是一个问题:这里是「重新跑一整批」,下面那条错误提示里
- 的「重试未完成项」只补上一趟没做完的那些。采集里网络超时几乎每趟都留下几项可
+ 的「立即重试」只补上一趟没做完的那些。采集里网络超时几乎每趟都留下几项可
重试的,页脚要是让位给重试键,新入库的片子就再也没有入口被扫到。 */}
<ProcessingActions scan busy={busy} metadataOnly={state?.metadata_only} speedMode={state.speed_mode} onRun={run} />
</>
diff --git a/frontend/src/react/library-shortcuts/shortcut-controls.tsx b/frontend/src/react/library-shortcuts/shortcut-controls.tsx
index d4c75c185..f11a014b7 100644
--- a/frontend/src/react/library-shortcuts/shortcut-controls.tsx
+++ b/frontend/src/react/library-shortcuts/shortcut-controls.tsx
@@ -44,7 +44,7 @@ function FavoriteChoice({ item }: { item: Favorite }) {
if (!write.isPending) write.mutate({ action: 'favorite', ...item, on: !selected });
}}>{write.isPending ? <span aria-hidden dangerouslySetInnerHTML={{ __html: spinnerHtml('') }} /> : <Star />}</EntityActionButton>
{write.isError ? <Note tone="error">{errorMessage(write.error)}</Note> : null}
- {query.isError ? <Button variant="secondary" size="small" onClick={() => void query.refetch()}>重试读取收藏</Button> : null}
+ {query.isError ? <Button variant="secondary" size="small" aria-label="立即重试读取收藏" onClick={() => void query.refetch()}>立即重试</Button> : null}
</span>;
}
diff --git a/frontend/src/react/review/review-evidence.tsx b/frontend/src/react/review/review-evidence.tsx
index 346bb68f5..f49421d34 100644
--- a/frontend/src/react/review/review-evidence.tsx
+++ b/frontend/src/react/review/review-evidence.tsx
@@ -42,8 +42,9 @@ function RequestedSourceImage({ source }: { source: string }) {
onError={() => setStatus('failed')} />
: source ? <div className="flex flex-col items-center gap-2">
{status === 'failed' ? <span className="text-body-2-regular text-text-secondary">未取得来源图片</span> : null}
- <Button variant="secondary" size="small" onClick={() => setStatus('loading')}>
- {status === 'failed' ? '重新加载图片' : '查看来源图片'}
+ <Button variant="secondary" size="small" aria-label={status === 'failed' ? '立即重试加载来源图片' : undefined}
+ onClick={() => setStatus('loading')}>
+ {status === 'failed' ? '立即重试' : '查看来源图片'}
</Button>
</div> : <span className="text-body-2-regular text-text-secondary">未取得来源图片</span>}
</div>
diff --git a/frontend/test/react/data-cleanup.test.tsx b/frontend/test/react/data-cleanup.test.tsx
index cd48b9d6f..3e1ebbb22 100644
--- a/frontend/test/react/data-cleanup.test.tsx
+++ b/frontend/test/react/data-cleanup.test.tsx
@@ -441,7 +441,7 @@ describe('链接管理', () => {
expect(server.posts('/api/links/prune')).toEqual([]);
});
- it('「全部重试」只重验未访问成功的那几条,带上这一趟的检查号', async () => {
+ it('「立即重试全部」只重验未访问成功的那几条,带上这一趟的检查号', async () => {
const server = serve({
'/api/links': stats,
'/api/links/check': (body: { status_only?: boolean }) => (body.status_only
@@ -451,7 +451,7 @@ describe('链接管理', () => {
});
const host = await wrap(<LinkManager />);
await settle();
- await click(buttonNamed('全部重试(2)', host));
+ await click(buttonNamed('立即重试全部(2)', host));
await settle();
expect(server.posts('/api/links/check').filter((body) => !(body as { status_only?: boolean }).status_only))
.toEqual([{ retry: [2, 3], check_id: 'check-3' }]);
diff --git a/frontend/test/react/library-processing.test.tsx b/frontend/test/react/library-processing.test.tsx
index 03df5307e..004bbaab6 100644
--- a/frontend/test/react/library-processing.test.tsx
+++ b/frontend/test/react/library-processing.test.tsx
@@ -106,7 +106,7 @@ it('来源说没有只报一个数,不算问题也不提供失败重试', asyn
expect(record.closest('.text-text-secondary')).not.toBeNull();
expect(record.closest('.border-t')!.className).toContain('border-current/20');
expect(host.querySelector('[role="alert"]')).toBeNull();
- expect(buttonNamed('重试未完成项')).toBeNull();
+ expect(buttonNamed('立即重试未完成项')).toBeNull();
expect(host.querySelector('details')).toBeNull();
});
@@ -230,9 +230,10 @@ it('失败时把问题清单折叠进错误提示,重试只交失败的那些
// 补上没做完的那些是这一趟的事,重新跑一整批是下一趟的事:页脚那颗留着,各答各的问题。
expect(buttonNamed('同步媒体库', host)?.textContent).toBe('同步媒体库');
- // 重试键属于错误提示,问题清单收起时仍可操作。
- const retry = buttonNamed('重试未完成项')!;
- expect(retry.className).toContain('bg-button-primary');
+ // 重试键属于错误提示,和别处 Note 的恢复动作一样是次级键;问题清单收起时仍可操作。
+ const retry = buttonNamed('立即重试未完成项')!;
+ expect(retry.textContent).toBe('立即重试');
+ expect(retry.className).not.toContain('bg-button-primary');
expect(alert!.contains(retry)).toBe(true);
expect(details.contains(retry)).toBe(false);
@@ -259,7 +260,7 @@ it('失败项都不可重试时仍能重新发起整批任务', async () => {
retryable_asset_ids: [], issue_preview: [{ asset_id: 1, message: '未识别到番号' }],
});
const host = await mount(card({ toast: vi.fn() }));
- expect(buttonNamed('重试未完成项')).toBeNull();
+ expect(buttonNamed('立即重试未完成项')).toBeNull();
expect(buttonNamed('同步媒体库', host)?.textContent).toBe('同步媒体库');
});
diff --git a/frontend/test/react/rating-stars.test.tsx b/frontend/test/react/rating-stars.test.tsx
index 6702edfe7..2d769b2b7 100644
--- a/frontend/test/react/rating-stars.test.tsx
+++ b/frontend/test/react/rating-stars.test.tsx
@@ -44,7 +44,7 @@ it('表格评分成功同步列表与详情缓存,失败保留原因并支持
await click(root.host.querySelector('button[aria-label="评为 5 星"]'));
await settle();
expect(root.host.textContent).toContain('示例评分失败');
- const retry = [...root.host.querySelectorAll('button')].find(button => button.textContent === '重试评分')!;
+ const retry = [...root.host.querySelectorAll('button')].find(button => button.getAttribute('aria-label') === '立即重试评分')!;
await act(async () => retry.click());
await settle();
expect(rate).toHaveBeenCalledTimes(3);
diff --git a/frontend/test/react/source-image.test.tsx b/frontend/test/react/source-image.test.tsx
index 5e976b738..0286e6654 100644
--- a/frontend/test/react/source-image.test.tsx
+++ b/frontend/test/react/source-image.test.tsx
@@ -29,5 +29,5 @@ it('来源图片超时结束等待并提供重试', async () => {
await act(async () => { vi.advanceTimersByTime(30_000) });
expect(host.querySelector('img')).toBeNull();
expect(host.querySelector('[role=status]')).toBeNull();
- expect(host.textContent).toContain('重新加载图片');
+ expect(host.querySelector('button')?.getAttribute('aria-label')).toBe('立即重试加载来源图片');
});