Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 统计页空态的去处按钮画成次级实底按钮

longmeidao6fa732d87033
diff --git a/frontend/src/react/stats/stats-page.tsx b/frontend/src/react/stats/stats-page.tsx
index 508ba2a76..7e4aa2932 100644
--- a/frontend/src/react/stats/stats-page.tsx
+++ b/frontend/src/react/stats/stats-page.tsx
@@ -16,8 +16,7 @@ import { Tab, TabList, TabPanel, Tabs } from 'react-aria-components';
import { fmtSize, LOC } from '@peach/legacy/core';
-import { Button } from '@/components/base/buttons/button';
-import { LinkButton } from '@/components/base/buttons/link-button';
+import { Button, ButtonLink } from '@/components/base/buttons/button';
import { errorMessage } from '../../api';
import type { StatsProps } from '../bundle';
@@ -114,7 +113,7 @@ function InventoryDetail({ data, configurable, openMediaSettings }: { data: Stat
{configurable
? <Button size="small" onClick={openMediaSettings}>添加媒体文件夹</Button>
: null}
- <LinkButton href="/follow-manage?tab=add" size="small">添加关注</LinkButton>
+ <ButtonLink variant="secondary" href="/follow-manage?tab=add" size="small">添加关注</ButtonLink>
</>
}>{NO_VIDEO_HINT}</EmptyState>
);
@@ -210,7 +209,7 @@ function TagRanking({ tags, tagLabel, onTag }: { tags: TopTag[] } & StatsProps)
if (!tags.length) {
return (
<EmptyState shell="plain" icon={RiPriceTag3Line} title="还没有内容标签"
- actions={<LinkButton href="/data-cleanup" size="small">补全资料</LinkButton>}>{NO_TAG_HINT}</EmptyState>
+ actions={<ButtonLink variant="secondary" href="/data-cleanup" size="small">补全资料</ButtonLink>}>{NO_TAG_HINT}</EmptyState>
);
}
return (
@@ -234,7 +233,7 @@ function RecentWatches({ rows }: { rows: RecentPlay[] }) {
if (!rows.length) {
return (
<EmptyState shell="plain" icon={RiHistoryLine} title="还没有观看记录"
- actions={<LinkButton href="/" size="small">浏览馆藏</LinkButton>}>{NO_WATCH_HINT}</EmptyState>
+ actions={<ButtonLink variant="secondary" href="/" size="small">浏览馆藏</ButtonLink>}>{NO_WATCH_HINT}</EmptyState>
);
}
return (
@@ -269,7 +268,7 @@ function TagSources({ sources, videos }: { sources: TagSource[]; videos: number
if (!sources.length) {
return (
<EmptyState shell="plain" icon={RiPriceTag3Line} title="还没有标签来源"
- actions={<LinkButton href="/data-cleanup" size="small">补全资料</LinkButton>}>{NO_TAG_SOURCE_HINT}</EmptyState>
+ actions={<ButtonLink variant="secondary" href="/data-cleanup" size="small">补全资料</ButtonLink>}>{NO_TAG_SOURCE_HINT}</EmptyState>
);
}
return (
diff --git a/frontend/test/react/stats.test.tsx b/frontend/test/react/stats.test.tsx
index 99d04b6f2..b7945a753 100644
--- a/frontend/test/react/stats.test.tsx
+++ b/frontend/test/react/stats.test.tsx
@@ -280,6 +280,20 @@ it('这台机器不能改配置时空态不给那个按钮,只留能走的那
const { host } = await open(payload({ by_loc: [], by_library: [] }), props);
expect(buttonNamed('添加媒体文件夹', host)).toBeNull();
expect(host.querySelector('a')?.textContent).toBe('添加关注');
+ expect(looksLikeButton(host.querySelector('a'))).toBe(true);
+});
+
+/** 空态里的去处画成次级实底按钮(白底、发丝边框),不是一行带下划线的文字链接。 */
+const looksLikeButton = (link: Element | null) =>
+ !!link && link.className.includes('border-border-button-default') && !link.className.includes('hover:underline');
+const linkNamed = (root: ParentNode, name: string) =>
+ [...root.querySelectorAll('a')].find((a) => a.textContent === name) ?? null;
+
+it('没有内容标签时空态给一枚「补全资料」按钮,去数据整理页', async () => {
+ const { host } = await open(payload({ top_tags: [] }));
+ const link = linkNamed(host, '补全资料');
+ expect(link?.getAttribute('href')).toBe('/data-cleanup');
+ expect(looksLikeButton(link)).toBe(true);
});
it('首屏取数就失败时只剩一条错误,不画空看板', async () => {
diff --git a/web/dist/peach-react.js b/web/dist/peach-react.js
index 1a9eefae9..466f57140 100644
--- a/web/dist/peach-react.js
+++ b/web/dist/peach-react.js
@@ -65187,7 +65187,8 @@ function jDe({ data: t, configurable: n, openMediaSettings: i }) {
size: "small",
onClick: i,
children: "添加媒体文件夹"
- }) : null, /* @__PURE__ */ (0, F.jsx)(NA, {
+ }) : null, /* @__PURE__ */ (0, F.jsx)(bw, {
+ variant: "secondary",
href: "/follow-manage?tab=add",
size: "small",
children: "添加关注"
@@ -65332,7 +65333,8 @@ function IDe({ tags: e, tagLabel: t, onTag: n }) {
shell: "plain",
icon: wS,
title: "还没有内容标签",
- actions: /* @__PURE__ */ (0, F.jsx)(NA, {
+ actions: /* @__PURE__ */ (0, F.jsx)(bw, {
+ variant: "secondary",
href: "/data-cleanup",
size: "small",
children: "补全资料"
@@ -65377,7 +65379,8 @@ function LDe({ rows: e }) {
shell: "plain",
icon: _S,
title: "还没有观看记录",
- actions: /* @__PURE__ */ (0, F.jsx)(NA, {
+ actions: /* @__PURE__ */ (0, F.jsx)(bw, {
+ variant: "secondary",
href: "/",
size: "small",
children: "浏览馆藏"
@@ -65419,7 +65422,8 @@ function RDe({ sources: e, videos: t }) {
shell: "plain",
icon: wS,
title: "还没有标签来源",
- actions: /* @__PURE__ */ (0, F.jsx)(NA, {
+ actions: /* @__PURE__ */ (0, F.jsx)(bw, {
+ variant: "secondary",
href: "/data-cleanup",
size: "small",
children: "补全资料"