Skip to content

armgit / peach

Public Imported from GitHub
0

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

feat(ui): 全站按钮主动作放右、链接放左

longmeidaof2153fc18f1c
diff --git a/docs/FRONTEND.md b/docs/FRONTEND.md
index 5152cf676..4b39b8582 100644
--- a/docs/FRONTEND.md
+++ b/docs/FRONTEND.md
@@ -74,7 +74,7 @@ Peach 按 [ADR-0031](adr/0031-frontend-react-boardui-tailwind.md) 接入 React +
- 结构:一条窄列里排「通用 / 媒体 / 下载 / 网络与访问 / 维护」五组,每组一个 `h2.ui-configgroup` 小标题,没有内容的组连标题一起省略。页面自己画顶上那排页签(`.ui-board-local-nav`,`role="tablist"`,方向键与 Home/End 在整排里走),一组一格,一次只显示选中的那一组;页签条和整页同一次提交画出,第一帧就在。
- 数据契约是 `/api/configuration`(`src/peach/routes_configuration.py`)。端点字符串只在 `frontend/src/configuration-endpoints.ts` 声明一次,整页和设置弹层的摘要卡读同一个 `queryKey`。
- 第一帧必须同步:壳挂完这一页紧接着按地址里的 `#peachProxy` 滚到那一块,所以路由树用 `flushSync` 画第一帧,往后的更新照常异步。`.ui-configpage` 的第一层依次是页签条、各组的小标题与面板;每组的根节点就是那一格 `role="tabpanel"`,选中的那一组带 `ui-board-group-active`。
-- 跳到某一组:别处(统计页「添加媒体目录」、空库提示、媒体库选单「管理媒体库」、诊断页)把组名记进壳单例 `configurationRequestedSection`(路由树里的页面经 `actions.requestConfigurationSection`),壳打开这一页时作为 `open.section` 交进去、页面画上之后清空;页面只拿它定第一帧选中哪一格。
+- 跳到某一组:React 页面(统计页「添加媒体」、诊断页、关注管理的凭据入口)直接链到这一组的地址 `/settings/<组>`,页面按地址定第一帧选中哪一格;遗留层的空库提示与媒体库选单「管理媒体库」把组名记进壳单例 `configurationRequestedSection`,壳打开这一页时作为 `open.section` 交进去、页面画上之后清空。
- 设置弹层「这台电脑」一格只挂 `configuration-summary`(`configuration-summary.tsx`):媒体库数、端口、更新状态和「打开配置页」,不放可编辑的控件(ADR-0050)。媒体库数取 `/api/configuration` 的 `library_count`,由服务端按 `media_libraries.libraries` 分组数好,页面不自己归并。
- 相邻的两处不在这页:媒体修复是数据管理页 React 子树里的一张卡(`frontend/src/react/media-repair/`),订阅源是关注管理页的「订阅源」页签(`follow-manage/feed-sources.tsx`,读 `/api/feeds`)。
- 服务端检查部署方式和请求来源:桌面服务由托盘管理且请求来自本机;Docker 服务由容器入口管理,允许经过登录验证的本机或私有网络请求,拒绝携带代理转发头的管理请求。`/healthz` 按调用方返回 `configurable`,页面据此显示配置入口;入口隐藏不能替代服务端访问检查。
diff --git a/frontend/e2e/design-manage.test.ts b/frontend/e2e/design-manage.test.ts
index 1050e4caf..728bae1aa 100644
--- a/frontend/e2e/design-manage.test.ts
+++ b/frontend/e2e/design-manage.test.ts
@@ -992,7 +992,7 @@ describe('设计决定:数据管理、索引页与资料页头', () => {
it('凭据的四种处境四副底色:待办和完成一眼分得开', { timeout: 60_000 }, async () => {
const opened = await openFollowManage(browser);
try {
- await opened.page.getByRole('button', { name: /^来源与订阅设置/ }).click();
+ await opened.page.getByRole('link', { name: /^来源与订阅设置/ }).click();
await opened.page.getByRole('tab', { name: '来源与订阅', exact: true, selected: true }).waitFor();
await opened.page.getByRole('region', { name: '可配置凭据', exact: true }).waitFor();
await settle(opened.page);
diff --git a/frontend/e2e/design-people.test.ts b/frontend/e2e/design-people.test.ts
index 1ebf76a2e..f0af6ffbf 100644
--- a/frontend/e2e/design-people.test.ts
+++ b/frontend/e2e/design-people.test.ts
@@ -1118,7 +1118,7 @@ describe('设计决定:人物与厂牌资料页', () => {
const opened = await openFollowManage(browser, viewport);
try {
const page = opened.page;
- await page.getByRole('button', { name: /^来源与订阅设置/ }).click();
+ await page.getByRole('link', { name: /^来源与订阅设置/ }).click();
await page.getByRole('tab', { name: '来源与订阅', exact: true, selected: true }).waitFor();
await page.getByRole('region', { name: '可配置凭据', exact: true }).waitFor();
await settle(page);
diff --git a/frontend/e2e/folder-layout.test.ts b/frontend/e2e/folder-layout.test.ts
index 077a5ee12..4c6ce5491 100644
--- a/frontend/e2e/folder-layout.test.ts
+++ b/frontend/e2e/folder-layout.test.ts
@@ -51,7 +51,7 @@ describe('文件夹反馈与滚动边界', () => {
const dialog = page.getByRole('dialog', { name: '文件夹目录', exact: true });
await dialog.getByRole('alert').waitFor();
assert.equal(await page.locator('#catalogFolderHeader [role="alert"]').count(), 0);
- await dialog.getByRole('button', { name: '重试', exact: true }).click();
+ await dialog.getByRole('button', { name: '立即重试', exact: true }).click();
await dialog.getByRole('button', { name: '关闭文件夹目录', exact: true }).click();
await page.locator('#catalogFolderHeader [role="alert"]').waitFor();
} finally { await opened.close() }
diff --git a/frontend/e2e/jav-detail.test.ts b/frontend/e2e/jav-detail.test.ts
index 1b27b31a4..1845ed339 100644
--- a/frontend/e2e/jav-detail.test.ts
+++ b/frontend/e2e/jav-detail.test.ts
@@ -288,8 +288,8 @@ describe('库外 JAV 作品详情', () => {
assert.equal(await toggle.getAttribute('aria-expanded'), 'false');
assert.equal(await toggle.locator('svg').count(), 2, '对象图标和展开箭头齐备');
}
- const sourceButton = page.getByRole('button', { name: '作品来源', exact: true });
- assert.deepEqual(await page.locator('[data-jav-actions] button').allTextContents(), ['查找资源', '想要', '作品来源']);
+ const sourceButton = page.getByRole('link', { name: '作品来源', exact: true });
+ assert.deepEqual(await page.locator('[data-jav-actions] :is(button, a)').allTextContents(), ['作品来源', '想要', '查找资源']);
assert.ok(await sourceButton.evaluate(el => parseFloat(getComputedStyle(el).borderWidth) > 0));
const side = page.locator('[data-jav-info]');
const before = await page.locator('#stage').boundingBox();
@@ -359,7 +359,7 @@ describe('库外 JAV 作品详情', () => {
}));
assert.ok(lines.every(line => line.width === '1px' && line.color === line.expected), JSON.stringify(lines));
assert.ok(await page.locator('[data-jav-resources]').getByRole('button', { name: '添加下载', exact: true }).first().isDisabled());
- assert.deepEqual(await page.locator('[data-resource-actions]').first().locator('button, a').allTextContents(), ['添加下载', '复制链接', '链接来源']);
+ assert.deepEqual(await page.locator('[data-resource-actions]').first().locator('button, a').allTextContents(), ['链接来源', '复制链接', '添加下载']);
assert.equal(await page.locator('[data-resource-facts]').first().getByText('高清', { exact: true }).count(), 0);
const facts = await page.locator('[data-resource-facts]').first().evaluate(node => {
const boxes = [...node.children].map(child => child.getBoundingClientRect());
diff --git a/frontend/e2e/video-wall.test.ts b/frontend/e2e/video-wall.test.ts
index cb77e239d..2e5b14146 100644
--- a/frontend/e2e/video-wall.test.ts
+++ b/frontend/e2e/video-wall.test.ts
@@ -197,7 +197,7 @@ describe('播放墙的浏览与详情', () => {
const attempts = failures, position = await camera(page);
await page.waitForTimeout(400);
assert.equal(failures, attempts, '失败后不连续触发新请求');
- recover = true; await page.getByRole('button', { name:'重试',exact:true }).click();
+ recover = true; await page.getByRole('button', { name:'立即重试',exact:true }).click();
await page.locator('[data-wall-error]').waitFor({ state:'hidden' });
await page.waitForFunction(() => [...document.querySelectorAll<HTMLElement>('[data-wall-id]')].some(node => Number(node.dataset.wallId) >= 1060));
assert.deepEqual(await camera(page), position);
diff --git a/frontend/e2e/want-resources.test.ts b/frontend/e2e/want-resources.test.ts
index bf603d5f6..b33acce71 100644
--- a/frontend/e2e/want-resources.test.ts
+++ b/frontend/e2e/want-resources.test.ts
@@ -47,7 +47,7 @@ describe('JAV 入库作品卡', () => {
assert.equal(await page.locator('#stats').getByRole('button', { name: '查找资源', exact: true }).count(), 2, '通用入口与作品入口分别保留一处');
assert.equal(await page.getByRole('combobox', { name: '下载到', exact: true }).count(), 0, '下载目标在资源下载面板中选择');
const source = card.getByRole('link', { name: '来源页', exact: true });
- assert.deepEqual(await source.evaluate(node => [...node.parentElement!.querySelectorAll('button, a')].map(action => action.textContent)), ['查找资源', '移除', '来源页']);
+ assert.deepEqual(await source.evaluate(node => [...node.parentElement!.querySelectorAll('button, a')].map(action => action.textContent)), ['来源页', '移除', '查找资源']);
const style = await card.evaluate(el => ({ radius: getComputedStyle(el).borderRadius,
border: getComputedStyle(el).borderTopWidth }));
assert.notEqual(style.radius, '0px');
diff --git a/frontend/src/application/composition.js b/frontend/src/application/composition.js
index 21dfa1276..696414454 100644
--- a/frontend/src/application/composition.js
+++ b/frontend/src/application/composition.js
@@ -66,7 +66,6 @@ compositionState.shellActions = {
failure:receiptsState.actionFailure,
revealSource:revealForIsland,
reopenTutorial:reopenPostSetupTutorial,
- requestConfigurationSection:section=>{writeShell({configurationRequestedSection:section})},
routeReview,
routeFollowManage,
saveFollowPreference:patch=>{
diff --git a/frontend/src/application/follow.js b/frontend/src/application/follow.js
index 5a5dcabd6..ed314b1f8 100644
--- a/frontend/src/application/follow.js
+++ b/frontend/src/application/follow.js
@@ -11,7 +11,6 @@ import { $, entityPath } from '../core';
import { navigationState, openRoutedPage, requestOverlay } from './navigation.js';
import { entityState, syncPhotoWalls } from './entity.js';
import { followDetailReturnPath, followDiscoverySeed, followRevision, followSelected, pageOpens, selectMode, writeShell } from './../shell/index';
-import { followManageEntry } from './index.js';
import { censorOn, preferencesState, wireDrag } from './preferences.js';
import { revealSkeleton, wireHorizontalScroller } from '../ui-kit';
import { followJobProgress } from './../jobs';
@@ -116,7 +115,6 @@ followState.followFeedActions = {
loaded:drawer=>renderFollowDrawer(drawer),
openDetail:id=>openFollowDetail(id),
openAuthor:name=>navigationState.navigatePath(entityPath('creator',name)),
- openManage:()=>navigationState.navigatePath(followManageEntry()),
toggleSelection:(id,range)=>toggleFollowSelection(id,range),
setImagesOnly:on=>{preferencesState.appSettings.followImagesOnly=!!on;preferencesState.saveSettings();syncPhotoWalls()},
setPhotoLayout:layout=>{storePhotoLayout(layout);syncPhotoWalls()},
diff --git a/frontend/src/application/tutorial.js b/frontend/src/application/tutorial.js
index 26c4d058e..a497b2c14 100644
--- a/frontend/src/application/tutorial.js
+++ b/frontend/src/application/tutorial.js
@@ -1,6 +1,6 @@
/* tutorial 域控制器:本域状态与动作,启动由 Application 的生命周期统一安装。 */
import { cameFromSetup, writeShell } from './../shell/index';
-import { isCurrentPostSetupTutorialRequest, nextPostSetupTutorialRequest, postSetupTutorialCollapsed, postSetupTutorialMarker, postSetupTutorialSignature, postSetupTutorialSkipped, resetPostSetupTutorialState, setCollapseRegionOpen, setPostSetupTutorialCollapsed, setPostSetupTutorialMarker, setPostSetupTutorialSkipped } from '../ui-kit';
+import { isCurrentPostSetupTutorialRequest, nextPostSetupTutorialRequest, postSetupTutorialCollapsed, postSetupTutorialMarker, postSetupTutorialErrorHtml, postSetupTutorialSignature, postSetupTutorialSkipped, resetPostSetupTutorialState, setCollapseRegionOpen, setPostSetupTutorialCollapsed, setPostSetupTutorialMarker, setPostSetupTutorialSkipped } from '../ui-kit';
import { peachHistory, shellNavigate } from './../history/index';
import { $, api, icon } from '../core';
import { navigationState } from './navigation.js';
@@ -77,10 +77,7 @@ export async function syncPostSetupTutorial(){
if(!isCurrentPostSetupTutorialRequest(request))return;
/* 取数失败时这张卡是死的:没有清单,也没有下一步。给一条重试和一个关闭,
不然它只能一直杵在右下角占着地方。 */
- root.innerHTML=`<article class="post-setup-notification post-setup-error">${icon('alert')}
- <div><h2>暂时无法检查安装进度</h2><p>切换页面或重新打开后会再检查一次。</p>
- <div class="post-setup-error-actions"><button class="geist-button" type="button" data-tutorial-retry>重试</button>
- <button class="geist-button" type="button" data-tutorial-dismiss>关闭</button></div></div></article>`;
+ root.innerHTML=postSetupTutorialErrorHtml(icon('alert'));
root.removeAttribute('aria-busy');
applicationEffects.handler(root.querySelector('[data-tutorial-retry]'), 'onclick', ()=>{
delete root.dataset.tutorialSignature;root.innerHTML='';void syncPostSetupTutorial();
diff --git a/frontend/src/onboarding/post-setup-tutorial.ts b/frontend/src/onboarding/post-setup-tutorial.ts
index b0e63e4c2..943b10913 100644
--- a/frontend/src/onboarding/post-setup-tutorial.ts
+++ b/frontend/src/onboarding/post-setup-tutorial.ts
@@ -42,3 +42,10 @@ export function resetPostSetupTutorialState():void{
setPostSetupTutorialCollapsed(false);
setPostSetupTutorialMarker('pending');
}
+
+/** 取不到清单时那张卡:只有固定文案,关闭在左、立即重试在右;事件仍由装配那一侧接。 */
+export const postSetupTutorialErrorHtml=(alertIcon:string):string=>
+ `<article class="post-setup-notification post-setup-error">${alertIcon}
+ <div><h2>暂时无法检查安装进度</h2><p>切换页面或重新打开后会再检查一次。</p>
+ <div class="post-setup-error-actions"><button class="geist-button" type="button" data-tutorial-dismiss>关闭</button>
+ <button class="geist-button" type="button" data-tutorial-retry>立即重试</button></div></div></article>`;
diff --git a/frontend/src/player/subtitles.ts b/frontend/src/player/subtitles.ts
index 9a5ba5490..d5e4b8cfb 100644
--- a/frontend/src/player/subtitles.ts
+++ b/frontend/src/player/subtitles.ts
@@ -99,7 +99,7 @@ export class SubtitleControls {
});
if (this.session.error) {
this.status(this.session.error, true);
- panel.querySelector('[data-subtitle-status]')!.insertAdjacentHTML('beforeend', '<button type="button" class="vjs-peach-caption-action" data-subtitle-memory-retry>重试</button>');
+ panel.querySelector('[data-subtitle-status]')!.insertAdjacentHTML('beforeend', '<button type="button" class="vjs-peach-caption-action" data-subtitle-memory-retry>立即重试</button>');
panel.querySelector<HTMLButtonElement>('[data-subtitle-memory-retry]')!.onclick = () => { void this.session.retry() };
}
}
@@ -192,7 +192,7 @@ export class SubtitleControls {
this.status(error instanceof Error ? error.message : '字幕搜索失败', true);
list.querySelector('[data-subtitle-more]')?.remove();
list.querySelector('[data-subtitle-retry]')?.remove();
- list.insertAdjacentHTML('beforeend', '<button type="button" class="vjs-peach-caption-action" data-subtitle-retry>重试</button>');
+ list.insertAdjacentHTML('beforeend', '<button type="button" class="vjs-peach-caption-action" data-subtitle-retry>立即重试</button>');
list.querySelector<HTMLButtonElement>('[data-subtitle-retry]')!.onclick = () => { void this.runSearch(panel, offset) };
}
} finally { panel.removeAttribute('aria-busy'); if (trigger) setActionBusy(trigger, false); list.inert = false }
diff --git a/frontend/src/react/avatar-picker/avatar-picker-page.tsx b/frontend/src/react/avatar-picker/avatar-picker-page.tsx
index ced878c86..901ef0607 100644
--- a/frontend/src/react/avatar-picker/avatar-picker-page.tsx
+++ b/frontend/src/react/avatar-picker/avatar-picker-page.tsx
@@ -178,7 +178,7 @@ function PickerBody({ kind, entityId, name, onPicked, close }: AvatarPickerProps
{problem ? (
<Note tone="error" action={listingFailed ? (
<Button variant="secondary" size="small" {...busyProps(listing.isFetching)}
- onClick={() => { if (!listing.isFetching) void listing.refetch() }}>重试</Button>
+ onClick={() => { if (!listing.isFetching) void listing.refetch() }}>立即重试</Button>
) : undefined}>{problem}</Note>
) : null}
</div>
@@ -258,7 +258,7 @@ function PickerBody({ kind, entityId, name, onPicked, close }: AvatarPickerProps
<div className="min-w-0 flex-1">
<Input type="url" aria-label="图片地址" placeholder="https://…" value={url} onChange={setUrl} />
</div>
- <Button disabled={!url.trim()} {...busyProps(opens('url'))}
+ <Button variant="secondary" disabled={!url.trim()} {...busyProps(opens('url'))}
onClick={() => { if (!busy) opening.mutate({ via: 'url', url: url.trim() }) }}>用这个地址</Button>
</div>
</div>
diff --git a/frontend/src/react/bundle.d.ts b/frontend/src/react/bundle.d.ts
index c57bde500..fb19f9303 100644
--- a/frontend/src/react/bundle.d.ts
+++ b/frontend/src/react/bundle.d.ts
@@ -322,8 +322,6 @@ export interface StatsProps {
tagLabel(key: string): string;
/** 点一个内容标签:回目录并按它筛选。整页换成目录由遗留壳做。 */
onTag(key: string): void;
- /** 打开配置页的「媒体」页签。没有视频或没有存储来源时空态里的那个去处。 */
- openMediaSettings(): void;
}
/** 口味页仍由遗留层提供的能力。都是导航、查表或回执,页面不持有它们的状态。 */
@@ -366,7 +364,6 @@ export interface FollowManageProps {
toast(message: string): void;
/** 去「看更新」那一页(`/follow`)。整页换成哪一屏仍归遗留壳。 */
openFollow(): void;
- openServiceConfiguration(): void;
/** 数据库只读:这台机器只能浏览,写操作全部不给点。 */
readOnly: boolean;
readOnlyMessage: string;
diff --git a/frontend/src/react/catalog-folders/catalog-folders-page.tsx b/frontend/src/react/catalog-folders/catalog-folders-page.tsx
index 60442e6a9..1939b4f9c 100644
--- a/frontend/src/react/catalog-folders/catalog-folders-page.tsx
+++ b/frontend/src/react/catalog-folders/catalog-folders-page.tsx
@@ -102,7 +102,7 @@ export function CatalogFolders({ treeTarget, headerTarget, enabled = true }: {
{data?.selected ? <IconButton aria-label="设置目录用途" icon={RiFolderSettingsLine} size="small"
onClick={() => setEditing(true)} /> : null}
</div>
- {query.error && !drawer ? <Note tone="error" action={<Button variant="secondary" size="small" onClick={() => { void query.refetch() }}>重试</Button>}>{errorMessage(query.error)}</Note> : null}
+ {query.error && !drawer ? <Note tone="error" action={<Button variant="secondary" size="small" onClick={() => { void query.refetch() }}>立即重试</Button>}>{errorMessage(query.error)}</Note> : null}
{data?.conflicts?.length ? <Note tone="warning" action={<Button variant="secondary" size="small" onClick={() => setEditing(true)}>查看归属冲突</Button>}>{data.conflicts.length} 项保留现有归属</Note> : null}
{data?.selected ? <div className="folder-scope-row">
<Checkbox size="sm" isSelected={params.get('folder_recursive') !== '0'}
@@ -168,7 +168,7 @@ function FolderTree({ scope, selected, current, go, reportedError }: {
return <section aria-label="文件夹导航" className="catalog-folder-navigation flex min-h-0 min-w-0 flex-col gap-3">
<Input aria-label="查找文件夹" placeholder="查找文件夹" leadingIcon={RiSearchLine} value={search}
onChange={setSearch} size="small" />
- {failed ? <Note tone="error" action={<Button variant="secondary" size="small" onClick={() => { void roots.refetch(); branches.forEach(branch => { if (branch.error) void branch.refetch() }) }}>重试</Button>}>{errorMessage(failed)}</Note> : null}
+ {failed ? <Note tone="error" action={<Button variant="secondary" size="small" onClick={() => { void roots.refetch(); branches.forEach(branch => { if (branch.error) void branch.refetch() }) }}>立即重试</Button>}>{errorMessage(failed)}</Note> : null}
<div className="folder-tree-frame relative flex min-h-0 flex-col overflow-hidden rounded-3xl"><div ref={scroll} className="folder-tree-scroller">
{roots.error ? null : roots.isPending ? <div data-skeleton="" aria-busy="true" aria-label="正在读取目录树" className="flex flex-col gap-2">{Array.from({ length: 8 }, (_, i) => <div key={i} className="flex h-8 items-center gap-2 px-3"><span className="skeleton-sheen size-4" /><span className="skeleton-sheen h-4 flex-1" /></div>)}</div>
: deferredSearch ? <div className="flex flex-col gap-1">{searchQuery.isPending ? <div data-skeleton="" aria-busy="true" className="h-8 skeleton-sheen" aria-label="正在查找文件夹" />
diff --git a/frontend/src/react/components/grid-reveal.tsx b/frontend/src/react/components/grid-reveal.tsx
index 9b2241ada..d6f655a58 100644
--- a/frontend/src/react/components/grid-reveal.tsx
+++ b/frontend/src/react/components/grid-reveal.tsx
@@ -41,6 +41,6 @@ export function RetryNote({ message, onRetry }: { message: string; onRetry: () =
};
return (
<div data-media-error="" onClick={click}
- dangerouslySetInnerHTML={{ __html: noteHtml(message, { variant: 'error', actionLabel: '重试' }) }} />
+ dangerouslySetInnerHTML={{ __html: noteHtml(message, { variant: 'error', actionLabel: '立即重试' }) }} />
);
}
diff --git a/frontend/src/react/components/source-picture.tsx b/frontend/src/react/components/source-picture.tsx
index 3a300d500..5de6acd2c 100644
--- a/frontend/src/react/components/source-picture.tsx
+++ b/frontend/src/react/components/source-picture.tsx
@@ -20,5 +20,5 @@ export function SourcePicture({ item, image, thumbnail = false }: {
if (src) return <img data-jav-picture={thumbnail ? undefined : ''} src={src} alt={thumbnail ? '' : image === 'cover' ? `${item.code} 封面` : `${item.code} 预览 ${Number(image) + 1}`} referrerPolicy="no-referrer" />;
if (thumbnail) return remote && result.isPending ? <span className="relative block h-full w-full skeleton-sheen" aria-label="正在读取预览" /> : <span>预览未取得</span>;
if (remote && result.isPending) return <div data-jav-picture-wait="" data-skeleton="image" role="status" aria-label="正在读取图片"><span className="relative skeleton-sheen" /></div>;
- return <div data-jav-picture-wait=""><Note tone="neutral" action={remote ? <Button variant="secondary" {...busyProps(result.isFetching)} onClick={() => { void result.refetch() }}>重试</Button> : undefined}>{result.data?.message || (result.error ? '图片未取得' : '封面未取得')}</Note></div>;
+ return <div data-jav-picture-wait=""><Note tone="neutral" action={remote ? <Button variant="secondary" {...busyProps(result.isFetching)} onClick={() => { void result.refetch() }}>立即重试</Button> : undefined}>{result.data?.message || (result.error ? '图片未取得' : '封面未取得')}</Note></div>;
}
diff --git a/frontend/src/react/data-cleanup/organize-card.tsx b/frontend/src/react/data-cleanup/organize-card.tsx
index 6034ae4bf..e65c8a982 100644
--- a/frontend/src/react/data-cleanup/organize-card.tsx
+++ b/frontend/src/react/data-cleanup/organize-card.tsx
@@ -175,6 +175,7 @@ export function OrganizeCard(
/* 这张卡上的结论只有一句:跑着的那一趟、这次跟完的那一趟、刚出的预览,按新旧取最新。 */
let state = null;
+ const applicable = !!changes && !running && !job.outcome;
const current = job.job;
const outcome = job.outcome;
if (current?.status === 'running') {
@@ -200,13 +201,12 @@ export function OrganizeCard(
attributes={{ 'data-cleanup-organize': '' }}
footer={
<>
- <Button disabled={!locations.length || running} {...busyProps(preview.isPending)} onClick={runPreview}>预览</Button>
- {changes && !running && !job.outcome
- ? <Button onClick={runApply}>执行整理</Button>
- : null}
{data?.last_batch
? <Button variant="secondary" {...busyProps(running)} onClick={runRollback}>回滚上一批</Button>
: null}
+ <Button variant={applicable ? 'secondary' : 'primary'} disabled={!locations.length || running}
+ {...busyProps(preview.isPending)} onClick={runPreview}>预览</Button>
+ {applicable ? <Button variant="primary" onClick={runApply}>执行整理</Button> : null}
</>
}>
<FieldsetTitle id="cleanup-organize-title" gap="medium">整理</FieldsetTitle>
diff --git a/frontend/src/react/data-cleanup/orphan-records-card.tsx b/frontend/src/react/data-cleanup/orphan-records-card.tsx
index 0bf5f0f2a..36001bbbd 100644
--- a/frontend/src/react/data-cleanup/orphan-records-card.tsx
+++ b/frontend/src/react/data-cleanup/orphan-records-card.tsx
@@ -59,6 +59,7 @@ function OrphanActions({ item, toast }: { item: OrphanRecord; toast(message: str
const busy = attach.isPending || purge.isPending;
return (
<span className="flex min-w-0 flex-wrap items-center gap-2">
+ <Button variant="danger" size="small" {...busyProps(busy)} onClick={remove}>删除记录</Button>
{item.candidates.length
? <Select aria-label={`选择接收 ${item.name} 个人记录的文件`} className="w-52" selectedKey={target}
onSelectionChange={(key) => { if (key !== null) setTarget(Number(key)) }}>
@@ -70,10 +71,9 @@ function OrphanActions({ item, toast }: { item: OrphanRecord; toast(message: str
</Select>
: null}
{item.candidates.length
- ? <Button size="small" disabled={target === null} {...busyProps(busy)}
+ ? <Button variant="primary" size="small" disabled={target === null} {...busyProps(busy)}
onClick={() => attach.mutate()}>转移记录</Button>
: null}
- <Button variant="danger" size="small" {...busyProps(busy)} onClick={remove}>删除记录</Button>
</span>
);
}
diff --git a/frontend/src/react/diagnostics/diagnostics-page.tsx b/frontend/src/react/diagnostics/diagnostics-page.tsx
index 93c8b7355..4355ad1ff 100644
--- a/frontend/src/react/diagnostics/diagnostics-page.tsx
+++ b/frontend/src/react/diagnostics/diagnostics-page.tsx
@@ -1,6 +1,7 @@
import { useState } from 'react';
import { useQuery } from '@tanstack/react-query';
-import { Button } from '@/components/base/buttons/button';
+import { configurationSection, settingsPath } from '@peach/history';
+import { Button, ButtonLink } from '@/components/base/buttons/button';
import { Chip } from '@/components/base/badges/chip';
import { SettingsCard, SettingsSectionLabel } from '@/components/application/settings/settings-rows';
import { cx } from '@/utils/cx';
@@ -16,9 +17,7 @@ import { HealthList } from './health-list';
const STATUS: Record<string, string> = { ok: '正常', warning: '需检查', failed: '需处理', unknown: '未取得', disabled: '未配置',
stale: '待复查', unchecked: '尚无记录' };
-const TARGET_LABELS: Record<string, string> = {
- '/settings/network': '打开网络与访问', '/settings/maintenance': '打开维护与更新', '/tasks': '查看任务',
-};
+const TARGET_LABELS: Record<string, string> = { '/tasks': '查看任务' };
const SECTIONS = [
['媒体库与挂载', ['media_mounts', 'data_root']],
['数据库与迁移', ['database', 'schema']],
@@ -36,7 +35,7 @@ function DiagnosticStatus({ status }: { status: string }) {
}
export interface DiagnosticsProps {
- navigate(path: string): void; configure(section: string): void; openItem(id: number): void;
+ openItem(id: number): void;
receipt(message: string): void;
}
@@ -60,10 +59,12 @@ function DownloadReport() {
</div>;
}
-function Check({ name, check, navigate, configure, compact = false }: Pick<DiagnosticsProps, 'navigate' | 'configure'> & {
+function Check({ name, check, compact = false }: {
name: string; check: DiagnosticCheck; compact?: boolean;
}) {
- const section = name === 'security' || name === 'port' ? '网络与访问' : '媒体库与入库';
+ /* 访问安全与端口落在网络与访问里,即使检查项给的是媒体库那一栏。 */
+ const target = check.target === '/settings/library' && (name === 'security' || name === 'port')
+ ? settingsPath('网络与访问') : check.target;
const Heading = compact ? 'h4' : 'h3';
return <div data-diagnostic-check={name} className={cx('flex flex-col gap-4 border-b border-separator-border pr-3 last:border-b-0 sm:flex-row sm:items-center sm:justify-between', compact ? 'py-3' : 'py-5')}>
<div className={cx('flex min-w-0 flex-1 flex-col', compact ? 'gap-1' : 'gap-2')}>
@@ -74,9 +75,8 @@ function Check({ name, check, navigate, configure, compact = false }: Pick<Diagn
<p data-check-reason className={cx('text-body-2-regular break-words', compact ? 'text-text-secondary' : 'text-text-primary')}>{check.reason}</p>
{check.action ? <p className="text-body-2-regular text-text-secondary">处理建议:{check.action}</p> : null}
</div>
- {check.target ? <div className="shrink-0 self-end sm:self-auto"><Button size="small" variant="secondary" onClick={() => check.target === '/settings/library'
- ? configure(section) : navigate(check.target!)}>{check.target === '/settings/library'
- ? `打开${section}` : TARGET_LABELS[check.target] ?? '打开相关页面'}</Button></div> : null}
+ {target ? <div className="shrink-0 self-end sm:self-auto"><ButtonLink size="small" variant="secondary" href={target}>
+ {target.startsWith('/settings/') ? `打开${configurationSection(target)}` : TARGET_LABELS[target] ?? '打开相关页面'}</ButtonLink></div> : null}
</div>;
}
@@ -102,7 +102,7 @@ export function DiagnosticsPage(props: DiagnosticsProps) {
<Button variant="secondary" onClick={refresh} {...busyProps(action.busy === 'refresh')}>重新检查</Button></div>
{refreshError ? <Note tone="error">{refreshError}</Note> : null}
{attention.length ? <Section title={`需要关注 · ${attention.length} 项`}>
- {attention.map(([key, check]) => <Check key={key} name={key} check={check} {...props} />)}
+ {attention.map(([key, check]) => <Check key={key} name={key} check={check} />)}
</Section> : null}
<Section title="库健康"><Stack>
{data.library.issue_at ? <p className="text-body-2-regular text-text-secondary">处理记录 · {moment(data.library.issue_at)}</p> : null}
@@ -116,7 +116,7 @@ export function DiagnosticsPage(props: DiagnosticsProps) {
<h3 className="flex items-center gap-2 px-3 text-body-medium text-text-primary">{title}
<span className="text-caption-1-regular text-text-secondary">{rows.length} 项</span>
</h3>
- <SettingsCard>{rows.map(([key, check]) => <Check key={key} name={key} check={check} compact {...props} />)}</SettingsCard>
+ <SettingsCard>{rows.map(([key, check]) => <Check key={key} name={key} check={check} compact />)}</SettingsCard>
</section> : null;
})}
</Disclosure>
@@ -139,7 +139,7 @@ export function DiagnosticsPage(props: DiagnosticsProps) {
</FactList>
</Stack></SettingsCard>
</article>)}
- <div><Button size="small" variant="secondary" onClick={() => props.navigate('/sources')}>打开来源和凭证</Button></div>
+ <div><ButtonLink size="small" variant="secondary" href="/sources">打开来源和凭证</ButtonLink></div>
</section>
</div>;
}
diff --git a/frontend/src/react/follow-feed/follow-feed-page.tsx b/frontend/src/react/follow-feed/follow-feed-page.tsx
index 10deab52a..8d65b0968 100644
--- a/frontend/src/react/follow-feed/follow-feed-page.tsx
+++ b/frontend/src/react/follow-feed/follow-feed-page.tsx
@@ -10,7 +10,7 @@
* `helpers.jobProgress` 盯着,跑完失效这一页的查询重取。 */
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode, type RefObject } from 'react';
import { useInfiniteQuery, useMutation, useQuery, type InfiniteData } from '@tanstack/react-query';
-import { icon, leadingGraphemes, requestErrorMessage } from '@peach/legacy/core';
+import { esc, icon, leadingGraphemes, requestErrorMessage } from '@peach/legacy/core';
import { tagLabel } from '@peach/legacy/tags';
import { spinnerHtml } from '@peach/legacy/ui';
@@ -29,6 +29,7 @@ import { useMasonryGrid } from '../components/use-masonry-grid';
import { Segments, Shuffle } from '../entity-filter/entity-filter-page';
import type { SegmentOption } from '../entity-filter/entity-filter';
import { checkSummary, FOLLOW_CHECK_URL, FOLLOW_STATUS_URL, sourceIconUrl } from '../follow-manage/follow-manage';
+import { followManageEntry } from '../follow-manage/manage-route';
import { Note } from '../components/note';
import { sidebarTagCounts } from '../../sidebar';
import { queryClient } from '../query';
@@ -143,7 +144,7 @@ export function FollowFeedPage(props: FollowFeedProps) {
if (result.isError) {
return (
<div data-follow-feed="">
- <Head onManage={actions.openManage} />
+ <Head />
<RetryNote message={requestErrorMessage(result.error)} onRetry={() => void result.refetch()} />
</div>
);
@@ -165,7 +166,7 @@ export function FollowFeedPage(props: FollowFeedProps) {
<div key={job.generation} ref={job.host} data-follow-progress="" />
{!job.busy && job.report ? <Note tone="neutral" title="检查结果">{job.report}</Note> : null}
<div data-follow-feed="" data-select-mode={props.selectMode ? '' : undefined}>
- <Head onManage={actions.openManage}>
+ <Head>
{facets.sources.length ? (
<Button variant="primary" data-follow-recheck="" aria-label="检查每个来源的更新"
aria-busy={job.busy || undefined}
@@ -183,7 +184,7 @@ export function FollowFeedPage(props: FollowFeedProps) {
<Glass facets={facets} view={view} total={total} busy={listPending} props={props} route={route} />
<Combo conditions={conditions} onDrop={(row) => actions.route(dropCondition(view, row))}
onClear={() => route({ author: '', provider: '', work: '', tags: [], durMin: 0, durMax: 0 })} />
- {facets.broken.length ? <BrokenNote count={facets.broken.length} onManage={actions.openManage} /> : null}
+ {facets.broken.length ? <BrokenNote count={facets.broken.length} /> : null}
<List key={query.queryKey.join('\u0000')} retryKey={result.dataUpdatedAt} pending={listPending} facets={facets} data={data} context={context}
props={props} checkAction={<Button size="small" variant="secondary" aria-label="检查每个来源的更新" aria-busy={job.busy || undefined}
aria-disabled={job.busy || undefined} onClick={() => { if (!job.busy) void job.start(false) }}>检查更新</Button>} />
@@ -223,14 +224,14 @@ export function FollowFeedPage(props: FollowFeedProps) {
}
/** 页头:标题与「管理关注」恒在,检查更新那枚键要等来源读到才摆(`children`)。 */
-function Head({ onManage, children }: { onManage(): void; children?: ReactNode }) {
+function Head({ children }: { children?: ReactNode }) {
return (
<div data-follow-head="">
<h2 data-follow-title="">关注</h2>
<span data-follow-head-actions="">
- <Button variant="secondary" leadingIcon={SETTINGS} data-follow-manage="" onClick={onManage}>
+ <ButtonLink variant="secondary" leadingIcon={SETTINGS} data-follow-manage="" href={manageHref()}>
管理关注
- </Button>
+ </ButtonLink>
{children}
</span>
</div>
@@ -528,16 +529,17 @@ function Combo({ conditions, onDrop, onClear }: {
}
/** 有来源上次检查失败:这一页不摊原因,指到管理页去看。Note 的边界与图标取全站那一份。 */
-function BrokenNote({ count, onManage }: { count: number; onManage(): void }) {
+function BrokenNote({ count }: { count: number }) {
return (
- <div data-follow-broken="" onClick={(event) => {
- if ((event.target as HTMLElement).closest('[data-follow-manage]')) onManage();
- }} dangerouslySetInnerHTML={{
- __html: `<div class="geist-note geist-note-error fwarn" role="alert">${icon('alert')}<span>${count} 个来源上次检查失败,去<button type="button" class="flink" data-follow-manage>管理关注</button>看原因。</span></div>`,
+ <div data-follow-broken="" dangerouslySetInnerHTML={{
+ __html: `<div class="geist-note geist-note-error fwarn" role="alert">${icon('alert')}<span>${count} 个来源上次检查失败,去<a class="flink" href="${esc(manageHref())}" data-follow-manage>管理关注</a>看原因。</span></div>`,
}} />
);
}
+/** 管理页入口随当前地址算:旧地址上的 `tab` 仍按 `followManageEntry` 的约定改道。 */
+const manageHref = () => followManageEntry(window.location.search);
+
/* ── 列表 ── */
function List({ pending, facets, data, context, props, retryKey, checkAction }: {
diff --git a/frontend/src/react/follow-feed/follow-feed.ts b/frontend/src/react/follow-feed/follow-feed.ts
index 82d85e73c..9e30de6ca 100644
--- a/frontend/src/react/follow-feed/follow-feed.ts
+++ b/frontend/src/react/follow-feed/follow-feed.ts
@@ -472,7 +472,6 @@ export interface FollowFeedActions {
loaded(drawer: FollowDrawer): void;
openDetail(id: number): void;
openAuthor(name: string): void;
- openManage(): void;
/** 多选里的一张:`range` 是 Shift 连选。 */
toggleSelection(id: number, range: boolean): void;
/** 照片墙「仅显示图片」与图片布局两样偏好,壳存起来再推回。 */
diff --git a/frontend/src/react/follow-manage/add-feed.tsx b/frontend/src/react/follow-manage/add-feed.tsx
index e6a90b917..c759b8790 100644
--- a/frontend/src/react/follow-manage/add-feed.tsx
+++ b/frontend/src/react/follow-manage/add-feed.tsx
@@ -121,11 +121,11 @@ export function AddFeed({ readOnly, toast, onAdded }: AddFeedProps) {
<Help role="status">{picked.size ? where!.text : '勾选她的演员卡;有碼与無碼两条记录都是她的话,两张都勾。'}</Help>
) : null}
<div className="flex flex-wrap items-center gap-2">
+ <Button variant="secondary" size="small" onClick={close}>关闭</Button>
{result.candidates.length ? (
<Button variant="primary" size="small" disabled={readOnly || !picked.size || where!.blocked}
{...busyProps(action.busy === 'follow')} onClick={add}>{`添加订阅(${picked.size})`}</Button>
) : null}
- <Button variant="secondary" size="small" onClick={close}>关闭</Button>
</div>
</div>
) : null}
diff --git a/frontend/src/react/follow-manage/add-source.tsx b/frontend/src/react/follow-manage/add-source.tsx
index a8551ced0..34d0971cd 100644
--- a/frontend/src/react/follow-manage/add-source.tsx
+++ b/frontend/src/react/follow-manage/add-source.tsx
@@ -11,7 +11,7 @@ import { RiFilter3Line, RiSearchLine } from '@remixicon/react';
import { useMutation, useQuery } from '@tanstack/react-query';
import { Dialog, Popover } from 'react-aria-components';
-import { Button } from '@/components/base/buttons/button';
+import { Button, ButtonLink } from '@/components/base/buttons/button';
import { Checkbox } from '@/components/base/checkbox/checkbox';
import {
MENU_ITEM, MENU_ITEM_INTERACTIVE, MENU_POPOVER_SURFACE,
@@ -46,10 +46,11 @@ export interface AddSourceProps {
credentials: CredentialData;
readOnly: boolean;
toast(message: string): void;
- /** 去凭据那一栏配这个站。候选里的「需要配置凭据」按下去就是换页签。 */
- openCredentials(): void;
}
+/** 凭据配在「来源与订阅」设置里;候选行的凭据链接指到那里。 */
+const CREDENTIALS_PATH = '/settings/subscriptions';
+
/** 候选的身份是它的地址:同一次查找里同一个地址只会出现一次。 */
const candidateKey = (row: number, candidate: ResolveCandidate) => `${row}:${candidate.url}`;
@@ -116,10 +117,10 @@ function SuggestMenu(
/** 来源筛选:列出全部可关注的站,默认全选。取消勾选的站,其查找结果行不显示、也不进
* 「添加选中」。 */
function SourceFilter(
- { credentials, hidden, onHidden, openCredentials }:
+ { credentials, hidden, onHidden }:
{
credentials: CredentialData; hidden: ReadonlySet<string>;
- onHidden(next: Set<string>): void; openCredentials(): void;
+ onHidden(next: Set<string>): void;
},
) {
const trigger = useRef<HTMLButtonElement>(null);
@@ -160,8 +161,8 @@ function SourceFilter(
</span>
</Checkbox>
{needsCredential ? (
- <Button variant="ghost" size="xs" className="ml-auto"
- onClick={() => { setOpen(false); openCredentials() }}>需要配置凭据</Button>
+ <ButtonLink variant="ghost" size="xs" className="ml-auto" href={CREDENTIALS_PATH}
+ onClick={() => setOpen(false)}>打开凭据设置</ButtonLink>
) : null}
</div>
);
@@ -219,7 +220,7 @@ function PickRow(
);
}
-export function AddSource({ data, credentials, readOnly, toast, openCredentials }: AddSourceProps) {
+export function AddSource({ data, credentials, readOnly, toast }: AddSourceProps) {
const [line, setLine] = useState('');
const [composing, setComposing] = useState(false);
/** 这一趟查的是什么。等待提示使用已提交的词,输入框可继续编辑并保留重试内容。 */
@@ -371,8 +372,7 @@ export function AddSource({ data, credentials, readOnly, toast, openCredentials
busy={suggesting} onPick={search} onClose={closeMenu} />
) : null}
</div>
- <SourceFilter credentials={credentials} hidden={hidden} onHidden={setHidden}
- openCredentials={openCredentials} />
+ <SourceFilter credentials={credentials} hidden={hidden} onHidden={setHidden} />
<Button variant="primary" disabled={readOnly || !line.trim()}
{...busyProps(running || resolve.isPending)} onClick={() => search(line)}>查找</Button>
</div>
@@ -396,11 +396,11 @@ export function AddSource({ data, credentials, readOnly, toast, openCredentials
}} />
))}
<div className="flex flex-wrap items-center gap-2">
+ <Button variant="secondary" size="small"
+ onClick={() => dismiss()}>关闭</Button>
<Button variant="primary" size="small" disabled={readOnly || !picked.length}
{...busyProps(register.isPending)}
onClick={() => register.mutate(picked)}>{`添加选中(${picked.length})`}</Button>
- <Button variant="secondary" size="small"
- onClick={() => dismiss()}>关闭</Button>
{register.isPending ? (
<span role="status" className="text-body-2-regular text-text-secondary">
{`添加中… ${added}/${picked.length}`}
diff --git a/frontend/src/react/follow-manage/credentials.tsx b/frontend/src/react/follow-manage/credentials.tsx
index 1b15561b5..cab6e5a9f 100644
--- a/frontend/src/react/follow-manage/credentials.tsx
+++ b/frontend/src/react/follow-manage/credentials.tsx
@@ -86,8 +86,6 @@ function CredentialForm({ row, readOnly, toast }:
))}
</div>
<div className="flex flex-wrap items-center gap-2">
- <Button variant="primary" size="small" disabled={readOnly} {...busyProps(write.isPending)}
- onClick={save}>保存配置</Button>
{done ? (
<Button variant="danger" size="small" disabled={readOnly} {...busyProps(write.isPending)}
onClick={() => void confirmModal({
@@ -95,6 +93,8 @@ function CredentialForm({ row, readOnly, toast }:
onConfirm: () => write.mutateAsync({}),
})}>清除</Button>
) : null}
+ <Button variant="primary" size="small" disabled={readOnly} {...busyProps(write.isPending)}
+ onClick={save}>保存配置</Button>
</div>
{problem ? <ErrorText>{problem}</ErrorText> : null}
{(row.shared_fields || []).length
diff --git a/frontend/src/react/follow-manage/follow-manage-page.tsx b/frontend/src/react/follow-manage/follow-manage-page.tsx
index a9cd074ce..be97c6cb2 100644
--- a/frontend/src/react/follow-manage/follow-manage-page.tsx
+++ b/frontend/src/react/follow-manage/follow-manage-page.tsx
@@ -27,7 +27,7 @@ import { PillAriaTabList } from '../components/pill-aria-tab-list';
import { STAT_STRIP_SIX } from '../components/stat-card';
import { AddSource } from './add-source';
import { AliasManager } from './alias-manager';
-import { Button } from '@/components/base/buttons/button';
+import { ButtonLink } from '@/components/base/buttons/button';
import { FeedSources } from './feed-sources';
import {
credentialDone, DEFAULT_SORT, FEEDS_KEY, fetchCredentials, fetchFeeds, fetchFollow, FOLLOW_CREDENTIALS_KEY,
@@ -60,7 +60,7 @@ function Reading({ term, figure, unit }: { term: string; figure: number; unit: s
export function FollowManagePage(props: FollowManageProps) {
const {
- route, savePreference, toast, openFollow, openServiceConfiguration, readOnly, readOnlyMessage, writerUrl,
+ route, savePreference, toast, openFollow, readOnly, readOnlyMessage, writerUrl,
} = props;
const [tab, setTab] = useState<TabKey>(isTab(props.tab) ? props.tab : 'list');
const [page, setPage] = useState(Math.max(1, Math.floor(props.page) || 1));
@@ -179,8 +179,7 @@ export function FollowManagePage(props: FollowManageProps) {
</TabPanel>
<TabPanel id="add" className="flex flex-col gap-8">
- <AddSource data={data} credentials={creds} readOnly={readOnly} toast={toast}
- openCredentials={openServiceConfiguration} />
+ <AddSource data={data} credentials={creds} readOnly={readOnly} toast={toast} />
<AliasManager groups={data.author_aliases || []} readOnly={readOnly} toast={toast}
suggestions={data.alias_suggestions || []} sources={data.sources} />
</TabPanel>
@@ -190,7 +189,7 @@ export function FollowManagePage(props: FollowManageProps) {
</TabPanel>
</Tabs>
- <div><Button variant="secondary" onClick={openServiceConfiguration}>来源与订阅设置{pending ? `(${pending})` : ''}</Button></div>
+ <div><ButtonLink variant="secondary" href="/settings/subscriptions">来源与订阅设置{pending ? `(${pending})` : ''}</ButtonLink></div>
</Page>
);
}
diff --git a/frontend/src/react/follow-manage/source-list.tsx b/frontend/src/react/follow-manage/source-list.tsx
index f393c1127..593730858 100644
--- a/frontend/src/react/follow-manage/source-list.tsx
+++ b/frontend/src/react/follow-manage/source-list.tsx
@@ -529,11 +529,11 @@ export function SourceList(props: SourceListProps) {
</span>
</span>
<div data-follow-toolbar-actions="" data-toolbar-actions="">
+ {failedSourceIds.length ? <Button variant="secondary" disabled={readOnly}
+ {...busyProps(rowHandlers.busy)} onClick={() => startChecking(failedSourceIds)}>检查失败项</Button> : null}
<Button variant="primary" leadingIcon={RiRefreshLine} disabled={readOnly}
aria-label="检查全部" iconOnly={compact}
{...busyProps(rowHandlers.busy)} onClick={() => startChecking([])}>检查全部</Button>
- {failedSourceIds.length ? <Button variant="secondary" disabled={readOnly}
- {...busyProps(rowHandlers.busy)} onClick={() => startChecking(failedSourceIds)}>检查失败项</Button> : null}
<span data-follow-toolbar-controls="" className="contents">
<span data-button-group role="group" aria-label="关注列表版式">
<Button variant="ghost" iconOnly
diff --git a/frontend/src/react/index/index-page.tsx b/frontend/src/react/index/index-page.tsx
index 4eb696329..1f16d9247 100644
--- a/frontend/src/react/index/index-page.tsx
+++ b/frontend/src/react/index/index-page.tsx
@@ -221,7 +221,7 @@ export function IndexPage(props: IndexProps) {
if (result.isError) {
return (
<EmptyState icon={spriteGlyph('alert')} title={`没能读取${title}`}
- actions={<Button variant="secondary" onClick={() => void result.refetch()}>重试</Button>}>
+ actions={<Button variant="secondary" onClick={() => void result.refetch()}>立即重试</Button>}>
{requestErrorMessage(result.error)}
</EmptyState>
);
diff --git a/frontend/src/react/index/tag-manager.tsx b/frontend/src/react/index/tag-manager.tsx
index 6601c38f3..1aa45f2bb 100644
--- a/frontend/src/react/index/tag-manager.tsx
+++ b/frontend/src/react/index/tag-manager.tsx
@@ -53,7 +53,7 @@ export function TagManager({ search = '', category = 'all', view = 'cloud', onCa
{picked.size ? <GlassPill onPress={() => setPicked(new Set())}>清空选择</GlassPill> : null}
</>} />
{inventory.isPending ? <div aria-busy="true" data-skeleton="" className="h-24 rounded-lg bg-background-tertiary-default"><VisuallyHidden>正在读取标签</VisuallyHidden></div>
- : inventory.isError ? <Note tone="error" action={<Button variant="secondary" onClick={() => void inventory.refetch()}>重试</Button>}>无法读取标签</Note>
+ : inventory.isError ? <Note tone="error" action={<Button variant="secondary" onClick={() => void inventory.refetch()}>立即重试</Button>}>无法读取标签</Note>
: visible.length ? (view === 'alphabet' ? <TagAlphabet groups={groups} actions={actions} /> : <TagCloud tags={tags} actions={actions} />)
: <Note tone="neutral">没有符合条件的标签。</Note>}
{action.error ? <Note tone="error">{action.error}</Note> : null}
diff --git a/frontend/src/react/item-detail/catalog-picture.tsx b/frontend/src/react/item-detail/catalog-picture.tsx
index d116a1a78..46889e9eb 100644
--- a/frontend/src/react/item-detail/catalog-picture.tsx
+++ b/frontend/src/react/item-detail/catalog-picture.tsx
@@ -14,7 +14,7 @@ export function CatalogPicture({ item, image, source = false, thumbnail = false
: `/${thumbnail ? 'sample-thumb' : 'sample-image'}?code=${encodeURIComponent(item.code || '')}&n=${image}`;
if (thumbnail) return failed ? <span>预览未取得</span> : <img src={src} alt="" onError={() => setFailed(true)} />;
if (failed) return <Note tone="neutral" action={<Button variant="secondary"
- onClick={() => { setFailed(false); setAttempt(value => value + 1) }}>重试</Button>}>预览未取得</Note>;
+ onClick={() => { setFailed(false); setAttempt(value => value + 1) }}>立即重试</Button>}>预览未取得</Note>;
return <img key={attempt} data-catalog-picture="" src={src} alt={image < 0 ? `${item.code} 封面` : `${item.code} 预览 ${image}`}
onError={() => setFailed(true)} />;
}
diff --git a/frontend/src/react/jav-detail/jav-detail-page.tsx b/frontend/src/react/jav-detail/jav-detail-page.tsx
index 25184f4a9..be3b34e14 100644
--- a/frontend/src/react/jav-detail/jav-detail-page.tsx
+++ b/frontend/src/react/jav-detail/jav-detail-page.tsx
@@ -5,7 +5,7 @@ import { entityPath, icon } from '@peach/legacy/core';
import { tagLabel } from '@peach/legacy/tags';
import { mountPreviewPlayer } from '../../player';
import { apiGet, errorMessage } from '../../api';
-import { Button } from '@/components/base/buttons/button';
+import { Button, ButtonLink } from '@/components/base/buttons/button';
import { CloudDownloadDialog, type DownloadPrefill } from '../activity/cloud-download-dialog';
import { Note } from '../components/note';
import { RetryNote } from '../components/grid-reveal';
@@ -91,13 +91,13 @@ function Work({ code, item, actions, readOnly, retry, retrying }: JavDetailProps
<span data-detail-tag="" data-tag-cat={tag.category} key={tag.name}><button type="button" data-tag={tag.name}
title={tagLabel(tag.name)} onClick={() => actions.openTag(tag.name)}>{tagLabel(tag.name)}</button></span>)}</div> : null}
{item.summary ? <p data-jav-summary="">{item.summary}</p> : null}
- {item.message ? <Note tone="neutral" action={<Button variant="secondary" {...busyProps(retrying)} onClick={retry}>重试</Button>}>{item.message}</Note> : null}
+ {item.message ? <Note tone="neutral" action={<Button variant="secondary" {...busyProps(retrying)} onClick={retry}>立即重试</Button>}>{item.message}</Note> : null}
<div data-jav-actions="">
+ {item.source_url ? <ButtonLink data-button-link="" variant="secondary" trailingIcon={RiExternalLinkLine}
+ href={item.source_url} target="_blank" rel="noopener noreferrer">作品来源</ButtonLink> : null}
+ <Button variant="secondary" disabled={readOnly} aria-pressed={!!wantId} {...busyProps(!!want.busy)} onClick={toggleWant}>{wantId ? '取消想要' : '想要'}</Button>
<Button variant="primary" onClick={() => setDownload({ code: item.code, title: item.title, performers: item.performers,
studio: item.studio, release_date: item.release_date, origin: `jav:${item.code}` })}>查找资源</Button>
- <Button variant="secondary" disabled={readOnly} aria-pressed={!!wantId} {...busyProps(!!want.busy)} onClick={toggleWant}>{wantId ? '取消想要' : '想要'}</Button>
- {item.source_url ? <Button variant="secondary" trailingIcon={RiExternalLinkLine}
- onClick={() => window.open(item.source_url, '_blank', 'noopener,noreferrer')}>作品来源</Button> : null}
</div>
{want.error ? <Note tone="error">{want.error}</Note> : null}
<Reviews code={item.code} count={item.comments_count} released={item.release_date} />
@@ -157,7 +157,7 @@ function PreviewVideo({ src }: { src: string }) {
node.append(video);
return mountPreviewPlayer(video, { src, type: /\.m3u8(?:\?|$)/i.test(src) ? 'application/x-mpegURL' : 'video/mp4' }, () => setFailed(true));
}, [src, attempt]);
- return <div ref={frame} data-jav-video="">{failed ? <Note tone="neutral" action={<Button variant="secondary" onClick={() => { setFailed(false); setAttempt(value => value + 1) }}>重试</Button>}>视频预览未取得</Note> : null}</div>;
+ return <div ref={frame} data-jav-video="">{failed ? <Note tone="neutral" action={<Button variant="secondary" onClick={() => { setFailed(false); setAttempt(value => value + 1) }}>立即重试</Button>}>视频预览未取得</Note> : null}</div>;
}
function Reviews({ code, count, released }: { code: string; count: number; released?: string }) {
@@ -196,7 +196,7 @@ function Reviews({ code, count, released }: { code: string; count: number; relea
{items.map(item => <article key={item.id} data-jav-review=""><div data-jav-review-meta=""><b>{item.username}</b>
{Number(item.score) > 0 ? <SourceRating score={Number(item.score)} review /> : null}
<time dateTime={item.created_at} title={item.created_at}>{item.created_at.slice(0, 10)}</time></div><p>{item.content}</p></article>)}
- {failure ? <Note tone="neutral" action={<Button variant="secondary" {...busyProps(result.isFetching)} onClick={() => { refresh.current = true; void result.refetch() }}>重试</Button>}>{failure}</Note>
+ {failure ? <Note tone="neutral" action={<Button variant="secondary" {...busyProps(result.isFetching)} onClick={() => { refresh.current = true; void result.refetch() }}>立即重试</Button>}>{failure}</Note>
: !result.isPending && !items.length ? <Note tone="neutral">暂无评论</Note> : null}
{!failure && pages.length ? <Button variant="secondary" {...busyProps(result.isFetching)}
onClick={() => { refresh.current = true; void result.refetch() }}>刷新评论</Button> : null}
diff --git a/frontend/src/react/jav/jav-page.tsx b/frontend/src/react/jav/jav-page.tsx
index eebd4d69d..724b66e04 100644
--- a/frontend/src/react/jav/jav-page.tsx
+++ b/frontend/src/react/jav/jav-page.tsx
@@ -150,10 +150,10 @@ function Discover({ readOnly, receipt, resource, query, navigate, clearText }: {
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={<>{query || tag ? <Button size="small" onClick={() => { clearText(); changeTag(''); writeJavQuery({ q: '', tag: '' }) }}>清除筛选</Button>
- : scope === 'library' ? <ButtonLink size="small" href="/">浏览馆藏</ButtonLink>
- : <Button size="small" onClick={() => resource({})}>查找作品</Button>}
- <ButtonLink size="small" href="/taste" variant="secondary">查看口味</ButtonLink></>}>
+ actions={<><ButtonLink size="small" href="/taste" variant="secondary">查看口味</ButtonLink>
+ {query || tag ? <Button variant="primary" size="small" onClick={() => { clearText(); changeTag(''); writeJavQuery({ q: '', tag: '' }) }}>清除筛选</Button>
+ : scope === 'library' ? <ButtonLink variant="primary" size="small" href="/">浏览馆藏</ButtonLink>
+ : <Button variant="primary" size="small" onClick={() => resource({})}>查找作品</Button>}</>}>
{query || tag ? '清除筛选后查看其他作品。' : scope === 'library' ? '观看或标记作品后,可以探索少看的馆藏。' : '可以查找番号,或更新关注来源。'}
</EmptyState> : null}
{action.error ? <Note tone="error">{action.error}</Note> : null}
@@ -195,13 +195,13 @@ function Discover({ readOnly, receipt, resource, query, navigate, clearText }: {
</div>
</div>
<div data-jav-actions="" className="flex flex-wrap gap-2">
- <Button variant="secondary" onClick={() => resource({ ...item, cover: item.has_cover ? coverUrl(item, true) : item.cover_url, origin: `${item.asset_id ? 'asset' : 'feed'}:${item.id}` })}>查找资源</Button>
+ {item.link ? <ButtonLink data-button-link="" variant="secondary" trailingIcon={RiExternalLinkLine} href={item.link} target="_blank" rel="noopener noreferrer">作品来源</ButtonLink> : null}
<Button variant="ghost" disabled={readOnly || item.wanted || !!item.asset_id} {...busyProps(action.busy === String(item.id))} onClick={() => {
void action.run(String(item.id), signal => addWant({ code: item.code }, signal), () => {
receipt('已加入想要'); void invalidateWants(); void discoveries.refetch();
});
}}>{item.asset_id ? '已入库' : item.wanted ? '已加入想要' : '想要'}</Button>
- {item.link ? <ButtonLink data-button-link="" variant="secondary" trailingIcon={RiExternalLinkLine} href={item.link} target="_blank" rel="noopener noreferrer">作品来源</ButtonLink> : null}
+ <Button variant="secondary" onClick={() => resource({ ...item, cover: item.has_cover ? coverUrl(item, true) : item.cover_url, origin: `${item.asset_id ? 'asset' : 'feed'}:${item.id}` })}>查找资源</Button>
</div>
</article>})}
</div>
diff --git a/frontend/src/react/library-processing/library-completion.tsx b/frontend/src/react/library-processing/library-completion.tsx
index 17258715b..e226e0fa3 100644
--- a/frontend/src/react/library-processing/library-completion.tsx
+++ b/frontend/src/react/library-processing/library-completion.tsx
@@ -71,7 +71,7 @@ function Completion({ assetIds, onComplete }: { assetIds: number[]; onComplete?(
start.mutate(command);
}} /></div>}>
{message}{' '}<LinkButton href="/data-cleanup#libraryProcessing" size="small" trailingIcon={RiArrowRightLine}>
- {problem ? '查看并处理' : '查看处理详情'}
+ {problem ? '打开扫描与采集' : '查看处理详情'}
</LinkButton></Note>
</section>;
}
diff --git a/frontend/src/react/library-processing/library-processing-notice.tsx b/frontend/src/react/library-processing/library-processing-notice.tsx
index 912038041..0ef62ee13 100644
--- a/frontend/src/react/library-processing/library-processing-notice.tsx
+++ b/frontend/src/react/library-processing/library-processing-notice.tsx
@@ -102,10 +102,10 @@ export function ProcessingNoticePanel({ state, problem = '', measure = false }:
{state?.stalled && !problem ? <p className="text-caption-1-regular">当前步骤耗时较长,正在等待进展</p> : null}
</div></div></CollapseRegion>
<div className="flex flex-wrap items-center justify-between gap-2 pt-3">
- {active ? <ProcessingControls state={state!} disabled={!!problem} /> : null}
<LinkButton href="/data-cleanup#libraryProcessing" variant="secondary" size="small" trailingIcon={RiArrowRightLine}>
- {problem || failed ? '查看并处理' : '任务详情'}
+ {problem || failed ? '打开扫描与采集' : '任务详情'}
</LinkButton>
+ {active ? <ProcessingControls state={state!} disabled={!!problem} /> : null}
</div>
</aside>;
}
diff --git a/frontend/src/react/library-shortcuts/shortcut-controls.tsx b/frontend/src/react/library-shortcuts/shortcut-controls.tsx
index 2853bc756..d4c75c185 100644
--- a/frontend/src/react/library-shortcuts/shortcut-controls.tsx
+++ b/frontend/src/react/library-shortcuts/shortcut-controls.tsx
@@ -141,7 +141,7 @@ function ShortcutContents({ currentHref, kind, close }: { currentHref?: () => st
</aside>
<div ref={content} data-shortcuts-content="" role="tabpanel" id={`${id}-content`} aria-labelledby={`${id}-${scope}`} tabIndex={0} className="flex min-h-0 min-w-0 flex-col gap-4 overflow-y-auto overscroll-contain">
{query.isPending ? <div aria-busy="true" data-skeleton="" className="h-12 animate-pulse rounded-lg bg-background-secondary-default" /> : null}
- {query.isError ? <Note tone="error" action={<Button variant="secondary" onClick={() => void query.refetch()}>重试</Button>}>{errorMessage(query.error)}</Note> : null}
+ {query.isError ? <Note tone="error" action={<Button variant="secondary" onClick={() => void query.refetch()}>立即重试</Button>}>{errorMessage(query.error)}</Note> : null}
{write.isError ? <Note tone="error">{errorMessage(write.error)}</Note> : null}
{data ? scope !== 'filters' ? <>
<Input aria-label="搜索收藏" placeholder="搜索收藏" leadingIcon={spriteGlyph('search')} value={search} onChange={setSearch} />
diff --git a/frontend/src/react/pages/setup/setup-page.tsx b/frontend/src/react/pages/setup/setup-page.tsx
index 09a10770e..1827a069c 100644
--- a/frontend/src/react/pages/setup/setup-page.tsx
+++ b/frontend/src/react/pages/setup/setup-page.tsx
@@ -46,7 +46,7 @@ export function SetupPage() {
<AuthCard title="欢迎使用 Peach" lede="添加媒体库,开始整理馆藏。" busy={view.kind === 'loading'}>
{view.kind === 'denied' ? <Note tone="error">请在运行 Peach 的这台电脑上打开设置。</Note> : null}
{view.kind === 'failed'
- ? <Note tone="error" action={<Button variant="secondary" onClick={retry}>重试</Button>}>{view.message}</Note>
+ ? <Note tone="error" action={<Button variant="secondary" onClick={retry}>立即重试</Button>}>{view.message}</Note>
: null}
{view.kind === 'form' ? <>
<Button variant="secondary" className="self-start" onClick={() => setRestoring((current) => !current)}>
diff --git a/frontend/src/react/review/bulk-toolbar.tsx b/frontend/src/react/review/bulk-toolbar.tsx
index 20bcd3543..a68f51e0e 100644
--- a/frontend/src/react/review/bulk-toolbar.tsx
+++ b/frontend/src/react/review/bulk-toolbar.tsx
@@ -86,10 +86,10 @@ export function BulkToolbar(props: BulkToolbarProps) {
{sources.map((source) => <SelectItem key={source} id={source}>{source}</SelectItem>)}
</Select>
) : null}
- <Button variant="primary" size="small" disabled={busy || !selected.size || !approvable}
- onClick={() => onRun('approved')}>通过所选</Button>
<Button variant="danger" size="small" disabled={busy || !selected.size}
onClick={() => onRun('rejected')}>拒绝所选</Button>
+ <Button variant="primary" size="small" disabled={busy || !selected.size || !approvable}
+ onClick={() => onRun('approved')}>通过所选</Button>
<Button variant="ghost" size="small" disabled={busy}
onClick={() => onSelected(new Set())}>取消选择</Button>
{feedback
diff --git a/frontend/src/react/review/review-page.tsx b/frontend/src/react/review/review-page.tsx
index 9a6e0bbc1..7dbd82cc8 100644
--- a/frontend/src/react/review/review-page.tsx
+++ b/frontend/src/react/review/review-page.tsx
@@ -328,7 +328,7 @@ export function ReviewPage(props: ReviewProps) {
)) : review.isError && !review.data ? (
/* 读不到队列和队列是空的不是一回事:说清楚是读取失败,给一颗重试键。 */
<Note tone="error" title="复核队列读取失败" action={
- <Button variant="secondary" size="small" disabled={review.isFetching} onClick={() => void review.refetch()}>重试</Button>
+ <Button variant="secondary" size="small" disabled={review.isFetching} onClick={() => void review.refetch()}>立即重试</Button>
}>
{errorMessage(review.error)}
</Note>
diff --git a/frontend/src/react/router/managed-routes.tsx b/frontend/src/react/router/managed-routes.tsx
index cb01f86a0..8893fcf8e 100644
--- a/frontend/src/react/router/managed-routes.tsx
+++ b/frontend/src/react/router/managed-routes.tsx
@@ -11,7 +11,7 @@
* 四张表的页面不走 `go`:它们在页内写地址一律由壳认领(`routeIndex`、资料页与关注页的 `actions.route`、
* 目录的换筛选、垃圾队列的换分类),跨页也交壳,打开次数同壳自己打开。 */
import type { ReactElement } from 'react';
-import { settingsPath, type ConfigurationPath } from '@peach/history';
+import type { ConfigurationPath } from '@peach/history';
import { javDisplayName, javTitleHtml } from '@peach/legacy/jav-title';
import { tagLabel } from '@peach/legacy/tags';
@@ -110,10 +110,9 @@ const configurationRoute = (path: ConfigurationPath): ManagedRoute<ManagedOpenPr
prefetch: async (_open, signal) => {
await Promise.all([prefetchConfiguration(signal), ...(path === '/settings/diagnostics' ? [prefetchDiagnostics(signal)] : [])]);
},
- page: (open, actions, go) => <ConfigurationPage receipt={message => actions.receipt(message)}
+ page: (open, actions) => <ConfigurationPage receipt={message => actions.receipt(message)}
reopenTutorial={actions.reopenTutorial} section={path === '/settings/diagnostics' ? '系统诊断' : open.section ?? ''}
- diagnostics={<DiagnosticsPage navigate={go} openItem={actions.openItem} receipt={message => actions.receipt(message)}
- configure={section => { actions.requestConfigurationSection(section); go(settingsPath(section)) }} />} />,
+ diagnostics={<DiagnosticsPage openItem={actions.openItem} receipt={message => actions.receipt(message)} />} />,
});
export const MANAGED_ROUTES: ManagedRouteTable = {
@@ -126,10 +125,7 @@ export const MANAGED_ROUTES: ManagedRouteTable = {
element: <ManagedMatch path="/stats" />,
prefetch: (_open, signal) => prefetchStats(signal),
/* 点一个内容标签是「回目录并按它筛选」,整页换成目录仍归壳。 */
- page: (_open, actions, go) => (
- <StatsPage tagLabel={tagLabel} onTag={actions.openTag}
- openMediaSettings={() => { actions.requestConfigurationSection('媒体库与入库'); go('/settings/library') }} />
- ),
+ page: (_open, actions) => <StatsPage tagLabel={tagLabel} onTag={actions.openTag} />,
},
'/taste': {
element: <ManagedMatch path="/taste" />,
@@ -199,8 +195,7 @@ export const MANAGED_ROUTES: ManagedRouteTable = {
prefetch: (open, signal) => prefetchFollowManage(signal, open.tab),
page: (open, actions) => (
<FollowManagePage {...open} route={actions.routeFollowManage} savePreference={actions.saveFollowPreference}
- toast={(message) => actions.receipt(message)} openFollow={actions.openFollow}
- openServiceConfiguration={() => actions.navigate('/settings/subscriptions')} />
+ toast={(message) => actions.receipt(message)} openFollow={actions.openFollow} />
),
},
};
diff --git a/frontend/src/react/router/shell-actions.ts b/frontend/src/react/router/shell-actions.ts
index 9de90eb24..7e71624dc 100644
--- a/frontend/src/react/router/shell-actions.ts
+++ b/frontend/src/react/router/shell-actions.ts
@@ -48,8 +48,6 @@ export interface ShellActions {
revealSource(id: number): Promise<string>;
/** 让安装教程重新出现。 */
reopenTutorial(): Promise<void>;
- /** 下一次打开配置页时选中的页签,只交给那一次。 */
- requestConfigurationSection(section: string): void;
/** 复核页把分类写回地址栏,不重开。 */
routeReview(params: { category: string }): void;
/** 关注管理页把页签、页码与排序写回地址栏,不重开。 */
@@ -173,7 +171,7 @@ export interface ManagedOpenProps extends Record<ConfigurationPath, { section?:
'/duplicates': Record<string, never>;
'/quality-goals': Record<string, never>;
'/sources': Record<string, never>;
- /** `section`:首帧选中的那一组页签名,取走 `requestConfigurationSection` 记下的那一次(地址带 `#peachProxy` 时是「网络与访问」)。 */
+ /** `section`:首帧选中的那一组页签名,取走壳里 `configurationRequestedSection` 记下的那一次(地址带 `#peachProxy` 时是「网络与访问」)。 */
'/settings/library': { section?: string };
'/tasks': Record<string, never>;
'/subscriptions': {
diff --git a/frontend/src/react/scraping/custom-sources.tsx b/frontend/src/react/scraping/custom-sources.tsx
index 49fea5ab4..67451bdce 100644
--- a/frontend/src/react/scraping/custom-sources.tsx
+++ b/frontend/src/react/scraping/custom-sources.tsx
@@ -41,7 +41,7 @@ export function CustomSources({ receipt }: { receipt(message: string): void }) {
(result) => { changed(result); receipt(source.enabled ? '已停用来源' : '已启用来源') })}>
{source.enabled ? '停用' : '启用'}</Button>
<Button variant="danger" onClick={() => confirmModal({ title: '删除自定义来源',
- body: `删除「${esc(source.name)}」后,采集将不再查询这个来源。`, confirmLabel: '删除来源',
+ body: `删除「${esc(source.name)}」后,采集将不再查询这个来源。`, confirmLabel: '删除来源', danger: true,
onConfirm: async () => { changed(await apiSend<{ items: Source[] }>(URL, { action: 'delete', id: source.id }));
setEditing(null); receipt('已删除来源') } })}>删除</Button>
</div>)}
diff --git a/frontend/src/react/settings/download-settings.tsx b/frontend/src/react/settings/download-settings.tsx
index 3fc860425..1f0c8da10 100644
--- a/frontend/src/react/settings/download-settings.tsx
+++ b/frontend/src/react/settings/download-settings.tsx
@@ -392,7 +392,7 @@ function PikPakAccount({ state, settle, receipt, username, setUsername }: CardPr
</>
);
const passwordLogin = (
- <Button type="submit" disabled={!state.available || waiting} {...busyProps(action.busy === 'login')}>登录</Button>
+ <Button type="submit" variant="primary" disabled={!state.available || waiting} {...busyProps(action.busy === 'login')}>登录</Button>
);
const outcomeFailed = browser.state === 'timeout' || browser.state === 'failed';
@@ -420,12 +420,12 @@ function PikPakAccount({ state, settle, receipt, username, setUsername }: CardPr
? <LoadingDots label={browser.message || '等你在浏览器窗口里登录 PikPak'} /> : null}>
{account.logged_in ? (
<Button variant="secondary" onClick={logout} disabled={!state.available} {...busyProps(action.busy === 'logout')}>登出</Button>
- ) : <>{passwordLogin}{!browser.available ? null : waiting ? (
+ ) : <>{!browser.available ? null : waiting ? (
<Button variant="secondary" type="button" onClick={cancelBrowser} {...busyProps(action.busy === 'cancel')}>取消</Button>
) : (
- <Button type="button" onClick={openBrowser} disabled={!state.available}
+ <Button variant="secondary" type="button" onClick={openBrowser} disabled={!state.available}
{...busyProps(action.busy === 'browser')}>用浏览器登录</Button>
- )}</>}
+ )}{passwordLogin}</>}
</Footer>
</Section>
);
diff --git a/frontend/src/react/settings/library-sharing-settings.tsx b/frontend/src/react/settings/library-sharing-settings.tsx
index 83f9e7cd0..dfca48427 100644
--- a/frontend/src/react/settings/library-sharing-settings.tsx
+++ b/frontend/src/react/settings/library-sharing-settings.tsx
@@ -66,15 +66,15 @@ export function LibrarySharingSettings({ initial, receipt }: {
</Stack> : null}
{action.error ? <Stack divided><ErrorText>{action.error}</ErrorText></Stack> : null}
<Footer>
+ {reviewing && !value.enabled ? <Button variant="secondary" onClick={() => {
+ setReviewing(false); setPreview(null); setAccepted(false);
+ }}>取消</Button> : null}
<Button variant="secondary" onClick={() => { setReviewing(true); void action.run('preview',
(signal) => apiGet<Preview>('/api/configuration/library-sharing/preview', signal),
(data) => { setPreview(data); setAccepted(false) }) }}
{...busyProps(action.busy === 'preview')}>预览上传内容</Button>
- {!value.enabled && preview ? <Button disabled={!accepted} onClick={() => save(true)}
+ {!value.enabled && preview ? <Button variant="primary" disabled={!accepted} onClick={() => save(true)}
{...busyProps(action.busy === 'save')}>同意并开启上传</Button> : null}
- {reviewing && !value.enabled ? <Button variant="secondary" onClick={() => {
- setReviewing(false); setPreview(null); setAccepted(false);
- }}>取消</Button> : null}
</Footer>
</>;
}
diff --git a/frontend/src/react/settings/release-updates.tsx b/frontend/src/react/settings/release-updates.tsx
index 0f4511e67..b35844663 100644
--- a/frontend/src/react/settings/release-updates.tsx
+++ b/frontend/src/react/settings/release-updates.tsx
@@ -119,12 +119,12 @@ export function ReleaseUpdates({ initial, initialJob }: { initial: ReleaseState;
) : null}
</Stack>}
<Footer status={<ExternalLink href={data.release_url}>查看发布页</ExternalLink>}>
- {job.state === 'ready' ? <Button onClick={confirmRestart}>重启安装</Button> : null}
- {data.state === 'available' && data.installation === '独立测试包' && job.state !== 'ready'
- ? <Button onClick={download} {...busyProps(running || action.busy === 'download')}>下载并安装</Button>
- : null}
<Button variant={job.state === 'ready' || (data.state === 'available' && data.installation === '独立测试包') ? 'secondary' : 'primary'}
disabled={running} onClick={check} {...busyProps(action.busy === 'check')}>检查更新</Button>
+ {data.state === 'available' && data.installation === '独立测试包' && job.state !== 'ready'
+ ? <Button variant="primary" onClick={download} {...busyProps(running || action.busy === 'download')}>下载并安装</Button>
+ : null}
+ {job.state === 'ready' ? <Button variant="primary" onClick={confirmRestart}>重启安装</Button> : null}
</Footer>
</Section>
);
diff --git a/frontend/src/react/stats/stats-page.tsx b/frontend/src/react/stats/stats-page.tsx
index adcec0dcc..b2b9d462e 100644
--- a/frontend/src/react/stats/stats-page.tsx
+++ b/frontend/src/react/stats/stats-page.tsx
@@ -17,7 +17,8 @@ import { Tab, TabList, TabPanel, Tabs } from 'react-aria-components';
import { fmtSize, LOC } from '@peach/legacy/core';
import { MEDIA_SOURCE_ICONS } from '@peach/legacy/ui';
-import { Button, ButtonLink } from '@/components/base/buttons/button';
+import { settingsPath } from '@peach/history';
+import { ButtonLink } from '@/components/base/buttons/button';
import { errorMessage } from '../../api';
import type { StatsProps } from '../bundle';
@@ -41,6 +42,9 @@ import {
type Attribution, type Count, type RecentPlay, type StatsData, type StorageVolume, type TagSource, type TopTag,
} from './stats';
+/** 空馆藏与没有存储来源时「添加媒体」去的那一栏设置。 */
+const MEDIA_SETTINGS = settingsPath('媒体库与入库');
+
/** 收起时露这么多条排行。三十条一次铺开会把下面两个面板整个顶到屏外。 */
const RANKING_PREVIEW = 10;
@@ -119,14 +123,14 @@ function Detail({ headline, children }: { headline: ReactNode; children: ReactNo
);
}
-function InventoryDetail({ data, openMediaSettings }: { data: StatsData } & StatsProps) {
+function InventoryDetail({ data }: { data: StatsData } & StatsProps) {
const videos = data.by_loc.reduce((sum, row) => sum + row.videos, 0);
if (!videos) {
return (
<EmptyState icon={RiVideoLine} title="还没有视频" actions={
<>
- <Button size="small" onClick={openMediaSettings}>添加媒体</Button>
<ButtonLink variant="secondary" href="/subscriptions?tab=add" size="small">添加关注</ButtonLink>
+ <ButtonLink variant="primary" href={MEDIA_SETTINGS} size="small">添加媒体</ButtonLink>
</>
}>{NO_VIDEO_HINT}</EmptyState>
);
@@ -205,11 +209,11 @@ function VolumeRow({ volume }: { volume: StorageVolume }) {
);
}
-function StorageDetail({ volumes, openMediaSettings }: { volumes: StorageVolume[] } & StatsProps) {
+function StorageDetail({ volumes }: { volumes: StorageVolume[] } & StatsProps) {
if (!volumes.length) {
return (
<EmptyState icon={RiHardDrive2Line} title="还没有存储来源" actions={
- <Button size="small" onClick={openMediaSettings}>添加媒体</Button>
+ <ButtonLink variant="primary" href={MEDIA_SETTINGS} size="small">添加媒体</ButtonLink>
}>{NO_VOLUME_HINT}</EmptyState>
);
}
diff --git a/frontend/src/react/taste/browser-sources.tsx b/frontend/src/react/taste/browser-sources.tsx
index 0d7e2707d..21dd3040a 100644
--- a/frontend/src/react/taste/browser-sources.tsx
+++ b/frontend/src/react/taste/browser-sources.tsx
@@ -39,8 +39,8 @@ export function BrowserSources({ browsers, sources, range, children }:
<Input label="资料目录或历史文件" value={path} onChange={setPath} maxLength={1024} isRequired isDisabled={change.isPending}
hint="请选择运行 Peach 的电脑上的浏览器资料。" />
<div className="flex gap-2">
- <Button type="submit" variant="secondary" disabled={!name.trim() || !path.trim()} {...busyProps(change.isPending)}>添加</Button>
<Button variant="ghost" disabled={change.isPending} onClick={() => { setAdding(false); change.reset() }}>取消</Button>
+ <Button type="submit" variant="secondary" disabled={!name.trim() || !path.trim()} {...busyProps(change.isPending)}>添加</Button>
</div>
</form> : null}
<div className="inline-grid w-full min-w-0 gap-2 sm:grid-cols-2">
@@ -70,7 +70,7 @@ export function BrowserSources({ browsers, sources, range, children }:
<Button variant="secondary" size="small" iconOnly leadingIcon={RiDeleteBinLine} {...busyProps(change.isPending)}
aria-label={`删除 ${browser.name}`} onClick={() => {
void confirmModal({ title: `删除 ${browser.name}`, body: '移除该浏览器的读取配置和已导入历史、书签,浏览器原文件保留。可以通过添加浏览器重新接入。',
- confirmLabel: '删除浏览器来源', onConfirm: () => change.mutateAsync({ operation: 'delete_browser', id: browser.id }) });
+ confirmLabel: '删除浏览器来源', danger: true, onConfirm: () => change.mutateAsync({ operation: 'delete_browser', id: browser.id }) });
}} />
</span>
</div>})}
diff --git a/frontend/src/react/video-wall/video-wall.tsx b/frontend/src/react/video-wall/video-wall.tsx
index 2e9699dd6..c8615b149 100644
--- a/frontend/src/react/video-wall/video-wall.tsx
+++ b/frontend/src/react/video-wall/video-wall.tsx
@@ -309,7 +309,7 @@ export function VideoWall({ items, finite, hasMore, busy, loading = false, error
</div>
<button type="button" data-wall-focus-close="" aria-label="收起作品" title="收起" onClick={() => close()}><svg viewBox="0 0 24 24" aria-hidden="true"><use href="#i-x" /></svg></button>
{error || (groupRef && groupQuery.error && !group) ? <div data-wall-play-error=""><Note tone="error">{error || requestErrorMessage(groupQuery.error)}</Note>
- {groupQuery.error && !group ? <Button size="small" variant="ghost" onClick={() => void groupQuery.refetch()}>重试</Button> : null}</div> : null}
+ {groupQuery.error && !group ? <Button size="small" variant="ghost" onClick={() => void groupQuery.refetch()}>立即重试</Button> : null}</div> : null}
<WallControls item={current} playing={playing} frame={playerFrame} starting={starting} pendingGroup={!!groupRef && groupQuery.isPending}
grouped={!!groupRef} queueOpen={queueOpen} queueReady={!!tracks.length && (!groupRef || !!group)}
hasPrevious={trackIndex > 0} hasNext={trackIndex >= 0 && trackIndex < tracks.length - 1}
@@ -413,7 +413,7 @@ export function VideoWall({ items, finite, hasMore, busy, loading = false, error
})}
</div>
</div>
- {!loading && queryError ? <div data-wall-error=""><Note tone="error">{queryError}</Note><Button size="small" variant="ghost" onClick={retry}>重试</Button></div> : null}
+ {!loading && queryError ? <div data-wall-error=""><Note tone="error">{queryError}</Note><Button size="small" variant="ghost" onClick={retry}>立即重试</Button></div> : null}
{!loading && !queryError && !items.length ? <div data-wall-empty="" onClick={async event => {
const control = (event.target as Element).closest('[data-wall-load-more]');
if (!control || busy || moreFlight.current) return;
@@ -423,7 +423,7 @@ export function VideoWall({ items, finite, hasMore, busy, loading = false, error
{!finite && (hasMore || items.length > 0) ? <div data-wall-refresh=""><Shuffle busy={busy} onPress={() => void fresh()} /></div> : null}
{hasMore && finite && items.length > 0 ? <div data-wall-footer=""><Button size="small" variant="secondary" {...busyProps(busy)} onClick={() => void more()}>
{busy ? <span dangerouslySetInnerHTML={{ __html:spinnerHtml() }} /> : null}载入更多</Button></div> : null}
- {moreError ? <div data-wall-error=""><Note tone="error">{moreError}</Note><Button size="small" variant="ghost" {...busyProps(busy)} onClick={() => void more()}>重试</Button></div> : null}
+ {moreError ? <div data-wall-error=""><Note tone="error">{moreError}</Note><Button size="small" variant="ghost" {...busyProps(busy)} onClick={() => void more()}>立即重试</Button></div> : null}
<button type="button" data-wall-tools-button="" aria-label="播放墙工具" title="播放墙工具" aria-expanded={toolsOpen} onClick={() => setToolsOpen(!toolsOpen)}>
<svg viewBox="0 0 24 24" aria-hidden="true"><use href="#i-settings" /></svg>
</button>
diff --git a/frontend/src/react/wants/want-list.tsx b/frontend/src/react/wants/want-list.tsx
index 4887eb382..dd02d2e35 100644
--- a/frontend/src/react/wants/want-list.tsx
+++ b/frontend/src/react/wants/want-list.tsx
@@ -74,17 +74,17 @@ function WantRow({ want, readOnly, busy, onReset, onRemove, onCloudDownload, dow
<p data-want-note="" className="text-caption-1-regular text-text-secondary">{searchNote(want)}</p> : null}
{want.scrape_error ? <ErrorLine text={want.scrape_error} prefix="资料未取得:" tone="muted" /> : null}
<div className="mt-1 flex flex-wrap items-center gap-2">
- {/* 还在找的两段才给云下载:未发售的没有资源可下,已入库的已经到手。 */}
- {want.phase === 'searching' || want.phase === 'given_up' ? (
- <Button variant="secondary" size="small" onClick={onCloudDownload}>查找资源</Button>
- ) : null}
+ {source ? <ButtonLink data-button-link="" variant="secondary" size="small" trailingIcon={RiExternalLinkLine} href={source} target="_blank" rel="noopener noreferrer">来源页</ButtonLink> : null}
+ <Button variant="secondary" size="small" leadingIcon={RiDeleteBinLine} disabled={readOnly} {...busyProps(busy === `remove:${want.id}`)}
+ onClick={onRemove}>移除</Button>
{want.phase === 'given_up' ? (
<Button variant="secondary" size="small" disabled={readOnly} {...busyProps(busy === `reset:${want.id}`)}
onClick={onReset}>重新查找</Button>
) : null}
- <Button variant="secondary" size="small" leadingIcon={RiDeleteBinLine} disabled={readOnly} {...busyProps(busy === `remove:${want.id}`)}
- onClick={onRemove}>移除</Button>
- {source ? <ButtonLink data-button-link="" variant="secondary" size="small" trailingIcon={RiExternalLinkLine} href={source} target="_blank" rel="noopener noreferrer">来源页</ButtonLink> : null}
+ {/* 还在找的两段才给云下载:未发售的没有资源可下,已入库的已经到手。 */}
+ {want.phase === 'searching' || want.phase === 'given_up' ? (
+ <Button variant="secondary" size="small" onClick={onCloudDownload}>查找资源</Button>
+ ) : null}
</div>
</div>
</div>
diff --git a/frontend/src/react/wants/want-magnets.tsx b/frontend/src/react/wants/want-magnets.tsx
index a771670a0..277644006 100644
--- a/frontend/src/react/wants/want-magnets.tsx
+++ b/frontend/src/react/wants/want-magnets.tsx
@@ -144,14 +144,14 @@ export function WantMagnets({ want, readOnly, downloads, provider, toast, onSour
</div>
</div>
<div data-resource-actions="" className="flex flex-wrap gap-2">
+ <ButtonLink data-button-link="" variant="secondary" size="small" trailingIcon={RiExternalLinkLine} href={candidate.source_url} target="_blank" rel="noopener noreferrer">链接来源</ButtonLink>
+ <Button variant="secondary" size="small" leadingIcon={RiFileCopyLine} {...busyProps(action.busy === `copy:${candidate.id}`)}
+ onClick={() => copy(candidate)}>复制链接</Button>
{candidate.protocol === 'magnet' ?
<Button variant="primary" size="small" leadingIcon={configured ? providerIcon(configured.key) : RiCloudLine} title={configured ? `下载到 ${configured.label}` : undefined} disabled={readOnly || !downloads?.available || !configured || added}
{...busyProps(action.busy === candidate.id)} onClick={() => add(candidate)}>
{added ? '已添加' : '添加下载'}
</Button> : null}
- <Button variant={candidate.protocol === 'magnet' ? 'secondary' : 'primary'} size="small" leadingIcon={RiFileCopyLine} {...busyProps(action.busy === `copy:${candidate.id}`)}
- onClick={() => copy(candidate)}>复制链接</Button>
- <ButtonLink data-button-link="" variant="secondary" size="small" trailingIcon={RiExternalLinkLine} href={candidate.source_url} target="_blank" rel="noopener noreferrer">链接来源</ButtonLink>
</div>
</li>;
});
diff --git a/frontend/src/ui-kit/index.ts b/frontend/src/ui-kit/index.ts
index f4db28357..b2cd50a4c 100644
--- a/frontend/src/ui-kit/index.ts
+++ b/frontend/src/ui-kit/index.ts
@@ -27,6 +27,7 @@ export { confirmModal, formModal } from './modal';
export {
isCurrentPostSetupTutorialRequest, nextPostSetupTutorialRequest, POST_SETUP_TUTORIAL_COLLAPSED_KEY,
POST_SETUP_TUTORIAL_KEY, POST_SETUP_TUTORIAL_SKIPPED_KEY, postSetupTutorialCollapsed, postSetupTutorialMarker,
- postSetupTutorialSignature, postSetupTutorialSkipped, resetPostSetupTutorialState, setPostSetupTutorialCollapsed,
+ postSetupTutorialErrorHtml, postSetupTutorialSignature, postSetupTutorialSkipped, resetPostSetupTutorialState,
+ setPostSetupTutorialCollapsed,
setPostSetupTutorialMarker, setPostSetupTutorialSkipped,
} from '../onboarding/post-setup-tutorial';
diff --git a/frontend/src/ui-kit/markup.ts b/frontend/src/ui-kit/markup.ts
index b9f1fd42b..9ed522510 100644
--- a/frontend/src/ui-kit/markup.ts
+++ b/frontend/src/ui-kit/markup.ts
@@ -30,7 +30,8 @@ function noteDetailsHtml({label='',items=[],footnote=''}:NoteDetails={}){
/* Inline, persistent context beside the field/card/section it describes.
恢复动作有两种形态:留在本页执行的走按钮,要离开本页才做得成的走链接。
- 两者占同一个格子、同一枚 `data-note-action`,Note 的版式不因为它是 <a> 改变。 */
+ 两者占同一个格子、同一枚 `data-note-action`,Note 的版式不因为它是 <a> 改变;
+ 都是次要样式,与 React `Note` 的 `action` 一致,主动作留给 Note 所在区域自己的那一枚。 */
/** Geist Note:字段、卡片、分区旁的持久反馈。 */
export function noteHtml(message:any,{variant='secondary',label='',className='',size='medium',filled=false,actionLabel='',actionHref='',details=null}:{
variant?: 'secondary' | 'warning' | 'error' | 'success' | (string & {});
@@ -48,7 +49,7 @@ export function noteHtml(message:any,{variant='secondary',label='',className='',
const role=kind==='error'?' role="alert"':' role="note"';
const action=!actionLabel?''
:actionHref?`<a class="geist-button" href="${esc(actionHref)}" data-note-action>${esc(actionLabel)}</a>`
- :`<button type="button" class="geist-button primary" data-note-action>${esc(actionLabel)}</button>`;
+ :`<button type="button" class="geist-button" data-note-action>${esc(actionLabel)}</button>`;
return `<div class="geist-note geist-note-${kind}${className?` ${esc(className)}`:''}${size==='small'?' geist-note-small':''}${filled?' geist-note-filled':''}"${role}>
${icon(symbol)}<p>${label?`<b>${esc(label)}</b>`:''}<span>${esc(kind==='error'?requestErrorMessage(message):message)}</span></p>${action}${details?noteDetailsHtml(details):''}</div>`;
}
diff --git a/frontend/test/feedback.test.ts b/frontend/test/feedback.test.ts
index a6e557d89..a7b3cdfb3 100644
--- a/frontend/test/feedback.test.ts
+++ b/frontend/test/feedback.test.ts
@@ -40,9 +40,11 @@ describe('持久提示控件',()=>{
expect(host.querySelector('.ui-geist-gauge')?.getAttribute('data-level')).toBe(level);
expect(gaugeHtml('完成率',value,100)).toContain('data-level="normal"');
});
- it('失败提示包含一个内部操作按钮',()=>{
- const host=document.createElement('div');host.innerHTML=noteHtml('来源离线',{variant:'error',filled:true,actionLabel:'重试'});
- expect(host.querySelectorAll('[role=alert] button')).toHaveLength(1);
+ it('失败提示包含一个次要样式的内部操作按钮',()=>{
+ const host=document.createElement('div');host.innerHTML=noteHtml('来源离线',{variant:'error',filled:true,actionLabel:'立即重试'});
+ const buttons=host.querySelectorAll('[role=alert] button');
+ expect(buttons).toHaveLength(1);
+ expect(buttons[0]!.classList.contains('primary')).toBe(false);
});
it('容量比例和任务计数使用真实上限,未知容量不显示零',()=>{
const host=document.createElement('div');host.innerHTML=gaugeHtml('使用率',25,50);
diff --git a/frontend/test/post-setup-tutorial.test.ts b/frontend/test/post-setup-tutorial.test.ts
index 1cae41c8d..99d105929 100644
--- a/frontend/test/post-setup-tutorial.test.ts
+++ b/frontend/test/post-setup-tutorial.test.ts
@@ -9,6 +9,7 @@ import {
isCurrentPostSetupTutorialRequest,
nextPostSetupTutorialRequest,
postSetupTutorialCollapsed,
+ postSetupTutorialErrorHtml,
postSetupTutorialMarker,
postSetupTutorialSignature,
postSetupTutorialSkipped,
@@ -98,3 +99,10 @@ describe('安装教程的状态', () => {
expect([...postSetupTutorialSkipped()]).toEqual([]);
});
});
+
+it('取不到清单时关闭在左、立即重试在右', () => {
+ const host = document.createElement('div');
+ host.innerHTML = postSetupTutorialErrorHtml('');
+ expect([...host.querySelectorAll('.post-setup-error-actions button')].map((button) => button.textContent))
+ .toEqual(['关闭', '立即重试']);
+});
diff --git a/frontend/test/react/application.test.tsx b/frontend/test/react/application.test.tsx
index d8e5e1884..047587bc8 100644
--- a/frontend/test/react/application.test.tsx
+++ b/frontend/test/react/application.test.tsx
@@ -47,7 +47,7 @@ function actions(): ShellActions {
openItem: vi.fn(), openEntity: vi.fn(), openTag: vi.fn(), openTasteSignal: vi.fn(), navigate: vi.fn(),
openManage: vi.fn(), managePath: vi.fn(() => ''), openFollow: vi.fn(), receipt: vi.fn(), toast: vi.fn(),
failure: vi.fn(), revealSource: vi.fn(async () => ''), reopenTutorial: vi.fn(async () => {}),
- requestConfigurationSection: vi.fn(), routeReview: vi.fn(), routeFollowManage: vi.fn(),
+ routeReview: vi.fn(), routeFollowManage: vi.fn(),
saveFollowPreference: vi.fn(), srcBadge: () => '', routeIndex: vi.fn(), savePeopleLayout: vi.fn(),
exitSelectMode: vi.fn(), personAvatar: vi.fn(() => ({ html: '', face: '' })), authorAvatar: vi.fn(() => ''),
showIndexTags: vi.fn(), openFollowAuthor: vi.fn(), openFollowTag: vi.fn(), openPlaylist: vi.fn(),
diff --git a/frontend/test/react/avatar-picker.test.tsx b/frontend/test/react/avatar-picker.test.tsx
index ba77204e8..54320fceb 100644
--- a/frontend/test/react/avatar-picker.test.tsx
+++ b/frontend/test/react/avatar-picker.test.tsx
@@ -188,6 +188,7 @@ it('地址栏填了才允许取图,取回来的那一份进框选,交的是
});
await openPicker();
expect(buttonNamed('用这个地址')?.disabled).toBe(true);
+ expect(buttonNamed('用这个地址')?.className).not.toContain('bg-button-primary');
await type(document.querySelector<HTMLInputElement>('input[aria-label="图片地址"]'), ' https://example.com/a.jpg ');
expect(buttonNamed('用这个地址')?.disabled).toBe(false);
await click(buttonNamed('用这个地址'));
@@ -316,7 +317,7 @@ it('候选没取到时原因旁边有「重试」,点了再取一遍', async (
expect(dialog()?.querySelector('[role="alert"]')?.textContent).toContain('候选读不出来');
expect(document.querySelector('[role="listbox"]')).toBeNull();
fail = false;
- await click(buttonNamed('重试'));
+ await click(buttonNamed('立即重试'));
await settle();
expect(fetched).toHaveBeenCalledTimes(2);
expect(cells()).toHaveLength(1);
@@ -333,7 +334,7 @@ it('提交失败的原因旁边不给「重试」:重来的是那颗提交键
await click(cells()[0]);
await settle();
expect(dialog()?.querySelector('[role="alert"]')).not.toBeNull();
- expect(buttonNamed('重试')).toBeNull();
+ expect(buttonNamed('立即重试')).toBeNull();
});
it('保存失败返回候选并重新选图时只显示当前操作的错误', async () => {
diff --git a/frontend/test/react/batch-dock.test.tsx b/frontend/test/react/batch-dock.test.tsx
index c7a000600..26acb6b48 100644
--- a/frontend/test/react/batch-dock.test.tsx
+++ b/frontend/test/react/batch-dock.test.tsx
@@ -61,7 +61,7 @@ function shellActions(): ShellActions {
openItem: vi.fn(), openEntity: vi.fn(), openTag: vi.fn(), openTasteSignal: vi.fn(), navigate: vi.fn(),
openManage: vi.fn(), managePath: vi.fn(() => ''), openFollow: vi.fn(), receipt: vi.fn(), toast: vi.fn(),
failure: vi.fn(), revealSource: vi.fn(async () => ''), reopenTutorial: vi.fn(async () => {}),
- requestConfigurationSection: vi.fn(), routeReview: vi.fn(),
+ routeReview: vi.fn(),
routeFollowManage: vi.fn(), saveFollowPreference: vi.fn(), srcBadge: () => '', routeIndex: vi.fn(),
savePeopleLayout: vi.fn(), exitSelectMode: vi.fn(), personAvatar: vi.fn(() => ({ html: '', face: '' })),
authorAvatar: vi.fn(() => ''), showIndexTags: vi.fn(), openFollowAuthor: vi.fn(), openFollowTag: vi.fn(),
diff --git a/frontend/test/react/browse-routes.test.tsx b/frontend/test/react/browse-routes.test.tsx
index c02be34cf..7a38f132e 100644
--- a/frontend/test/react/browse-routes.test.tsx
+++ b/frontend/test/react/browse-routes.test.tsx
@@ -44,7 +44,7 @@ function shellActions(): ShellActions {
openItem: vi.fn(), openEntity: vi.fn(), openTag: vi.fn(), openTasteSignal: vi.fn(), navigate: vi.fn(),
openManage: vi.fn(), managePath: vi.fn(() => ''), openFollow: vi.fn(), receipt: vi.fn(), toast: vi.fn(),
failure: vi.fn(), revealSource: vi.fn(async () => ''), reopenTutorial: vi.fn(async () => {}),
- requestConfigurationSection: vi.fn(), routeReview: vi.fn(),
+ routeReview: vi.fn(),
routeFollowManage: vi.fn(), saveFollowPreference: vi.fn(), srcBadge: () => '', routeIndex: vi.fn(),
savePeopleLayout: vi.fn(), exitSelectMode: vi.fn(), personAvatar: vi.fn(() => ({ html: '', face: '' })),
authorAvatar: vi.fn(() => ''), showIndexTags: vi.fn(), openFollowAuthor: vi.fn(), openFollowTag: vi.fn(),
@@ -197,7 +197,7 @@ function followHelpers(): FollowFeedHelpers {
}
function followActions(): FollowFeedActions {
return {
- route: vi.fn(), shuffle: vi.fn(), loaded: vi.fn(), openDetail: vi.fn(), openAuthor: vi.fn(), openManage: vi.fn(), toggleSelection: vi.fn(),
+ route: vi.fn(), shuffle: vi.fn(), loaded: vi.fn(), openDetail: vi.fn(), openAuthor: vi.fn(), toggleSelection: vi.fn(),
setImagesOnly: vi.fn(), setPhotoLayout: vi.fn(), canFlip: () => false, toast: vi.fn(), failure: vi.fn(), checkReport: vi.fn(),
};
}
diff --git a/frontend/test/react/browser-sources.test.tsx b/frontend/test/react/browser-sources.test.tsx
new file mode 100644
index 000000000..ef5eb56b7
--- /dev/null
+++ b/frontend/test/react/browser-sources.test.tsx
@@ -0,0 +1,26 @@
+import { QueryClientProvider } from '@tanstack/react-query';
+import { afterEach, expect, it, vi } from 'vitest';
+import * as legacyUi from '@peach/legacy/ui';
+import { queryClient } from '../../src/react/query';
+import { BrowserSources } from '../../src/react/taste/browser-sources';
+import { actionOrder, buttonNamed, click, mount } from './render';
+
+afterEach(() => { queryClient.clear(); vi.restoreAllMocks() });
+
+const browser = { id: 'chrome', name: 'Chrome', path: 'C:\\Chrome\\User Data', enabled: true, available: true, profiles: 2 };
+const open = () => mount(<QueryClientProvider client={queryClient}>
+ <BrowserSources browsers={[browser]} sources={[]} range="90d" />
+</QueryClientProvider>);
+
+it('添加浏览器的表单取消在左、添加在右', async () => {
+ const host = await open();
+ await click(buttonNamed('添加浏览器', host));
+ expect(actionOrder(host.querySelector('form'))).toEqual(['取消', '添加']);
+});
+
+it('删除浏览器来源会删掉已导入的历史,确认弹层用危险样式', async () => {
+ const modal = vi.spyOn(legacyUi, 'confirmModal').mockResolvedValue({ confirmed: false });
+ const host = await open();
+ await click(host.querySelector('[aria-label="删除 Chrome"]'));
+ expect(modal.mock.calls[0]?.[0]).toMatchObject({ title: '删除 Chrome', confirmLabel: '删除浏览器来源', danger: true });
+});
diff --git a/frontend/test/react/catalog-routes.test.tsx b/frontend/test/react/catalog-routes.test.tsx
index af223cb51..3c9ebeb03 100644
--- a/frontend/test/react/catalog-routes.test.tsx
+++ b/frontend/test/react/catalog-routes.test.tsx
@@ -42,7 +42,7 @@ function shellActions(): ShellActions {
openItem: vi.fn(), openEntity: vi.fn(), openTag: vi.fn(), openTasteSignal: vi.fn(), navigate: vi.fn(),
openManage: vi.fn(), managePath: vi.fn(() => ''), openFollow: vi.fn(), receipt: vi.fn(), toast: vi.fn(),
failure: vi.fn(), revealSource: vi.fn(async () => ''), reopenTutorial: vi.fn(async () => {}),
- requestConfigurationSection: vi.fn(), routeReview: vi.fn(),
+ routeReview: vi.fn(),
routeFollowManage: vi.fn(), saveFollowPreference: vi.fn(), srcBadge: () => '', routeIndex: vi.fn(),
savePeopleLayout: vi.fn(), exitSelectMode: vi.fn(), personAvatar: vi.fn(() => ({ html: '', face: '' })),
authorAvatar: vi.fn(() => ''), showIndexTags: vi.fn(), openFollowAuthor: vi.fn(), openFollowTag: vi.fn(),
diff --git a/frontend/test/react/custom-sources.test.tsx b/frontend/test/react/custom-sources.test.tsx
index 177b55109..06a109d7f 100644
--- a/frontend/test/react/custom-sources.test.tsx
+++ b/frontend/test/react/custom-sources.test.tsx
@@ -1,6 +1,7 @@
import { act } from 'react';
import { notifyManager, QueryClientProvider } from '@tanstack/react-query';
import { afterEach, expect, it, vi } from 'vitest';
+import * as legacyUi from '@peach/legacy/ui';
import { queryClient } from '../../src/react/query';
import { CustomSources } from '../../src/react/scraping/custom-sources';
import { click, mount, pending, settle, type } from './render';
@@ -46,3 +47,15 @@ it('试查期间修改配置后不展示旧请求的结果', async () => {
expect(host.querySelector('pre')).toBeNull();
expect(host.textContent).not.toContain('旧请求标题');
});
+
+it('删除自定义来源的确认弹层用危险样式', async () => {
+ const row = { id: 'custom-1234567890abcdef', name: '示例来源', endpoint: 'https://example.com/{code}',
+ fields: { code: 'id' }, content_types: ['censored'], enabled: true };
+ vi.stubGlobal('fetch', vi.fn(async () => ({ ok: true, status: 200, json: async () => ({ items: [row] }) })));
+ const modal = vi.spyOn(legacyUi, 'confirmModal').mockResolvedValue({ confirmed: false });
+ const host = await mount(<QueryClientProvider client={queryClient}><CustomSources receipt={vi.fn()} /></QueryClientProvider>);
+ await settle();
+ await click(Array.from(host.querySelectorAll('button')).find(button => button.textContent === '删除'));
+ expect(modal.mock.calls[0]?.[0]).toMatchObject({ title: '删除自定义来源', confirmLabel: '删除来源', danger: true });
+ modal.mockRestore();
+});
diff --git a/frontend/test/react/data-cleanup.test.tsx b/frontend/test/react/data-cleanup.test.tsx
index 4092cfc6b..cd48b9d6f 100644
--- a/frontend/test/react/data-cleanup.test.tsx
+++ b/frontend/test/react/data-cleanup.test.tsx
@@ -22,7 +22,7 @@ import { hasResourceRoots, RESOURCE_SCAN_KEY, type ResourceScanState } from '../
import { IDLE_REPAIR } from '../../src/react/media-repair/media-repair';
import type { MediaSourcesData } from '../../src/react/media-sources';
import { queryClient } from '../../src/react/query';
-import { buttonNamed, choose, click, mount, settle, type } from './render';
+import { actionOrder, buttonNamed, choose, click, mount, settle, type } from './render';
afterEach(() => {
queryClient.clear();
@@ -513,6 +513,17 @@ describe('孤儿记录', () => {
expect(buttonNamed('删除记录', rows[1]!)).toBeTruthy();
});
+ it('删除记录在最左,转移记录是这一行的主动作、排在最右', async () => {
+ serve({ '/api/orphan-records': orphans });
+ const host = await wrap(<OrphanRecordsCard toast={vi.fn()} />);
+ await settle();
+ const row = host.querySelector('[aria-label="文件已消失的作品"] tbody tr')!;
+ const order = actionOrder(buttonNamed('删除记录', row)!.parentElement);
+ expect(order[0]).toBe('删除记录');
+ expect(order.at(-1)).toBe('转移记录');
+ expect(buttonNamed('转移记录', row)!.className).toContain('bg-button-primary');
+ });
+
it('转移记录直接发,目标默认是时长最接近的那个', async () => {
const server = serve({ '/api/orphan-records': orphans, '/api/orphan-records/attach': { ok: true, batch: 'user:reattach@1' } });
const toast = vi.fn();
@@ -714,6 +725,20 @@ describe('整理', () => {
expect(buttonNamed('执行整理', host)).toBeNull();
});
+ it('底栏回滚在左、预览居中、执行整理在最右;只有执行整理在场时预览才退成次级', async () => {
+ organizeServer({ ...organizeIdle, last_batch: 'batch-9' });
+ queryClient.setQueryData(['organize'], { ...organizeIdle, last_batch: 'batch-9' });
+ const host = await wrap(<OrganizeCard toast={vi.fn()} failure={vi.fn()} />);
+ const footer = () => host.querySelector('[data-cleanup-organize] footer');
+ expect(actionOrder(footer())).toEqual(['回滚上一批', '预览']);
+ expect(buttonNamed('预览', host)!.className).toContain('bg-button-primary');
+ await click(buttonNamed('预览', host));
+ await settle();
+ expect(actionOrder(footer())).toEqual(['回滚上一批', '预览', '执行整理']);
+ expect(buttonNamed('预览', host)!.className).not.toContain('bg-button-primary');
+ expect(buttonNamed('执行整理', host)!.className).toContain('bg-button-primary');
+ });
+
it('有上一批才给回滚;回滚也先确认,取消就不发', async () => {
const seen = confirmWith(false);
const server = organizeServer({ ...organizeIdle, last_batch: 'batch-9' });
diff --git a/frontend/test/react/diagnostics.test.tsx b/frontend/test/react/diagnostics.test.tsx
index 3c4c06b54..c5318710f 100644
--- a/frontend/test/react/diagnostics.test.tsx
+++ b/frontend/test/react/diagnostics.test.tsx
@@ -3,7 +3,7 @@ import { afterEach, expect, it, vi } from 'vitest';
import { queryClient } from '../../src/react/query';
import { DiagnosticsPage } from '../../src/react/diagnostics/diagnostics-page';
import { DIAGNOSTICS_KEY, type DiagnosticReport } from '../../src/react/diagnostics/diagnostics';
-import { buttonNamed, click, fetchMock, mount, settle } from './render';
+import { buttonNamed, click, fetchMock, linkNamed, mount, settle } from './render';
notifyManager.setScheduler(notify => notify());
afterEach(() => queryClient.clear());
@@ -20,18 +20,18 @@ const data = (): DiagnosticReport => ({ version: 'test', status: 'warning', chec
} }, sources: [{ source: 'javdb', label: 'javdb', status: 'unknown', reason: '当前解析状态未取得', last_success_at: null, cooldown_until: null }] });
async function open(report = data()) {
queryClient.setQueryData(DIAGNOSTICS_KEY, report);
- const props = { navigate: vi.fn(), configure: vi.fn(), openItem: vi.fn(), receipt: vi.fn() };
+ const props = { openItem: vi.fn(), receipt: vi.fn() };
const host = await mount(<QueryClientProvider client={queryClient}><DiagnosticsPage {...props} /></QueryClientProvider>);
return { host, props };
}
it('诊断跳到具体配置分栏,系统权限项只显示动作', async () => {
- const { host, props } = await open();
- await click(buttonNamed('打开媒体库与入库', host));
- await click(buttonNamed('打开网络与访问', host));
- expect(props.configure.mock.calls).toEqual([['媒体库与入库'], ['网络与访问']]);
+ const { host } = await open();
+ expect(linkNamed('打开媒体库与入库', host)?.getAttribute('href')).toBe('/settings/library');
+ expect(linkNamed('打开网络与访问', host)?.getAttribute('href')).toBe('/settings/network');
+ expect(buttonNamed('打开媒体库与入库', host)).toBeNull();
const root = [...host.querySelectorAll('h3')].find(node => node.textContent === '数据目录')!.parentElement!.parentElement!;
expect(root.textContent).toContain('调整权限');
- expect(root.querySelector('button')).toBeNull();
+ expect(root.querySelector('button, a')).toBeNull();
expect(host.textContent).toContain('当前解析状态未取得');
});
it('展开作品表格并复制可识别信息;零结果有独立空态', async () => {
@@ -51,7 +51,7 @@ it('展开作品表格并复制可识别信息;零结果有独立空态', asyn
});
it('请求失败保留原因和重试入口', async () => {
vi.stubGlobal('fetch', fetchMock(403, { detail: '请在运行 Peach 的电脑上打开系统诊断' }));
- const props = { navigate: vi.fn(), configure: vi.fn(), openItem: vi.fn(), receipt: vi.fn() };
+ const props = { openItem: vi.fn(), receipt: vi.fn() };
const host = await mount(<QueryClientProvider client={queryClient}><DiagnosticsPage {...props} /></QueryClientProvider>);
await settle();
expect(host.textContent).toContain('诊断读取失败');
@@ -79,11 +79,11 @@ it('恢复动作的名称与实际目标一致', async () => {
report.checks.security.target = '/settings/network';
report.checks.ffmpeg = { label: '媒体工具', status: 'warning', reason: '缺少 FFmpeg', action: '安装工具', target: '/settings/maintenance', details: {} };
report.checks.tasks = { label: '后台任务', status: 'warning', reason: '有任务失败', action: '查看原因', target: '/tasks', details: {} };
- const { host, props } = await open(report);
- await click(buttonNamed('打开网络与访问', host));
- await click(buttonNamed('打开维护与更新', host));
- await click(buttonNamed('查看任务', host));
- expect(props.navigate.mock.calls).toEqual([['/settings/network'], ['/settings/maintenance'], ['/tasks']]);
+ const { host } = await open(report);
+ expect(linkNamed('打开网络与访问', host)?.getAttribute('href')).toBe('/settings/network');
+ expect(linkNamed('打开应用与维护', host)?.getAttribute('href')).toBe('/settings/maintenance');
+ expect(linkNamed('查看任务', host)?.getAttribute('href')).toBe('/tasks');
+ expect(linkNamed('打开来源和凭证', host)?.getAttribute('href')).toBe('/sources');
});
it('诊断报告下载成功生成文件;失败原因保留在入口旁', async () => {
diff --git a/frontend/test/react/download-settings.test.tsx b/frontend/test/react/download-settings.test.tsx
index 65911817b..c15478f0b 100644
--- a/frontend/test/react/download-settings.test.tsx
+++ b/frontend/test/react/download-settings.test.tsx
@@ -3,7 +3,7 @@ import { expect, it, vi } from 'vitest';
import { DownloadSettings } from '../../src/react/settings/download-settings';
import type { DownloadCheckReport, DownloadSettingsState } from '../../src/react/bundle';
-import { buttonNamed, click, fetchMock, mount, pending, section, sentBody, settle, submit, type } from './render';
+import { actionOrder, buttonNamed, click, fetchMock, mount, pending, section, sentBody, settle, submit, type } from './render';
vi.mock('../../src/react/settings/jav-browser-settings', () => ({ JavBrowserSettings: () => null }));
@@ -96,7 +96,7 @@ it('保存时令牌随表单交给服务端,回来后清空,提示改成已
expect(field(host, 'CloudDrive2 API 令牌')?.placeholder).toBe('已保存,留空不改');
});
-it('检查报出缺的权限、目标目录与剩余配额,保存与登录使用主按钮', async () => {
+it('检查报出缺的权限、目标目录与剩余配额,保存与账号密码登录使用主按钮', async () => {
vi.stubGlobal('fetch', fetchMock(200, {
ok: true, address: 'http://127.0.0.1:19798', permissions: [{ name: 'a', label: '提交离线任务', granted: true },
{ name: 'b', label: '取消离线任务', granted: false }],
@@ -104,9 +104,10 @@ it('检查报出缺的权限、目标目录与剩余配额,保存与登录使
quota: { total: 1500, used: 3, left: 1497 }, problems: [],
}));
const host = await mount(<DownloadSettings initial={state()} receipt={vi.fn()} />);
- for (const name of ['保存配置', '用浏览器登录', '登录']) {
+ for (const name of ['保存配置', '登录']) {
expect(buttonNamed(name, host)?.className, name).toContain('bg-button-primary');
}
+ expect(buttonNamed('用浏览器登录', host)?.className).not.toContain('bg-button-primary');
expect(buttonNamed('检查连接', host)?.className).not.toContain('bg-button-primary');
await click(buttonNamed('检查连接', host));
await settle();
@@ -375,6 +376,7 @@ it('账号密码表单直接显示,两种登录方式共用底栏', async () =
expect(field(host, '账号')).not.toBeNull();
expect(buttonNamed('登录', host)?.parentElement).toBe(buttonNamed('用浏览器登录', host)?.parentElement);
expect(buttonNamed('用浏览器登录', host)?.type).toBe('button');
+ expect(actionOrder(buttonNamed('登录', host)?.parentElement)).toEqual(['用浏览器登录', '登录']);
});
it('这台电脑没有浏览器时只剩账号密码登录,直接摊开', async () => {
@@ -421,6 +423,7 @@ it('刷新页面时登录窗口还开着就接着轮询,点取消回到可以
vi.stubGlobal('fetch', fetcher);
const host = await mount(<DownloadSettings initial={browserAt('waiting')} receipt={vi.fn()} />);
expect(host.querySelector('[role="status"]')?.textContent).toContain('等你在浏览器窗口里登录 PikPak');
+ expect(actionOrder(buttonNamed('取消', host)?.parentElement)).toEqual(['取消', '登录']);
await click(buttonNamed('取消', host));
await settle();
expect(fetcher.mock.calls[0]?.[0]).toBe(`${BROWSER_URL}/cancel`);
diff --git a/frontend/test/react/entity-controller.test.ts b/frontend/test/react/entity-controller.test.ts
index 5ae89e34f..6384ff214 100644
--- a/frontend/test/react/entity-controller.test.ts
+++ b/frontend/test/react/entity-controller.test.ts
@@ -10,7 +10,7 @@ import type { FollowFeedActions, FollowFeedHelpers } from '../../src/react/follo
const followHelpers: FollowFeedHelpers = { workMark: () => '', tagLabel: tag => tag, wireDrag: vi.fn(), wireScroller: vi.fn(),
listSkeletonHtml: () => '', jobProgress: vi.fn() };
-const followActions: FollowFeedActions = { route: vi.fn(), shuffle: vi.fn(), loaded: vi.fn(), openDetail: vi.fn(), openAuthor: vi.fn(), openManage: vi.fn(),
+const followActions: FollowFeedActions = { route: vi.fn(), shuffle: vi.fn(), loaded: vi.fn(), openDetail: vi.fn(), openAuthor: vi.fn(),
toggleSelection: vi.fn(), setImagesOnly: vi.fn(), setPhotoLayout: vi.fn(), canFlip: () => true, toast: vi.fn(),
failure: vi.fn(), checkReport: vi.fn() };
const helpers: EntityPageHelpers = { portraitImg: entityPortraitImg, wireDrag: vi.fn(), wireScroller: vi.fn(), wireFeedRow: vi.fn(),
diff --git a/frontend/test/react/entity-page.test.tsx b/frontend/test/react/entity-page.test.tsx
index cba188578..f126798dc 100644
--- a/frontend/test/react/entity-page.test.tsx
+++ b/frontend/test/react/entity-page.test.tsx
@@ -140,7 +140,7 @@ function shellProps(patch: Partial<EntityPageProps> = {}): EntityPageProps {
follow: {
helpers: { workMark: () => '', tagLabel: (tag) => tag, wireDrag: vi.fn(), wireScroller: vi.fn(),
listSkeletonHtml: () => '<div data-test-follow-skeleton></div>', jobProgress: vi.fn() },
- actions: { route: vi.fn(), shuffle: vi.fn(), loaded: vi.fn(), openDetail: vi.fn(), openAuthor: vi.fn(), openManage: vi.fn(),
+ actions: { route: vi.fn(), shuffle: vi.fn(), loaded: vi.fn(), openDetail: vi.fn(), openAuthor: vi.fn(),
toggleSelection: vi.fn(), setImagesOnly: vi.fn(), setPhotoLayout: vi.fn(), canFlip: () => false, toast: vi.fn(),
failure: vi.fn(), checkReport: vi.fn() },
},
diff --git a/frontend/test/react/entity-routes.test.tsx b/frontend/test/react/entity-routes.test.tsx
index 72a71ba31..88adc3538 100644
--- a/frontend/test/react/entity-routes.test.tsx
+++ b/frontend/test/react/entity-routes.test.tsx
@@ -46,7 +46,7 @@ function shellActions(): ShellActions {
openItem: vi.fn(), openEntity: vi.fn(), openTag: vi.fn(), openTasteSignal: vi.fn(), navigate: vi.fn(),
openManage: vi.fn(), managePath: vi.fn(() => ''), openFollow: vi.fn(), receipt: vi.fn(), toast: vi.fn(),
failure: vi.fn(), revealSource: vi.fn(async () => ''), reopenTutorial: vi.fn(async () => {}),
- requestConfigurationSection: vi.fn(), routeReview: vi.fn(),
+ routeReview: vi.fn(),
routeFollowManage: vi.fn(), saveFollowPreference: vi.fn(), srcBadge: () => '', routeIndex: vi.fn(),
savePeopleLayout: vi.fn(), exitSelectMode: vi.fn(), personAvatar: vi.fn(() => ({ html: '', face: '' })),
authorAvatar: vi.fn(() => ''), showIndexTags: vi.fn(), openFollowAuthor: vi.fn(), openFollowTag: vi.fn(),
@@ -147,7 +147,7 @@ function entityProps(name: string, hosts: EntityPageProps['hosts']): EntityPageP
follow: {
helpers: { workMark: () => '', tagLabel: (tag) => tag, wireDrag: vi.fn(), wireScroller: vi.fn(),
listSkeletonHtml: () => '<div data-test-follow-skeleton></div>', jobProgress: vi.fn() },
- actions: { route: vi.fn(), shuffle: vi.fn(), loaded: vi.fn(), openDetail: vi.fn(), openAuthor: vi.fn(), openManage: vi.fn(),
+ actions: { route: vi.fn(), shuffle: vi.fn(), loaded: vi.fn(), openDetail: vi.fn(), openAuthor: vi.fn(),
toggleSelection: vi.fn(), setImagesOnly: vi.fn(), setPhotoLayout: vi.fn(), canFlip: () => false, toast: vi.fn(),
failure: vi.fn(), checkReport: vi.fn() },
},
diff --git a/frontend/test/react/follow-controller.test.ts b/frontend/test/react/follow-controller.test.ts
index 512416063..91284a120 100644
--- a/frontend/test/react/follow-controller.test.ts
+++ b/frontend/test/react/follow-controller.test.ts
@@ -10,7 +10,7 @@ const view = (patch: Partial<FollowView> = {}): FollowView => ({ status: '', med
work: '', tags: [], durMin: 0, durMax: 0, sort: 'new', dir: 'desc', seed: 7, ...patch });
const helpers: FollowFeedHelpers = { workMark: () => '', tagLabel: tag => tag, wireDrag: vi.fn(), wireScroller: vi.fn(),
listSkeletonHtml: () => '', jobProgress: vi.fn() };
-const delegated: Omit<FollowFeedActions, 'route' | 'shuffle'> = { loaded: vi.fn(), openDetail: vi.fn(), openAuthor: vi.fn(), openManage: vi.fn(),
+const delegated: Omit<FollowFeedActions, 'route' | 'shuffle'> = { loaded: vi.fn(), openDetail: vi.fn(), openAuthor: vi.fn(),
toggleSelection: vi.fn(), setImagesOnly: vi.fn(), setPhotoLayout: vi.fn(), canFlip: () => true, toast: vi.fn(),
failure: vi.fn(), checkReport: vi.fn() };
diff --git a/frontend/test/react/follow-feed.test.tsx b/frontend/test/react/follow-feed.test.tsx
index 634d4d885..156994557 100644
--- a/frontend/test/react/follow-feed.test.tsx
+++ b/frontend/test/react/follow-feed.test.tsx
@@ -235,7 +235,7 @@ function helpers(): FollowFeedHelpers {
function actions(): FollowFeedActions {
return {
- route: vi.fn(), shuffle: vi.fn(), loaded: vi.fn(), openDetail: vi.fn(), openAuthor: vi.fn(), openManage: vi.fn(), toggleSelection: vi.fn(),
+ route: vi.fn(), shuffle: vi.fn(), loaded: vi.fn(), openDetail: vi.fn(), openAuthor: vi.fn(), toggleSelection: vi.fn(),
setImagesOnly: vi.fn(), setPhotoLayout: vi.fn(), canFlip: () => false, toast: vi.fn(), failure: vi.fn(), checkReport: vi.fn(),
};
}
@@ -358,9 +358,10 @@ describe('页面', () => {
const given = props();
const host = await open(given);
expect(host.querySelector('[data-follow-title]')?.textContent).toBe('关注');
- await click(host.querySelector('[data-follow-manage]'));
- expect(given.actions.openManage).toHaveBeenCalled();
- expect(host.querySelector('[data-media-error] [data-note-action]')?.textContent).toBe('重试');
+ const manage = host.querySelector('[data-follow-manage]');
+ expect(manage?.tagName).toBe('A');
+ expect(manage?.getAttribute('href')).toBe('/subscriptions');
+ expect(host.querySelector('[data-media-error] [data-note-action]')?.textContent).toBe('立即重试');
});
it('有来源、一条更新都还没有:没设筛选时说还没有更新,设了筛选才叫人换筛选', async () => {
diff --git a/frontend/test/react/follow-manage.test.tsx b/frontend/test/react/follow-manage.test.tsx
index 16d591959..30e2e5308 100644
--- a/frontend/test/react/follow-manage.test.tsx
+++ b/frontend/test/react/follow-manage.test.tsx
@@ -22,7 +22,7 @@ import {
import { FollowManagePage } from '../../src/react/follow-manage/follow-manage-page';
import { Credentials } from '../../src/react/follow-manage/credentials';
-import { buttonNamed, choose, click, mountRoot, settle, type } from './render';
+import { actionOrder, buttonNamed, choose, click, linkNamed, mountRoot, settle, type } from './render';
// 客户端是模块级的单例(所有 React 根共用一个),用例之间不清就互相喂数据。
afterEach(() => queryClient.clear());
@@ -145,6 +145,7 @@ it('只检查已启用的失败来源,并随清单隐藏入口', async () => {
const data = follow({ sources: [source({ id: 1 }), source({ id: 2, last_status: 'error' }),
source({ id: 3, last_status: 'unauthorized' }), source({ id: 4, enabled: false, last_status: 'error' })] });
const { host, fetcher } = await open({ data });
+ expect(actionOrder(host.querySelector('[data-follow-toolbar-actions]')).slice(0, 2)).toEqual(['检查失败项', '检查全部']);
await click(buttonNamed('检查失败项', host)!);
const request = fetcher.mock.calls.find(([url, init]) => url === FOLLOW_CHECK_URL && init?.method);
expect(JSON.parse(String(request?.[1]?.body)).sources).toEqual([2, 3]);
@@ -162,7 +163,6 @@ const shellProps = (over: Partial<Props> = {}): Props => ({
savePreference: vi.fn(),
toast: vi.fn(),
openFollow: vi.fn(),
- openServiceConfiguration: vi.fn(),
readOnly: false, readOnlyMessage: '', writerUrl: '',
...over,
});
@@ -713,7 +713,7 @@ it('各栏按做事的先后排,缺凭据的数挂在最后一栏上', async (
const { host } = await open({ creds: { root: 'C:\\creds', providers: [credential({ provider: 'fanbox' })] } });
expect([...host.querySelectorAll('[role="tab"]')].map((tab) => tab.textContent))
.toEqual(['关注列表', '添加关注', 'JAV 订阅源']);
- expect(buttonNamed('来源与订阅设置(1)', host)).not.toBeNull();
+ expect(linkNamed('来源与订阅设置(1)', host)?.getAttribute('href')).toBe('/settings/subscriptions');
});
const FEEDS: FeedsData = {
@@ -1008,6 +1008,7 @@ it('按名字查找列出每张演员卡,同一个人的两张先勾上;说
await click(boxNamed(host, '無碼'));
expect(buttonNamed('添加订阅(1)', host)).not.toBeNull();
+ expect(actionOrder(buttonNamed('添加订阅(1)', host)!.parentElement)).toEqual(['关闭', '添加订阅(1)']);
await click(buttonNamed('添加订阅(1)', host));
await settle();
expect(feedWrite).toHaveBeenCalledWith({ action: 'follow-name', name: '瀬戸環奈', ids: ['Kn01'] });
@@ -1288,14 +1289,15 @@ it('来源筛选按钮写着筛到哪几个站,筛掉的站既不显示也不
await click(buttonNamed('全选'));
expect(buttonLabelled(host, '全部来源')).not.toBeNull();
expect(buttonNamed('添加选中(2)', host)).not.toBeNull();
+ expect(actionOrder(buttonNamed('添加选中(2)', host)!.parentElement)).toEqual(['关闭', '添加选中(2)']);
});
-it('筛选里撞见缺凭据的站,一步跳到凭据那一栏', async () => {
+it('筛选里撞见缺凭据的站,凭据入口是指到来源与订阅设置的链接', async () => {
const creds = { root: 'C:\\creds', providers: [credential({ provider: 'fanbox', provider_label: 'Fanbox' })] };
- const { host, props } = await open({ creds }, { tab: 'add' });
+ const { host } = await open({ creds }, { tab: 'add' });
await click(buttonLabelled(host, '全部来源'));
- await click(buttonNamed('需要配置凭据'));
- expect(props.openServiceConfiguration).toHaveBeenCalledOnce();
+ expect(buttonNamed('打开凭据设置')).toBeNull();
+ expect(linkNamed('打开凭据设置')?.getAttribute('href')).toBe('/settings/subscriptions');
});
it('「猜你喜欢」点一下就拿那个名字去查', async () => {
@@ -1534,6 +1536,7 @@ it('凭据填在页面上,保存后输入框清空,空着点保存会被拦
// 已经配好的那一行才给「清除」。
expect(buttonNamed('清除', fanbox)).toBeNull();
expect(buttonNamed('清除', credentialRow(host, 'Patreon'))).not.toBeNull();
+ expect(actionOrder(buttonNamed('清除', credentialRow(host, 'Patreon'))!.parentElement)).toEqual(['清除', '保存配置']);
});
it('凭据文件路径可展开,权限过宽警告在凭据收起时可见', async () => {
diff --git a/frontend/test/react/immerse.test.tsx b/frontend/test/react/immerse.test.tsx
index 975298c68..987de85cd 100644
--- a/frontend/test/react/immerse.test.tsx
+++ b/frontend/test/react/immerse.test.tsx
@@ -168,7 +168,7 @@ function shellActions(): ShellActions {
openItem: vi.fn(), openEntity: vi.fn(), openTag: vi.fn(), openTasteSignal: vi.fn(), navigate: vi.fn(),
openManage: vi.fn(), managePath: vi.fn(() => ''), openFollow: vi.fn(), receipt: vi.fn(), toast: vi.fn(),
failure: vi.fn(), revealSource: vi.fn(async () => ''), reopenTutorial: vi.fn(async () => {}),
- requestConfigurationSection: vi.fn(), routeReview: vi.fn(),
+ routeReview: vi.fn(),
routeFollowManage: vi.fn(), saveFollowPreference: vi.fn(), srcBadge: () => '', routeIndex: vi.fn(),
savePeopleLayout: vi.fn(), exitSelectMode: vi.fn(), personAvatar: vi.fn(() => ({ html: '', face: '' })),
authorAvatar: vi.fn(() => ''), showIndexTags: vi.fn(), openFollowAuthor: vi.fn(), openFollowTag: vi.fn(),
diff --git a/frontend/test/react/jav-page.test.tsx b/frontend/test/react/jav-page.test.tsx
index 2559cb80a..1fb35505c 100644
--- a/frontend/test/react/jav-page.test.tsx
+++ b/frontend/test/react/jav-page.test.tsx
@@ -5,7 +5,7 @@ import { JavPage } from '../../src/react/jav/jav-page';
import { JavHeader } from '../../src/react/jav/jav-header';
import { discoveryKey, prefetchJav } from '../../src/react/jav/jav';
import { WANTS_KEY } from '../../src/react/wants/wants';
-import { buttonNamed, click, mount, settle, type } from './render';
+import { actionOrder, buttonNamed, click, mount, settle, type } from './render';
notifyManager.setScheduler(notify => notify());
afterEach(() => queryClient.clear());
@@ -75,6 +75,7 @@ it('发现按范围读取,清除文字和标签恢复列表,卡片打开对
const host = await mount(<QueryClientProvider client={queryClient}><JavPage tab="discover" readOnly navigate={navigate} receipt={vi.fn()} /></QueryClientProvider>);
await settle();
expect(host.querySelectorAll('[data-jav-card]')).toHaveLength(2);
+ expect(actionOrder(host.querySelector('[data-jav-card] [data-jav-actions]'))).toEqual(['作品来源', '想要', '查找资源']);
expect(host.querySelector('[data-jav-card] h3')?.textContent).toContain('ABC-001');
await click(host.querySelector('[data-jav-card] [data-media-tag]'));
expect(host.querySelectorAll('[data-jav-card]')).toHaveLength(1);
@@ -93,3 +94,12 @@ it('发现按范围读取,清除文字和标签恢复列表,卡片打开对
expect(navigate).toHaveBeenLastCalledWith('/assets/22');
expect(buttonNamed('已入库', host)?.disabled).toBe(true);
});
+
+it('没有推荐时空态的查看口味在左,主入口在右', async () => {
+ vi.stubGlobal('fetch', vi.fn(async () => ({ ok: true, status: 200, json: async () => ({ items: [] }) })));
+ const host = await mount(<QueryClientProvider client={queryClient}><JavPage tab="discover" readOnly navigate={vi.fn()} receipt={vi.fn()} /></QueryClientProvider>);
+ await settle();
+ expect(actionOrder(host.querySelector('[data-empty-state]'))).toEqual(['查看口味', '浏览馆藏']);
+ const main = [...host.querySelectorAll('[data-empty-state] a')].find((link) => link.textContent === '浏览馆藏');
+ expect(main?.className).toContain('bg-button-primary');
+});
diff --git a/frontend/test/react/junk-queue.test.tsx b/frontend/test/react/junk-queue.test.tsx
index f8372c465..9cf5c2035 100644
--- a/frontend/test/react/junk-queue.test.tsx
+++ b/frontend/test/react/junk-queue.test.tsx
@@ -159,7 +159,7 @@ describe('计数行', () => {
const { host } = await open(p);
expect(p.countRow!.querySelector('[data-skeleton]')).toBeNull();
expect(p.countRow!.querySelector('[data-collection-summary] strong')?.textContent).toBe('—');
- expect(host.querySelector('[data-media-error] [data-note-action]')?.textContent).toBe('重试');
+ expect(host.querySelector('[data-media-error] [data-note-action]')?.textContent).toBe('立即重试');
expect(cards(host)).toHaveLength(0);
});
});
diff --git a/frontend/test/react/library-completion.test.tsx b/frontend/test/react/library-completion.test.tsx
index 8f493677a..2a6afdbd5 100644
--- a/frontend/test/react/library-completion.test.tsx
+++ b/frontend/test/react/library-completion.test.tsx
@@ -110,6 +110,6 @@ it('启动失败保留入口与处理详情,不显示完成回执', async () =
await click(buttonNamed('同步这些影片', host));
expect(host.textContent).toContain('请先添加媒体目录');
expect(host.textContent).not.toContain('补全完成');
- expect(host.querySelector('a[href="/data-cleanup#libraryProcessing"]')?.textContent).toBe('查看并处理');
+ expect(host.querySelector('a[href="/data-cleanup#libraryProcessing"]')?.textContent).toBe('打开扫描与采集');
expect(buttonNamed('同步这些影片', host)?.disabled).toBe(false);
});
diff --git a/frontend/test/react/library-processing.test.tsx b/frontend/test/react/library-processing.test.tsx
index 11d550d52..03df5307e 100644
--- a/frontend/test/react/library-processing.test.tsx
+++ b/frontend/test/react/library-processing.test.tsx
@@ -16,7 +16,7 @@ import { LibraryProcessingCard } from '../../src/react/library-processing/librar
import { LibraryProcessingNotice } from '../../src/react/library-processing/library-processing-notice';
import type { LibraryProcessingProps } from '../../src/react/bundle';
-import { buttonNamed as textButtonNamed, click, mount, mountRoot, submit } from './render';
+import { actionOrder, buttonNamed as textButtonNamed, click, mount, mountRoot, submit } from './render';
const buttonNamed = (name: string, root: ParentNode = document) =>
[...root.querySelectorAll('button')].find(button => button.getAttribute('aria-label') === name)
@@ -434,6 +434,10 @@ it('暂停与继续使用同一个任务号,暂停不是完成,暂停时仍
});
const host = await mount(notice({ toast, onComplete, mode: 'notice' }));
expect(host.textContent).toContain('预计剩余约 20–40 分钟(粗估)');
+ // 去任务详情的链接在左,暂停这类原地控制在右。
+ const bar = actionOrder(host.querySelector('a[href="/data-cleanup#libraryProcessing"]')!.parentElement);
+ expect(bar[0]).toBe('任务详情');
+ expect(bar.indexOf('暂停')).toBeGreaterThan(0);
await click(buttonNamed('暂停', host));
expect(host.textContent).toContain('正在暂停,当前步骤结束后暂停');
state = { ...state, status: 'paused' };
diff --git a/frontend/test/react/library-sharing.test.tsx b/frontend/test/react/library-sharing.test.tsx
index b5fb5b080..31930ac94 100644
--- a/frontend/test/react/library-sharing.test.tsx
+++ b/frontend/test/react/library-sharing.test.tsx
@@ -1,7 +1,7 @@
import { describe, expect, it, vi } from 'vitest';
import { LibrarySharingSettings, type LibrarySharingState } from '../../src/react/settings/library-sharing-settings';
-import { buttonNamed, click, mount, settle, switches } from './render';
+import { actionOrder, buttonNamed, click, mount, settle, switches } from './render';
const initial: LibrarySharingState = { enabled: false, available: true, schema: 4,
fields: ['作品编号、标签、评分与全部偏好维度'], notice: '匿名处理后上传馆藏与各类偏好明细。' };
@@ -37,6 +37,7 @@ describe('馆藏与口味分享的明确同意', () => {
expect(fetcher).toHaveBeenCalledTimes(1);
expect(host.textContent).toContain('KiB。不含账号、设备、文件路径和浏览器历史记录等个人数据。');
expect((buttonNamed('同意并开启上传', host) as HTMLButtonElement).disabled).toBe(true);
+ expect(actionOrder(buttonNamed('同意并开启上传', host)!.parentElement)).toEqual(['取消', '预览上传内容', '同意并开启上传']);
await click(host.querySelector('input[type="checkbox"]:not([role="switch"])'));
await click(buttonNamed('同意并开启上传', host));
await settle();
diff --git a/frontend/test/react/maintenance-settings.test.tsx b/frontend/test/react/maintenance-settings.test.tsx
index 26ff89fc8..174f97e03 100644
--- a/frontend/test/react/maintenance-settings.test.tsx
+++ b/frontend/test/react/maintenance-settings.test.tsx
@@ -7,7 +7,7 @@ import {
AutomaticUpdates, MaintenanceSettings, TutorialSettings, UninstallSettings,
} from '../../src/react/settings/maintenance-settings';
import { ReleaseUpdates } from '../../src/react/settings/release-updates';
-import { buttonNamed, choose, click, fetchMock, mount, section, sentBody, settle, submit, switches } from './render';
+import { actionOrder, buttonNamed, choose, click, fetchMock, mount, section, sentBody, settle, submit, switches } from './render';
const automatic = { mode: 'off', interval_hours: 24, available: true, download_available: true };
const release: ReleaseState = {
@@ -118,6 +118,7 @@ describe('检查更新', () => {
expect(updates.textContent).toContain('最新版本0.10.0');
expect(updates.querySelector('[role="status"]')?.textContent).toContain('有可用更新');
expect(buttonNamed('下载并安装', updates)).not.toBeNull();
+ expect(actionOrder(check.parentElement)).toEqual(['查看发布页', '检查更新', '下载并安装']);
expect(document.activeElement).toBe(check);
vi.stubGlobal('fetch', fetchMock(503, { detail: '连接失败' }));
await click(check);
diff --git a/frontend/test/react/manage-header.test.tsx b/frontend/test/react/manage-header.test.tsx
index 9148b5688..05170d06b 100644
--- a/frontend/test/react/manage-header.test.tsx
+++ b/frontend/test/react/manage-header.test.tsx
@@ -68,7 +68,7 @@ function shellActions(): ShellActions {
openItem: vi.fn(), openEntity: vi.fn(), openTag: vi.fn(), openTasteSignal: vi.fn(), navigate: vi.fn(),
openManage: vi.fn(), managePath: vi.fn(() => ''), openFollow: vi.fn(), receipt: vi.fn(), toast: vi.fn(),
failure: vi.fn(), revealSource: vi.fn(async () => ''), reopenTutorial: vi.fn(async () => {}),
- requestConfigurationSection: vi.fn(), routeReview: vi.fn(),
+ routeReview: vi.fn(),
routeFollowManage: vi.fn(), saveFollowPreference: vi.fn(), srcBadge: () => '', routeIndex: vi.fn(),
savePeopleLayout: vi.fn(), exitSelectMode: vi.fn(), personAvatar: vi.fn(() => ({ html: '', face: '' })),
authorAvatar: vi.fn(() => ''), showIndexTags: vi.fn(), openFollowAuthor: vi.fn(), openFollowTag: vi.fn(),
diff --git a/frontend/test/react/managed-routes.test.tsx b/frontend/test/react/managed-routes.test.tsx
index dfcea2617..255dd1fb8 100644
--- a/frontend/test/react/managed-routes.test.tsx
+++ b/frontend/test/react/managed-routes.test.tsx
@@ -47,7 +47,7 @@ function shellActions(): ShellActions {
openItem: vi.fn(), openEntity: vi.fn(), openTag: vi.fn(), openTasteSignal: vi.fn(), navigate: vi.fn(),
openManage: vi.fn(), managePath: vi.fn((section: string) => sections[section] ?? ''), openFollow: vi.fn(),
receipt: vi.fn(), toast: vi.fn(), failure: vi.fn(), revealSource: vi.fn(async () => ''),
- reopenTutorial: vi.fn(async () => {}), requestConfigurationSection: vi.fn(),
+ reopenTutorial: vi.fn(async () => {}),
routeReview: vi.fn(), routeFollowManage: vi.fn(), saveFollowPreference: vi.fn(), srcBadge: () => '',
routeIndex: vi.fn(), savePeopleLayout: vi.fn(), exitSelectMode: vi.fn(),
personAvatar: vi.fn(() => ({ html: '', face: '' })), authorAvatar: vi.fn(() => ''), showIndexTags: vi.fn(),
@@ -357,32 +357,23 @@ function element<P>(path: keyof Loaded['MANAGED_ROUTES'], r: Loaded, open: objec
open, actions, go).props;
}
-it('诊断页先选配置分栏再导航,作品与任务交给共享入口', async () => {
+it('诊断页的作品交给共享入口,去处是页内链接不再经过 go', async () => {
const r = await load();
const actions = shellActions();
- const order: string[] = [];
- const go = vi.fn((path: string) => { order.push(path) });
- vi.mocked(actions.requestConfigurationSection).mockImplementation(section => { order.push(section) });
+ const go = vi.fn();
const page = element<ConfigurationProps & { diagnostics: ReactElement<DiagnosticsProps> }>('/settings/diagnostics', r, {}, actions, go);
const props = page.diagnostics.props;
- props.configure('网络与访问');
props.openItem(12);
- props.navigate('/tasks');
- expect(order).toEqual(['网络与访问', '/settings/network', '/tasks']);
expect(actions.openItem).toHaveBeenCalledWith(12);
+ expect(go).not.toHaveBeenCalled();
});
-it('统计页:点标签交壳回目录;添加媒体先交页签再换到配置页', async () => {
+it('统计页:点标签交壳回目录', async () => {
const r = await load();
const actions = shellActions();
- const order: string[] = [];
- const go = vi.fn((path: string) => { order.push(`go ${path}`) });
- vi.mocked(actions.requestConfigurationSection).mockImplementation((section) => { order.push(`section ${section}`) });
- const props = element<StatsProps>('/stats', r, {}, actions, go);
+ const props = element<StatsProps>('/stats', r, {}, actions, vi.fn());
props.onTag('痴女');
- props.openMediaSettings();
expect(vi.mocked(actions.openTag).mock.calls).toEqual([['痴女']]);
- expect(order).toEqual(['section 媒体库与入库', 'go /settings/library']);
expect(props.tagLabel('JK制服')).toBe('JK制服');
});
diff --git a/frontend/test/react/pages/catalog.test.tsx b/frontend/test/react/pages/catalog.test.tsx
index e0ea83408..8fe0798ae 100644
--- a/frontend/test/react/pages/catalog.test.tsx
+++ b/frontend/test/react/pages/catalog.test.tsx
@@ -42,7 +42,7 @@ function shellActions() {
openItem: vi.fn(), openEntity: vi.fn(), openTag: vi.fn(), openTasteSignal: vi.fn(), navigate: vi.fn(),
openManage: vi.fn(), managePath: vi.fn(() => ''), openFollow: vi.fn(), receipt: vi.fn(), toast: vi.fn(),
failure: vi.fn(), revealSource: vi.fn(async () => ''), reopenTutorial: vi.fn(async () => {}),
- requestConfigurationSection: vi.fn(), routeReview: vi.fn(),
+ routeReview: vi.fn(),
routeFollowManage: vi.fn(), saveFollowPreference: vi.fn(), srcBadge: () => '', routeIndex: vi.fn(),
savePeopleLayout: vi.fn(), exitSelectMode: vi.fn(), personAvatar: vi.fn(() => ({ html: '', face: '' })),
authorAvatar: vi.fn(() => ''), showIndexTags: vi.fn(), openFollowAuthor: vi.fn(), openFollowTag: vi.fn(),
diff --git a/frontend/test/react/pages/follow.test.tsx b/frontend/test/react/pages/follow.test.tsx
index 9cac8b766..0ecdfb80f 100644
--- a/frontend/test/react/pages/follow.test.tsx
+++ b/frontend/test/react/pages/follow.test.tsx
@@ -45,7 +45,7 @@ const helpers: FollowFeedHelpers = {
listSkeletonHtml: () => '<div data-test-skeleton>骨架</div>', jobProgress: () => {},
};
const feedActions: FollowFeedActions = {
- route: () => {}, shuffle: () => {}, loaded: () => {}, openDetail: () => {}, openAuthor: () => {}, openManage: () => {}, toggleSelection: () => {},
+ route: () => {}, shuffle: () => {}, loaded: () => {}, openDetail: () => {}, openAuthor: () => {}, toggleSelection: () => {},
setImagesOnly: () => {}, setPhotoLayout: () => {}, canFlip: () => false, toast: () => {}, failure: () => {}, checkReport: () => {},
};
@@ -63,7 +63,7 @@ function shellActions(r: Loaded) {
openItem: vi.fn(), openEntity: vi.fn(), openTag: vi.fn(), openTasteSignal: vi.fn(), navigate: vi.fn(),
openManage: vi.fn(), managePath: vi.fn(() => ''), openFollow: vi.fn(), receipt: vi.fn(), toast: vi.fn(),
failure: vi.fn(), revealSource: vi.fn(async () => ''), reopenTutorial: vi.fn(async () => {}),
- requestConfigurationSection: vi.fn(), routeReview: vi.fn(),
+ routeReview: vi.fn(),
routeFollowManage: vi.fn(), saveFollowPreference: vi.fn(), srcBadge: () => '', routeIndex: vi.fn(),
savePeopleLayout: vi.fn(), exitSelectMode: vi.fn(), personAvatar: vi.fn(() => ({ html: '', face: '' })),
authorAvatar: vi.fn(() => ''), showIndexTags: vi.fn(), openFollowAuthor: vi.fn(), openFollowTag: vi.fn(),
diff --git a/frontend/test/react/pages/index-entity.test.tsx b/frontend/test/react/pages/index-entity.test.tsx
index 93af08a1f..edd6c5c79 100644
--- a/frontend/test/react/pages/index-entity.test.tsx
+++ b/frontend/test/react/pages/index-entity.test.tsx
@@ -50,7 +50,7 @@ function shellActions(refreshed = { ok: true }) {
openItem: vi.fn(), openEntity: vi.fn(), openTag: vi.fn(), openTasteSignal: vi.fn(), navigate: vi.fn(),
openManage: vi.fn(), managePath: vi.fn(() => ''), openFollow: vi.fn(), receipt: vi.fn(), toast: vi.fn(),
failure: vi.fn(), revealSource: vi.fn(async () => ''), reopenTutorial: vi.fn(async () => {}),
- requestConfigurationSection: vi.fn(), routeReview: vi.fn(),
+ routeReview: vi.fn(),
routeFollowManage: vi.fn(), saveFollowPreference: vi.fn(), srcBadge: () => '', routeIndex: vi.fn(),
savePeopleLayout: vi.fn(), exitSelectMode: vi.fn(), personAvatar: vi.fn(() => ({ html: '', face: '' })),
authorAvatar: vi.fn(() => ''), showIndexTags: vi.fn(), openFollowAuthor: vi.fn(), openFollowTag: vi.fn(),
diff --git a/frontend/test/react/pages/managed.test.tsx b/frontend/test/react/pages/managed.test.tsx
index f7efb00b2..5f8d4164f 100644
--- a/frontend/test/react/pages/managed.test.tsx
+++ b/frontend/test/react/pages/managed.test.tsx
@@ -41,7 +41,7 @@ function shellActions(): ShellActions {
openItem: vi.fn(), openEntity: vi.fn(), openTag: vi.fn(), openTasteSignal: vi.fn(), navigate: vi.fn(),
openManage: vi.fn(), managePath: vi.fn(() => ''), openFollow: vi.fn(),
receipt: vi.fn(), toast: vi.fn(), failure: vi.fn(), revealSource: vi.fn(async () => ''),
- reopenTutorial: vi.fn(async () => {}), requestConfigurationSection: vi.fn(),
+ reopenTutorial: vi.fn(async () => {}),
routeReview: vi.fn(), routeFollowManage: vi.fn(), saveFollowPreference: vi.fn(), srcBadge: () => '',
routeIndex: vi.fn(), savePeopleLayout: vi.fn(), exitSelectMode: vi.fn(),
personAvatar: vi.fn(() => ({ html: '', face: '' })), authorAvatar: vi.fn(() => ''), showIndexTags: vi.fn(),
diff --git a/frontend/test/react/render.tsx b/frontend/test/react/render.tsx
index bc58dc407..59f69eb28 100644
--- a/frontend/test/react/render.tsx
+++ b/frontend/test/react/render.tsx
@@ -75,6 +75,15 @@ export const submit = (form: Element | null | undefined) => act(async () => {
export const buttonNamed = (name: string, root: ParentNode = document) =>
[...root.querySelectorAll('button')].find((button) => button.textContent?.trim() === name) ?? null;
+/** 按可见文字找链接,同样默认从整页找。 */
+export const linkNamed = (name: string, root: ParentNode = document) =>
+ [...root.querySelectorAll('a')].find((link) => link.textContent?.trim() === name) ?? null;
+
+/** 一组动作按文档顺序的名称,按钮与链接都算,纯图标键取 `aria-label`:断言链接在左、主动作在最右用它。 */
+export const actionOrder = (root: ParentNode | null | undefined) =>
+ root ? [...root.querySelectorAll('button, a[href]')]
+ .map((node) => node.textContent?.trim() || node.getAttribute('aria-label') || '') : [];
+
/** 分区以标题作无障碍名称。 */
export const section = (root: ParentNode, title: string) =>
root.querySelector(`:is(form,section)[aria-label="${title}"]`);
diff --git a/frontend/test/react/review.test.tsx b/frontend/test/react/review.test.tsx
index 0eafd42e4..0a226908b 100644
--- a/frontend/test/react/review.test.tsx
+++ b/frontend/test/react/review.test.tsx
@@ -16,7 +16,7 @@ import {
} from '../../src/react/review/review';
import { ReviewPage } from '../../src/react/review/review-page';
-import { choose, click, mountRoot, settle } from './render';
+import { actionOrder, choose, click, mountRoot, settle } from './render';
// 客户端是模块级的单例(所有 React 根共用一个),用例之间不清就互相喂数据。
afterEach(() => queryClient.clear());
@@ -206,6 +206,8 @@ it('批量判定把成功的摘掉,没写成的留下来等重试', async () =
await choose(host.querySelector('button[aria-label="筛选当前分类"]'), '单一来源 · 3');
await click(buttonIn(host, '全选当前分类'));
expect(statusText(host)).toContain('已选 3 项');
+ expect(actionOrder(buttonIn(host, '通过所选')!.parentElement).filter((name) => name.endsWith('所选') || name === '取消选择'))
+ .toEqual(['拒绝所选', '通过所选', '取消选择']);
await click(buttonIn(host, '通过所选'));
await settle();
expect(props.toast).toHaveBeenCalledWith('已通过 2 项,1 项未完成');
@@ -294,7 +296,7 @@ it('队列读取失败时说读取失败、给重试键,和空队列分得开
expect(host.textContent).toContain('复核队列读取失败');
expect(host.textContent).not.toContain('此分类没有待复核项目');
fail = false;
- await click(buttonIn(host, '重试'));
+ await click(buttonIn(host, '立即重试'));
await settle();
expect(host.textContent).not.toContain('复核队列读取失败');
expect(cards(host)).toHaveLength(REVIEW_PAGE_SIZE);
diff --git a/frontend/test/react/settings-panel.test.tsx b/frontend/test/react/settings-panel.test.tsx
index f43a76ecc..766d007ee 100644
--- a/frontend/test/react/settings-panel.test.tsx
+++ b/frontend/test/react/settings-panel.test.tsx
@@ -85,7 +85,7 @@ function shellActions(): ShellActions {
openItem: vi.fn(), openEntity: vi.fn(), openTag: vi.fn(), openTasteSignal: vi.fn(), navigate: vi.fn(),
openManage: vi.fn(), managePath: vi.fn(() => ''), openFollow: vi.fn(), receipt: vi.fn(), toast: vi.fn(),
failure: vi.fn(), revealSource: vi.fn(async () => ''), reopenTutorial: vi.fn(async () => {}),
- requestConfigurationSection: vi.fn(), routeReview: vi.fn(),
+ routeReview: vi.fn(),
routeFollowManage: vi.fn(), saveFollowPreference: vi.fn(), srcBadge: () => '', routeIndex: vi.fn(),
savePeopleLayout: vi.fn(), exitSelectMode: vi.fn(), personAvatar: vi.fn(() => ({ html: '', face: '' })),
authorAvatar: vi.fn(() => ''), showIndexTags: vi.fn(), openFollowAuthor: vi.fn(), openFollowTag: vi.fn(),
diff --git a/frontend/test/react/setup-page.test.tsx b/frontend/test/react/setup-page.test.tsx
index 32d356127..27afec15b 100644
--- a/frontend/test/react/setup-page.test.tsx
+++ b/frontend/test/react/setup-page.test.tsx
@@ -317,7 +317,7 @@ it('读题失败时给原因和重试', async () => {
const host = await mount(<SetupPage />);
await settle();
expect(host.querySelector('[role="alert"]')?.textContent).toContain('服务出错了');
- await click(buttonNamed('重试', host));
+ await click(buttonNamed('立即重试', host));
await settle();
expect(fetcher).toHaveBeenCalledTimes(2);
expect(paths(host)).toHaveLength(1);
diff --git a/frontend/test/react/sidebar.test.tsx b/frontend/test/react/sidebar.test.tsx
index a59131705..9fabc2fb2 100644
--- a/frontend/test/react/sidebar.test.tsx
+++ b/frontend/test/react/sidebar.test.tsx
@@ -72,7 +72,7 @@ function shellActions(): ShellActions {
openItem: vi.fn(), openEntity: vi.fn(), openTag: vi.fn(), openTasteSignal: vi.fn(), navigate: vi.fn(),
openManage: vi.fn(), managePath: vi.fn(() => ''), openFollow: vi.fn(), receipt: vi.fn(), toast: vi.fn(),
failure: vi.fn(), revealSource: vi.fn(async () => ''), reopenTutorial: vi.fn(async () => {}),
- requestConfigurationSection: vi.fn(), routeReview: vi.fn(),
+ routeReview: vi.fn(),
routeFollowManage: vi.fn(), saveFollowPreference: vi.fn(), srcBadge: () => '', routeIndex: vi.fn(),
savePeopleLayout: vi.fn(), exitSelectMode: vi.fn(), personAvatar: vi.fn(() => ({ html: '', face: '' })),
authorAvatar: vi.fn(() => ''), showIndexTags: vi.fn(), openFollowAuthor: vi.fn(), openFollowTag: vi.fn(),
diff --git a/frontend/test/react/stage.test.tsx b/frontend/test/react/stage.test.tsx
index cfa1e82d6..9dd0d5e93 100644
--- a/frontend/test/react/stage.test.tsx
+++ b/frontend/test/react/stage.test.tsx
@@ -122,7 +122,7 @@ function shellActions(): ShellActions {
openItem: vi.fn(), openEntity: vi.fn(), openTag: vi.fn(), openTasteSignal: vi.fn(), navigate: vi.fn(),
openManage: vi.fn(), managePath: vi.fn(() => ''), openFollow: vi.fn(), receipt: vi.fn(), toast: vi.fn(),
failure: vi.fn(), revealSource: vi.fn(async () => ''), reopenTutorial: vi.fn(async () => {}),
- requestConfigurationSection: vi.fn(), routeReview: vi.fn(),
+ routeReview: vi.fn(),
routeFollowManage: vi.fn(), saveFollowPreference: vi.fn(), srcBadge: () => '', routeIndex: vi.fn(),
savePeopleLayout: vi.fn(), exitSelectMode: vi.fn(), personAvatar: vi.fn(() => ({ html: '', face: '' })),
authorAvatar: vi.fn(() => ''), showIndexTags: vi.fn(), openFollowAuthor: vi.fn(), openFollowTag: vi.fn(),
diff --git a/frontend/test/react/stats.test.tsx b/frontend/test/react/stats.test.tsx
index 1617306d4..d7c5703e4 100644
--- a/frontend/test/react/stats.test.tsx
+++ b/frontend/test/react/stats.test.tsx
@@ -18,7 +18,7 @@ import {
} from '../../src/react/stats/stats';
import { StatsPage } from '../../src/react/stats/stats-page';
-import { buttonNamed, click, mount, mountRoot } from './render';
+import { actionOrder, buttonNamed, click, mount, mountRoot } from './render';
// 客户端是模块级的单例(所有 React 根共用一个),用例之间不清就互相喂数据。
afterEach(() => queryClient.clear());
@@ -64,7 +64,6 @@ const payload = (overrides: Partial<StatsData> = {}): StatsData => ({
const legacyProps = () => ({
tagLabel: (key: string) => `标签 ${key}`,
onTag: vi.fn<(key: string) => void>(),
- openMediaSettings: vi.fn<() => void>(),
});
/** 依次回这几份数据,最后一份之后一直回它。`null` 那一份回 500。 */
@@ -339,22 +338,21 @@ it('快进扫过和正常看完是两回事,一行里分得出来', async () =
expect(entry.textContent).toContain('真实 50% · 到达 90%');
});
-it('空馆藏提供添加媒体入口', async () => {
- const { host, props } = await open(payload({ by_loc: [], by_library: [] }));
+it('空馆藏提供添加媒体入口,链到媒体库设置', async () => {
+ const { host } = await open(payload({ by_loc: [], by_library: [] }));
expect(host.querySelector('h3')?.textContent).toBe('还没有视频');
expect(radialCharts(host)).toEqual([]);
expect(host.querySelector('[role=tabpanel] section[aria-label]')).toBeNull();
- await click(buttonNamed('添加媒体', host));
- expect(props.openMediaSettings).toHaveBeenCalledTimes(1);
+ expect(buttonNamed('添加媒体', host)).toBeNull();
+ expect(linkNamed(host, '添加媒体')?.getAttribute('href')).toBe('/settings/library');
});
-it('媒体配置与添加关注是两个独立去向', async () => {
+it('媒体配置与添加关注是两个独立去向,次要的添加关注在左', async () => {
const props = legacyProps();
const { host } = await open(payload({ by_loc: [], by_library: [] }), props);
- await click(buttonNamed('添加媒体', host));
- expect(props.openMediaSettings).toHaveBeenCalledTimes(1);
- expect(host.querySelector('a')?.textContent).toBe('添加关注');
- expect(looksLikeButton(host.querySelector('a'))).toBe(true);
+ expect(actionOrder(host.querySelector('[data-empty-state]'))).toEqual(['添加关注', '添加媒体']);
+ expect(linkNamed(host, '添加关注')?.getAttribute('href')).toBe('/subscriptions?tab=add');
+ expect(looksLikeButton(linkNamed(host, '添加关注'))).toBe(true);
});
/** 空态里的去处画成次级实底按钮(白底、发丝边框),不是一行带下划线的文字链接。 */
diff --git a/frontend/test/react/surface-boundary.test.tsx b/frontend/test/react/surface-boundary.test.tsx
index 308807527..e64a3137d 100644
--- a/frontend/test/react/surface-boundary.test.tsx
+++ b/frontend/test/react/surface-boundary.test.tsx
@@ -66,7 +66,7 @@ function shellActions(): ShellActions {
openItem: vi.fn(), openEntity: vi.fn(), openTag: vi.fn(), openTasteSignal: vi.fn(), navigate: vi.fn(),
openManage: vi.fn(), managePath: vi.fn(() => ''), openFollow: vi.fn(), receipt: vi.fn(), toast: vi.fn(),
failure: vi.fn(), revealSource: vi.fn(async () => ''), reopenTutorial: vi.fn(async () => {}),
- requestConfigurationSection: vi.fn(), routeReview: vi.fn(),
+ routeReview: vi.fn(),
routeFollowManage: vi.fn(), saveFollowPreference: vi.fn(), srcBadge: () => '', routeIndex: vi.fn(),
savePeopleLayout: vi.fn(), exitSelectMode: vi.fn(), personAvatar: vi.fn(() => ({ html: '', face: '' })),
authorAvatar: vi.fn(() => ''), showIndexTags: vi.fn(), openFollowAuthor: vi.fn(), openFollowTag: vi.fn(),
diff --git a/frontend/test/react/surface-routes.test.tsx b/frontend/test/react/surface-routes.test.tsx
index 2a9e27411..13c701867 100644
--- a/frontend/test/react/surface-routes.test.tsx
+++ b/frontend/test/react/surface-routes.test.tsx
@@ -41,7 +41,7 @@ function shellActions(): ShellActions {
openItem: vi.fn(), openEntity: vi.fn(), openTag: vi.fn(), openTasteSignal: vi.fn(), navigate: vi.fn(),
openManage: vi.fn(), managePath: vi.fn(() => ''), openFollow: vi.fn(), receipt: vi.fn(), toast: vi.fn(),
failure: vi.fn(), revealSource: vi.fn(async () => ''), reopenTutorial: vi.fn(async () => {}),
- requestConfigurationSection: vi.fn(), routeReview: vi.fn(),
+ routeReview: vi.fn(),
routeFollowManage: vi.fn(), saveFollowPreference: vi.fn(), srcBadge: () => '', routeIndex: vi.fn(),
savePeopleLayout: vi.fn(), exitSelectMode: vi.fn(), personAvatar: vi.fn(() => ({ html: '', face: '' })),
authorAvatar: vi.fn(() => ''), showIndexTags: vi.fn(), openFollowAuthor: vi.fn(), openFollowTag: vi.fn(),
diff --git a/frontend/test/react/want-list.test.tsx b/frontend/test/react/want-list.test.tsx
index d7d9c5e6e..107893860 100644
--- a/frontend/test/react/want-list.test.tsx
+++ b/frontend/test/react/want-list.test.tsx
@@ -8,7 +8,7 @@ import { afterEach, expect, it, vi } from 'vitest';
import { queryClient } from '../../src/react/query';
import { WANT_PAGE_SIZE, WantList } from '../../src/react/wants/want-list';
import type { Want, WantsData } from '../../src/react/wants/wants';
-import { buttonNamed, click, mount, settle, type } from './render';
+import { actionOrder, buttonNamed, click, mount, settle, type } from './render';
afterEach(() => { queryClient.clear(); localStorage.clear() });
notifyManager.setScheduler((notify) => notify());
@@ -74,6 +74,8 @@ it('按待找、未发售、暂时放弃、已入库分段,段名带条数;
]);
expect(buttonNamed('重新查找', host.querySelector('[data-want-id="3"]')!)).not.toBeNull();
expect(buttonNamed('重新查找', host.querySelector('[data-want-id="2"]')!)).toBeNull();
+ expect(actionOrder(buttonNamed('重新查找', host.querySelector('[data-want-id="3"]')!)!.parentElement))
+ .toEqual(['来源页', '移除', '重新查找', '查找资源']);
});
it('待找与暂时放弃两段每行有查找资源,原地打开带番号与标题的云下载弹层;未发售与已入库没有', async () => {
diff --git a/frontend/test/react/want-magnets.test.tsx b/frontend/test/react/want-magnets.test.tsx
index 666fb6526..3bbabda7b 100644
--- a/frontend/test/react/want-magnets.test.tsx
+++ b/frontend/test/react/want-magnets.test.tsx
@@ -38,7 +38,7 @@ it('自动查询,展示来源、大小、日期与属性,直接添加到选
expect(fetcher.mock.calls[0]?.[0]).toBe('/api/wants/magnets?id=1');
for (const text of ['4 GB', '2 个文件', '2026-10-01', '字幕', 'JavDB']) expect(host.textContent).toContain(text);
expect(host.querySelector('[data-resource-facts]')?.textContent).not.toContain('高清');
- expect([...host.querySelectorAll('[data-resource-actions] button, [data-resource-actions] a')].map(node => node.textContent)).toEqual(['添加下载', '复制链接', '链接来源']);
+ expect([...host.querySelectorAll('[data-resource-actions] button, [data-resource-actions] a')].map(node => node.textContent)).toEqual(['链接来源', '复制链接', '添加下载']);
await click(buttonNamed('添加下载', host));
await settle();
const writes = fetcher.mock.calls.filter(([, init]) => init?.method === 'POST');
@@ -53,6 +53,7 @@ it('ed2k 与网页链接可复制,不能作为磁链提交', async () => {
const ed2k = { ...candidate, id: 'ed2k:abc:12', protocol: 'ed2k' as const, uri: 'ed2k://|file|demo|12|abc|/' };
const { host } = await open([ed2k]);
expect(buttonNamed('添加下载', host)).toBeNull();
+ expect(buttonNamed('复制链接', host)?.className).not.toContain('bg-button-primary');
await click(buttonNamed('复制链接', host));
expect(writeText).toHaveBeenCalledWith(ed2k.uri);
});
diff --git a/src/peach/follow_discovery.py b/src/peach/follow_discovery.py
index 89ee2e040..1dd864f0c 100644
--- a/src/peach/follow_discovery.py
+++ b/src/peach/follow_discovery.py
@@ -431,7 +431,7 @@ def _simpcity_candidates(term: str, transport,
credential: Credential | None = None) -> list[Candidate]:
"""simpcity 只有站内搜索这一条路,而它必须登录。
- 没有 cookie 就静默跳过:来源筛选菜单里已经标着「需要配置凭据」,每查一个名字
+ 没有 cookie 就静默跳过:来源筛选菜单里缺凭据的站已经挂着「打开凭据设置」,每查一个名字
都在结果里再报一次只是噪音。裸数字不去试——simpcity 的线程页对游客是 403,
对登录用户任何数字都可能存在,「存在」不构成「就是他」的证据。
"""
diff --git a/tests/test_follow_discovery.py b/tests/test_follow_discovery.py
index 29777a502..b85cbe8ac 100644
--- a/tests/test_follow_discovery.py
+++ b/tests/test_follow_discovery.py
@@ -514,7 +514,7 @@ class DiscoverTests(_DiscoveryCase):
self.assertIn("simpcity", {c.provider for c in found.candidates})
def test_without_a_simpcity_cookie_the_site_is_skipped_silently(self):
- # 来源筛选菜单里已经标着「需要配置凭据」,每查一个名字都再报一次只是噪音。
+ # 来源筛选菜单里缺凭据的站已经挂着「打开凭据设置」,每查一个名字都再报一次只是噪音。
calls = []
found = self._discover("solazola", self.SIMPCITY_ROUTES, providers=("simpcity",), calls=calls)
self.assertEqual(found.candidates, ())
diff --git a/web/dist/peach-pages.js b/web/dist/peach-pages.js
index f0389acf6..6f76edc82 100644
--- a/web/dist/peach-pages.js
+++ b/web/dist/peach-pages.js
@@ -2,7 +2,7 @@
(function() {
try {
var e = typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : {}, t = new e.Error().stack;
- t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "39f747ac-f39b-4523-a31c-93f5a2536310", e._sentryDebugIdIdentifier = "sentry-dbid-39f747ac-f39b-4523-a31c-93f5a2536310");
+ t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "561b1e10-0b5f-4162-bd1b-8cbad11f6521", e._sentryDebugIdIdentifier = "sentry-dbid-561b1e10-0b5f-4162-bd1b-8cbad11f6521");
} catch {}
})();
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, i, o, s) => {
@@ -21481,7 +21481,7 @@ function Ug() {
onClick: () => {
t({ kind: "loading" }), r((e) => e + 1);
},
- children: "重试"
+ children: "立即重试"
}),
children: e.message
}) : null,
@@ -21515,4 +21515,4 @@ var Gg = document.getElementById("peach-page"), Kg = Gg ? Wg[Gg.dataset.page ??
Gg && Kg && (0, w.createRoot)(Gg).render(/* @__PURE__ */ (0, B.jsx)(Kg, { data: { ...Gg.dataset } }));
//#endregion
-//# debugId=39f747ac-f39b-4523-a31c-93f5a2536310
\ No newline at end of file
+//# debugId=561b1e10-0b5f-4162-bd1b-8cbad11f6521
\ No newline at end of file