Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 设置页保存键统一叫保存配置,操作键改用主按钮

longmeidao1175fce7bb98
diff --git a/docs/BOARD_UI.md b/docs/BOARD_UI.md
index 95f6571d4..56619e7a6 100644
--- a/docs/BOARD_UI.md
+++ b/docs/BOARD_UI.md
@@ -109,6 +109,7 @@ Peach 使用 Board 的视觉与组件语义,保留 Vite、Preact、FastAPI 和
尺寸、颜色和布局的底稿在 `web/css/`,board.css 只做覆盖,选择器权重必须压得过底稿。
- 「增加对比度」关闭透明与折射;系统降低透明度偏好也使用实色。折射只作用于导航背景,不扭曲文字。
- 设置标题与控件在桌面同排,手机宽度不足时换行。单位与数值属于同一输入框;可关闭的功能显示开关,关闭时隐藏数值。
+- 设置页的保存键统一叫「保存配置」,回执「已保存配置」;保存、检查、添加、刷新这类操作键用 BoardUI `Button` 的 `primary`(缺省值,蓝底白字)。`secondary` 只给面板触发键与「取消」,不可逆操作用 `danger`(`frontend/test/settings-buttons.test.ts`)。
- 数值非法时不保存;关闭搜索记录后不读取或记入搜索记录,关闭相关推荐后不请求该模块。
- Board 免费源码以官网声明的 MIT 条款使用;Pro 图表与模板不取用收费源码。项目自有图表不宣称来自 Pro,也不承诺 Pro 更新权益。
- Remix Icon 固定为 4.9.1,按包内 Remix Icon License v1.0 登记;官网所写的 Apache 2.0 不代替实际包许可证。保留已确认图标,候选由 `attic/evidence/20260908-boardui-preview/boardui-full/icon-review.html` 审查。
diff --git a/frontend/src/react/settings/access-settings.tsx b/frontend/src/react/settings/access-settings.tsx
index bce734932..5a3b5211f 100644
--- a/frontend/src/react/settings/access-settings.tsx
+++ b/frontend/src/react/settings/access-settings.tsx
@@ -49,7 +49,7 @@ export function AccessSettings({ initial, receipt }: AccessSettingsProps) {
current_password: current, password: disable ? '' : password, confirmation: disable ? '' : confirmation,
}, 'POST', signal), (next) => {
setState(next); setCurrent(''); setPassword(''); setConfirmation(''); setDisable(false); setFields({});
- receipt(next.mode === 'open' ? '已关闭访问密码' : '已保存访问密码');
+ receipt(next.mode === 'open' ? '已关闭访问密码' : '已保存配置');
}, (cause) => {
const payload = cause instanceof ApiError ? cause.body as { errors?: FieldErrors; detail?: { errors?: FieldErrors } } : null;
const errors = payload?.errors || payload?.detail?.errors;
diff --git a/frontend/src/react/settings/general-settings.tsx b/frontend/src/react/settings/general-settings.tsx
index cc551e062..700d99093 100644
--- a/frontend/src/react/settings/general-settings.tsx
+++ b/frontend/src/react/settings/general-settings.tsx
@@ -27,7 +27,7 @@ export function StartupSettings({ startup, receipt }: { startup: StartupState; r
event.preventDefault();
if (!startup.available) return;
void action.run('save', (signal) => apiSend('/api/configuration/startup', { enabled, silent, desktop }, 'POST', signal),
- () => receipt('已保存开机自启'));
+ () => receipt('已保存配置'));
};
return (
diff --git a/frontend/src/react/settings/maintenance-settings.tsx b/frontend/src/react/settings/maintenance-settings.tsx
index b897cf6aa..40da9df92 100644
--- a/frontend/src/react/settings/maintenance-settings.tsx
+++ b/frontend/src/react/settings/maintenance-settings.tsx
@@ -36,7 +36,7 @@ export function AutomaticUpdates({ initial, receipt }: { initial: AutomaticUpdat
event.preventDefault();
if (!initial.available) return;
void action.run('save', (signal) => apiSend<AutomaticUpdateState>('/api/configuration/automatic-updates',
- { mode, interval_hours: hours }, 'POST', signal), () => receipt('已保存自动更新设置'));
+ { mode, interval_hours: hours }, 'POST', signal), () => receipt('已保存配置'));
};
const help = !initial.available
@@ -65,7 +65,7 @@ export function AutomaticUpdates({ initial, receipt }: { initial: AutomaticUpdat
</Rows>
{action.error ? <Stack divided><ErrorText>{action.error}</ErrorText></Stack> : null}
<Footer>
- <Button variant="secondary" type="submit" disabled={!initial.available} {...busyProps(action.busy === 'save')}>保存自动更新</Button>
+ <Button type="submit" disabled={!initial.available} {...busyProps(action.busy === 'save')}>保存配置</Button>
</Footer>
</Section>
);
diff --git a/frontend/src/react/settings/media-settings.tsx b/frontend/src/react/settings/media-settings.tsx
index 655206c64..197cb2961 100644
--- a/frontend/src/react/settings/media-settings.tsx
+++ b/frontend/src/react/settings/media-settings.tsx
@@ -220,7 +220,7 @@ function MediaForm({ data, receipt }: ConfigurationGroupProps) {
</div>
))}
</div>
- <Button variant="secondary" className="self-start" onClick={add}>添加文件夹</Button>
+ <Button className="self-start" onClick={add}>添加文件夹</Button>
</div>
{cloud ? <CloudDriveGuide /> : null}
{missing.map((dependency) => (
@@ -272,7 +272,7 @@ function MountStatus({ data }: { data: ConfigurationData }) {
</FactList>
{action.error ? <Stack divided><ErrorText>{action.error}</ErrorText></Stack> : null}
<Footer>
- <Button variant="secondary" onClick={refresh} {...busyProps(action.busy === 'refresh')}>刷新挂载状态</Button>
+ <Button onClick={refresh} {...busyProps(action.busy === 'refresh')}>刷新挂载状态</Button>
</Footer>
</Section>
);
diff --git a/frontend/src/react/settings/network-settings.tsx b/frontend/src/react/settings/network-settings.tsx
index 9dd77dabf..08e2baef7 100644
--- a/frontend/src/react/settings/network-settings.tsx
+++ b/frontend/src/react/settings/network-settings.tsx
@@ -32,7 +32,7 @@ export function PeachProxy({ initial, receipt }: { initial: PeachProxyState; rec
const submit = (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
void action.run('save', (signal) => apiSend<PeachProxyState>('/api/configuration/peach-proxy', { mode, proxy: address }, 'POST', signal),
- (next) => { setSaved(next); setAddress(''); receipt('已保存 Peach 代理'); });
+ (next) => { setSaved(next); setAddress(''); receipt('已保存配置'); });
};
return (
@@ -55,7 +55,7 @@ export function PeachProxy({ initial, receipt }: { initial: PeachProxyState; rec
</Stack>
) : null}
<Footer>
- <Button type="submit" {...busyProps(action.busy === 'save')}>保存代理</Button>
+ <Button type="submit" {...busyProps(action.busy === 'save')}>保存配置</Button>
</Footer>
</Section>
);
diff --git a/frontend/src/react/settings/release-updates.tsx b/frontend/src/react/settings/release-updates.tsx
index 5e62656b1..cd38f759f 100644
--- a/frontend/src/react/settings/release-updates.tsx
+++ b/frontend/src/react/settings/release-updates.tsx
@@ -112,7 +112,7 @@ export function ReleaseUpdates({ initial, initialJob }: { initial: ReleaseState;
{data.state === 'available' && data.installation === '独立测试包' && job.state !== 'ready'
? <Button onClick={download} {...busyProps(running || action.busy === 'download')}>下载并安装</Button>
: null}
- <Button variant="secondary" disabled={running} onClick={check} {...busyProps(action.busy === 'check')}>检查更新</Button>
+ <Button disabled={running} onClick={check} {...busyProps(action.busy === 'check')}>检查更新</Button>
</Footer>
</Section>
);
diff --git a/frontend/test/react/general-network-settings.test.tsx b/frontend/test/react/general-network-settings.test.tsx
index cba1fde97..c9e695478 100644
--- a/frontend/test/react/general-network-settings.test.tsx
+++ b/frontend/test/react/general-network-settings.test.tsx
@@ -22,7 +22,7 @@ it('开机自启:静默启动跟着开机自启解锁,保存发出三颗开
await settle();
expect(fetcher.mock.calls[0]?.[0]).toBe('/api/configuration/startup');
expect(sentBody(fetcher)).toEqual({ enabled: true, silent: true, desktop: false });
- expect(receipt).toHaveBeenCalledWith('已保存开机自启');
+ expect(receipt).toHaveBeenCalledWith('已保存配置');
});
it('桌面快捷方式被别的安装占着时只锁那一颗,并说出原因', async () => {
@@ -48,7 +48,7 @@ it('Peach 代理:选自定义才出地址栏,保存后清空地址并记住
await submit(host.querySelector('form'));
await settle();
expect(sentBody(fetcher)).toEqual({ mode: 'proxy', proxy: 'http://127.0.0.1:7890' });
- expect(receipt).toHaveBeenCalledWith('已保存 Peach 代理');
+ expect(receipt).toHaveBeenCalledWith('已保存配置');
const saved = host.querySelector<HTMLInputElement>('#peachProxyAddress');
expect(saved?.value).toBe('');
expect(saved?.placeholder).toBe('已保存,留空保留');
diff --git a/frontend/test/react/maintenance-settings.test.tsx b/frontend/test/react/maintenance-settings.test.tsx
index c5efdd195..3694f5353 100644
--- a/frontend/test/react/maintenance-settings.test.tsx
+++ b/frontend/test/react/maintenance-settings.test.tsx
@@ -47,7 +47,7 @@ describe('自动更新', () => {
await submit(host.querySelector('form'));
await settle();
expect(sentBody(fetcher)).toEqual({ mode: 'download', interval_hours: 168 });
- expect(receipt).toHaveBeenCalledWith('已保存自动更新设置');
+ expect(receipt).toHaveBeenCalledWith('已保存配置');
await click(switches(host)[0]);
await submit(host.querySelector('form'));
await settle();
diff --git a/frontend/test/settings-buttons.test.ts b/frontend/test/settings-buttons.test.ts
new file mode 100644
index 000000000..31df6889f
--- /dev/null
+++ b/frontend/test/settings-buttons.test.ts
@@ -0,0 +1,29 @@
+/* 设置页的按钮:保存键一律叫「保存配置」,操作键用 BoardUI `Button` 的主按钮(`variant` 缺省即
+ * `primary`,蓝底白字)。次按钮 `secondary` 只留给图标选择面板的触发键和「取消」,危险操作用 `danger`。 */
+import { readdirSync, readFileSync } from 'node:fs';
+import { resolve } from 'node:path';
+
+import { expect, it } from 'vitest';
+
+const dir = resolve(process.cwd(), 'src/react/settings');
+const buttons = readdirSync(dir)
+ .filter((name) => name.endsWith('.tsx'))
+ .flatMap((name) => [...readFileSync(resolve(dir, name), 'utf8').matchAll(/<Button\b([\s\S]*?)<\/Button>/g)]
+ .map(([, tag = '']) => ({ name, tag, label: tag.slice(tag.lastIndexOf('>') + 1).trim() })));
+
+it('保存键一律叫「保存配置」', () => {
+ const saves = buttons.filter((button) => button.label.startsWith('保存'));
+ expect(saves.length).toBeGreaterThan(0);
+ expect(saves.filter((button) => button.label !== '保存配置').map((button) => `${button.name}: ${button.label}`)).toEqual([]);
+});
+
+it('保存、检查、添加、刷新这类操作键都是主按钮', () => {
+ const actions = buttons.filter((button) => /^(保存|检查|添加|刷新)/.test(button.label));
+ expect(actions.map((button) => button.label)).toEqual(expect.arrayContaining(['保存配置', '检查更新', '添加文件夹', '刷新挂载状态']));
+ expect(actions.filter((button) => /\bvariant=/.test(button.tag)).map((button) => `${button.name}: ${button.label}`)).toEqual([]);
+});
+
+it('次按钮只出现在图标选择面板', () => {
+ const secondary = buttons.filter((button) => button.tag.includes('variant="secondary"'));
+ expect([...new Set(secondary.map((button) => button.name))]).toEqual(['library-icon-picker.tsx']);
+});
diff --git a/web/dist/peach-react.js b/web/dist/peach-react.js
index 032ad01b2..8fb93fdf9 100644
--- a/web/dist/peach-react.js
+++ b/web/dist/peach-react.js
@@ -19447,7 +19447,7 @@ function Hp({ startup: e, receipt: t }) {
enabled: n,
silent: i,
desktop: o
- }, "POST", e), () => t("已保存开机自启"));
+ }, "POST", e), () => t("已保存配置"));
},
children: [
/* @__PURE__ */ (0, J.jsxs)(Tp, { children: [
@@ -19781,7 +19781,6 @@ function am({ initial: e, initialJob: t }) {
children: "下载并安装"
}) : null,
/* @__PURE__ */ (0, J.jsx)(Cu, {
- variant: "secondary",
disabled: f,
onClick: g,
...Bp(l.busy === "check"),
@@ -19821,7 +19820,7 @@ function cm({ initial: e, receipt: t }) {
r.preventDefault(), e.available && o.run("save", (e) => _p("/api/configuration/automatic-updates", {
mode: n,
interval_hours: i
- }, "POST", e), () => t("已保存自动更新设置"));
+ }, "POST", e), () => t("已保存配置"));
}, c = e.available ? e.download_available ? "开启后一分钟内开始检查。下载完成后,在此确认重启安装。" : "开启后一分钟内开始检查。源码运行请前往发布页获取新版本。" : "自动更新需要由托盘管理的服务。";
return /* @__PURE__ */ (0, J.jsxs)(wp, {
title: "自动更新",
@@ -19868,11 +19867,10 @@ function cm({ initial: e, receipt: t }) {
children: /* @__PURE__ */ (0, J.jsx)(kp, { children: o.error })
}) : null,
/* @__PURE__ */ (0, J.jsx)(Dp, { children: /* @__PURE__ */ (0, J.jsx)(Cu, {
- variant: "secondary",
type: "submit",
disabled: !e.available,
...Bp(o.busy === "save"),
- children: "保存自动更新"
+ children: "保存配置"
}) })
]
});
@@ -20497,7 +20495,6 @@ function Rm({ data: e, receipt: t }) {
}, r))
}),
/* @__PURE__ */ (0, J.jsx)(Cu, {
- variant: "secondary",
className: "self-start",
onClick: E,
children: "添加文件夹"
@@ -20583,7 +20580,6 @@ function Bm({ data: e }) {
children: /* @__PURE__ */ (0, J.jsx)(kp, { children: r.error })
}) : null,
/* @__PURE__ */ (0, J.jsx)(Dp, { children: /* @__PURE__ */ (0, J.jsx)(Cu, {
- variant: "secondary",
onClick: () => void r.run("refresh", (e) => gp(bm, e), (e) => n(e.media_sources)),
...Bp(r.busy === "refresh"),
children: "刷新挂载状态"
@@ -20614,7 +20610,7 @@ function Hm({ initial: e, receipt: t }) {
password: u ? "" : o,
confirmation: u ? "" : c
}, "POST", e), (e) => {
- r(e), a(""), s(""), l(""), d(!1), p({}), t(e.mode === "open" ? "已关闭访问密码" : "已保存访问密码");
+ r(e), a(""), s(""), l(""), d(!1), p({}), t(e.mode === "open" ? "已关闭访问密码" : "已保存配置");
}, (e) => {
let t = e instanceof pp ? e.body : null, n = t?.errors || t?.detail?.errors;
n ? p(n) : h.setError(hp(e));
@@ -20723,7 +20719,7 @@ function Gm({ initial: e, receipt: t }) {
mode: i,
proxy: o
}, "POST", e), (e) => {
- r(e), s(""), t("已保存 Peach 代理");
+ r(e), s(""), t("已保存配置");
});
},
children: [
@@ -20765,7 +20761,7 @@ function Gm({ initial: e, receipt: t }) {
/* @__PURE__ */ (0, J.jsx)(Dp, { children: /* @__PURE__ */ (0, J.jsx)(Cu, {
type: "submit",
...Bp(c.busy === "save"),
- children: "保存代理"
+ children: "保存配置"
}) })
]
});