Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 补齐配置分组与同步警告呈现

longmeidao2bfe3d21d3a5
diff --git a/docs/reference-snapshots/geist-settings.md b/docs/reference-snapshots/geist-settings.md
index 4c83b2ea7..b043e13eb 100644
--- a/docs/reference-snapshots/geist-settings.md
+++ b/docs/reference-snapshots/geist-settings.md
@@ -13,7 +13,7 @@
- Error Fieldset 根带 `data-fieldset-type="error"`、红色 400 边框;正文使用背景 100;footer 使用红色 100 底、红色 400 顶边、红色 900 文字。危险按钮为实底,整卡并非全铺深红。
- Select 标签在上方,`mb-2` 对应 8px;原生选择器 `w-full` 跟随容器,文字截断、右侧留箭头位置。规范没有要求统一的固定像素宽度。
- Collapse 文档明确要求开合过渡。Peach 复用 `wireCollapse` 的高度与箭头 200ms `ease-in-out`、`aria-expanded`、`aria-controls` 和关闭时 `inert`。
-- [Vercel General settings](https://vercel.com/docs/project-configuration/general-settings) 将通用设置作为独立类别。分类适合大量设置;Peach 当前采用按用途排列的 Fieldset,不再在同页叠加重复分类标题。
+- [Vercel General settings](https://vercel.com/docs/project-configuration/general-settings) 将通用设置作为独立类别。Peach 使用通用、媒体、网络与访问、更新与维护四组标题,组内使用 Fieldset,卸载区放在末尾。
## Peach 采用与差异
@@ -33,10 +33,12 @@
| --- | --- | --- |
| 卸载、删除空文件夹、删除已失效链接 | 红色区域及按钮 | 删除程序、目录或记录,应用内无完整恢复入口 |
| 永久删除、清空回收站 | 保持已有红色按钮 | 永久删除媒体与账本记录 |
-| 网盘差异同步、清理孤立缓存 | 黄色区域与后果 Note,动作按钮中性 | 缺失条目进入回收站;缓存可重建 |
+| 网盘差异同步、清理孤立缓存 | 黄色区域、后果 Note 与警告按钮 | 缺失条目进入回收站;缓存可重建 |
| 关闭访问密码 | 选中后黄色区域与访问范围 Note | 改变访问条件,保存前说明后果 |
| 扫描、检查、挂载、浏览、恢复、选择媒体路径 | 中性 | 读取、导航、恢复或可撤销配置 |
| 垃圾与重复文件移入回收站 | 保持可恢复操作及确认 | 不等同永久删除 |
| 删除播放列表、取消关注、清除来源凭据 | 保持既有危险按钮和作用范围确认 | 删除所选集合、订阅或凭据,不按存储来源着色 |
危险区域共用 `data-fieldset-type` 选择器,置于基础 Fieldset 规则之后;浏览器验收须检查实际底栏颜色,源代码包含红色声明不能证明层叠结果。
+
+警告按钮复用 Geist Warning 的琥珀底、深色字(`vercel-geist-semantics-measured.md`);底栏说明左对齐、动作靠右。风险预览须加载正式 SVG 图标集,Note 图标引用必须能解析。失效链接重验的结果在链接管理原位置显示,保留计数包含恢复和暂时无法确认失效的链接。
diff --git a/frontend/src/islands/configuration.tsx b/frontend/src/islands/configuration.tsx
index 66e4d8c76..f1a7bfc02 100644
--- a/frontend/src/islands/configuration.tsx
+++ b/frontend/src/islands/configuration.tsx
@@ -344,13 +344,17 @@ export function Configuration({ receipt, data, error }: ConfigurationProps & Sta
}
return (
<div class="configpage">
+ {data.startup ? <h2 class="configgroup">通用</h2> : null}
{data.startup ? <StartupSettings startup={data.startup} receipt={receipt} /> : null}
+ <h2 class="configgroup">媒体</h2>
{data.editable
? <ConfigurationForm data={data} receipt={receipt} />
: <Html html={noteHtml(data.notice, { variant: 'secondary', label: '只读' })} />}
<MountStatus data={data} />
+ {data.peach_proxy || data.access ? <h2 class="configgroup">网络与访问</h2> : null}
{data.peach_proxy ? <PeachProxy initial={data.peach_proxy} receipt={receipt} /> : null}
{data.access ? <AccessSettings initial={data.access} receipt={receipt} /> : null}
+ <h2 class="configgroup">更新与维护</h2>
{data.updates ? <ReleaseUpdates initial={data.updates} initialJob={data.update_job} /> : null}
<Facts facts={data.facts} />
{data.uninstall ? <UninstallSettings uninstall={data.uninstall} /> : null}
diff --git a/frontend/test/configuration.test.tsx b/frontend/test/configuration.test.tsx
index 93b38ab0d..94b2150c2 100644
--- a/frontend/test/configuration.test.tsx
+++ b/frontend/test/configuration.test.tsx
@@ -32,6 +32,13 @@ const submit = (el: Element) => {
const settle = async () => {
for (let i = 0; i < 4; i += 1) await Promise.resolve();
};
+
+it('配置以通用媒体网络和维护分组,缺少通用选项时省略标题', () => {
+ const {el}=mount({startup:{available:true,enabled:false,silent:true,message:''},peach_proxy:{mode:'direct',proxy_saved:false,needs_selection:false}});
+ expect([...el.querySelectorAll('.configgroup')].map(e=>e.textContent)).toEqual(['通用','媒体','网络与访问','更新与维护']);
+ const readonly=mount({editable:false});
+ expect([...readonly.el.querySelectorAll('.configgroup')].map(e=>e.textContent)).toEqual(['媒体','更新与维护']);
+});
type FetchCall = [string, RequestInit];
const fetchMock = (status: number, body: unknown) => vi.fn<(...call: FetchCall) => Promise<unknown>>(
async () => ({ ok: status < 400, status, json: async () => body }),
diff --git a/tests/test_desktop_settings.py b/tests/test_desktop_settings.py
index 58f316656..b404cdf09 100644
--- a/tests/test_desktop_settings.py
+++ b/tests/test_desktop_settings.py
@@ -34,7 +34,7 @@ class DesktopSettingsTests(unittest.TestCase):
self.assertIn('data-fieldset-type="error"', links)
self.assertIn('data-fieldset-type="warning"', sync)
self.assertIn("variant:'warning',label:'同步影响'", sync)
- self.assertIn('class="resourceaction" type="button" id="resourceApply"', sync)
+ self.assertIn('class="resourceaction warning" type="button" id="resourceApply"', sync)
self.assertNotIn('class="resourceaction resourcedanger" type="button" id="resourceApply"', sync)
self.assertIn('cleanupemptyfolders" data-geist-fieldset data-fieldset-type="error"', app)
diff --git a/web/app.js b/web/app.js
index be4ae5547..272e1d526 100644
--- a/web/app.js
+++ b/web/app.js
@@ -3090,7 +3090,7 @@ async function wireLinkManager(){
function wirePruneProgress(){
return wireOperationProgress({host:$('#link-manager'),path:'/api/links/prune',key:'peach-link-prune-job',title:'正在重验并删除失效链接…',
busy:running=>{const button=$('#linkPrune');if(button){setActionBusy(button,running);if(!running)button.textContent='重试删除失效链接'}},
- complete:out=>{$('#linkCheckResult').innerHTML=noteHtml(`已删除 ${out.removed} 条;保留 ${out.recovered} 条恢复的链接。`,{label:'完成'})}});
+ complete:out=>{$('#linkCheckResult').innerHTML=noteHtml(`已删除 ${out.removed} 条;保留 ${out.recovered} 条未确认失效的链接。`,{label:'完成'})}});
}
function resourceSyncMarkup(){
return `<section class="resourcesync" id="resource-sync" aria-labelledby="resourceSyncTitle">
@@ -3121,7 +3121,7 @@ async function wireResourceSync(){
<div class="resourcecache"><div><span>孤立缓存</span><b>${cache.files.toLocaleString()}</b><small>${fmtSize(cache.bytes||0)}</small></div>
<div><span>待同步</span><b>${Number(payload.missing||0).toLocaleString()} 项</b></div></div>
${hasChanges?noteHtml(`将把 ${payload.missing||0} 项移入回收站,并删除 ${cache.files||0} 个可重建缓存。`,{variant:'warning',label:'同步影响'}):''}
- <div class="resourceapplyrow">${hasChanges?`<button class="resourceaction" type="button" id="resourceApply">同步并清理</button>`:
+ <div class="resourceapplyrow">${hasChanges?`<button class="resourceaction warning" type="button" id="resourceApply">同步并清理</button>`:
'<p class="resourcesyncok">本地数据库与已挂载网盘一致,没有孤立缓存。</p>'}</div></div>`;
$('#resourceApply')?.addEventListener('click',async event=>{
const button=event.currentTarget;
diff --git a/web/css/23-configuration.css b/web/css/23-configuration.css
index 177222dfa..aa055d0fa 100644
--- a/web/css/23-configuration.css
+++ b/web/css/23-configuration.css
@@ -3,6 +3,12 @@
底部操作条 --fieldset-bar-h、左说明右动作。 */
.configuration-layout .managetitle,.configuration-layout .pagelede{width:min(812px,100%);margin-left:auto;margin-right:auto}
.configpage{width:min(812px,100%);margin:0 auto;display:grid;gap:20px}
+.configgroup{margin:16px 0 0;font-size:var(--fs-lg);font-weight:600}
+.configgroup:first-child{margin-top:0}
+.resourceapplyrow>p{margin-right:auto;text-align:left}
+.resourceaction.warning{background:var(--meter);border-color:var(--meter);color:light-dark(var(--ink),var(--ground))}
+.resourceaction.warning:hover:not(:disabled){background:color-mix(in srgb,var(--meter) 88%,#fff);border-color:var(--meter);color:light-dark(var(--ink),var(--ground))}
+.resourceaction.warning:disabled{background:var(--surface);border-color:var(--line);color:var(--muted)}
.configpage .geist-button{min-height:var(--control-h)}
.configfieldset{display:flex;flex-direction:column;min-width:0;margin:0;padding:0;overflow:hidden;
border:1px solid var(--line);border-radius:var(--control-radius);background:var(--ground)}
diff --git a/web/dist/peach-ui.js b/web/dist/peach-ui.js
index 44df4eb84..9bf729d5a 100644
--- a/web/dist/peach-ui.js
+++ b/web/dist/peach-ui.js
@@ -1443,10 +1443,18 @@ function _t({ receipt: e, data: t, error: n }) {
}) : /* @__PURE__ */ K("div", {
class: "configpage",
children: [
+ t.startup ? /* @__PURE__ */ K("h2", {
+ class: "configgroup",
+ children: "通用"
+ }) : null,
t.startup ? /* @__PURE__ */ K(at, {
startup: t.startup,
receipt: e
}) : null,
+ /* @__PURE__ */ K("h2", {
+ class: "configgroup",
+ children: "媒体"
+ }),
t.editable ? /* @__PURE__ */ K(gt, {
data: t,
receipt: e
@@ -1455,6 +1463,10 @@ function _t({ receipt: e, data: t, error: n }) {
label: "只读"
}) }),
/* @__PURE__ */ K(mt, { data: t }),
+ t.peach_proxy || t.access ? /* @__PURE__ */ K("h2", {
+ class: "configgroup",
+ children: "网络与访问"
+ }) : null,
t.peach_proxy ? /* @__PURE__ */ K(nt, {
initial: t.peach_proxy,
receipt: e
@@ -1463,6 +1475,10 @@ function _t({ receipt: e, data: t, error: n }) {
initial: t.access,
receipt: e
}) : null,
+ /* @__PURE__ */ K("h2", {
+ class: "configgroup",
+ children: "更新与维护"
+ }),
t.updates ? /* @__PURE__ */ K(tt, {
initial: t.updates,
initialJob: t.update_job