Peach: Local-first video metadata scraper and media manager.
feat(web): 没设访问密码时,卡片里常驻一条警示
longmeidao3644023c3409
diff --git a/frontend/src/islands/access-settings.tsx b/frontend/src/islands/access-settings.tsxindex c7b543842..7130dcb83 100644--- a/frontend/src/islands/access-settings.tsx+++ b/frontend/src/islands/access-settings.tsx@@ -58,9 +58,12 @@ export function AccessSettings({ initial, receipt }: { initial: AccessState; rec});};return <SettingsSection titleId="accessTitle" title="访问密码" warning={disable} onSubmit={submit} noValidate formRef={form} error={error}- help={state.mode === 'open' ? '未设置密码,能连接到 Peach 的设备可直接访问。' : state.mode === 'legacy' ? '当前使用系统生成的访问口令。你可以设置自己的密码,或关闭登录要求。' : state.mode === 'locked' ? '访问设置无法读取,请在本机检查配置文件。' : '已设置密码。新设备需要登录,保持登录时间在登录页选择。'}+ help={state.mode === 'legacy' ? '当前使用系统生成的访问口令。你可以设置自己的密码,或关闭登录要求。' : state.mode === 'locked' ? '访问设置无法读取,请在本机检查配置文件。' : state.mode === 'password' ? '已设置密码。新设备需要登录,保持登录时间在登录页选择。' : undefined}footer={state.mode !== 'locked' && <><p>保存后立即生效。</p><button class="geist-button primary" type="submit" ref={button}>保存配置</button></>}>- {state.mode === 'password' || state.mode === 'legacy' ? <label class="configcheck"><span class="pcheck"><input type="checkbox" checked={disable} onChange={(event) => setDisable(event.currentTarget.checked)} /><span aria-hidden="true"><svg viewBox="0 0 24 24"><use href="#i-check" /></svg></span></span><span>关闭访问密码,允许能连接到 Peach 的设备直接访问</span></label> : null}+ {/* 没有密码是这台机器当前的状态,不是填表时的一句说明:同一个局域网里任何一台+ 设备打开地址就进馆藏。灰色小字和其他字段的提示长得一样,扫一眼会滑过去。 */}+ {state.mode === 'open' ? <div dangerouslySetInnerHTML={{__html:noteHtml('能连接到 Peach 的设备打开地址就能看馆藏,不需要登录。',{variant:'warning',label:'未设置访问密码'})}} /> : null}+ {state.mode === 'password' || state.mode === 'legacy' ?<label class="configcheck"><span class="pcheck"><input type="checkbox" checked={disable} onChange={(event) => setDisable(event.currentTarget.checked)} /><span aria-hidden="true"><svg viewBox="0 0 24 24"><use href="#i-check" /></svg></span></span><span>关闭访问密码,允许能连接到 Peach 的设备直接访问</span></label> : null}{state.mode === 'password' ? <PasswordField id="access-current" label="当前访问密码" value={current} onInput={setCurrent} error={fields.current_password} current /> : null}{state.mode !== 'locked' ? <><PasswordField id="access-password" label={state.mode === 'password' ? '新访问密码' : '设置访问密码'} value={password} onInput={setPassword} disabled={disable} error={disable ? undefined : fields.password} help={disable ? '关闭访问密码时无需填写。' : '至少 8 个字符。保存后其他设备需要重新登录。'} />diff --git a/frontend/test/access-settings.test.tsx b/frontend/test/access-settings.test.tsxindex ab2884f52..0da654145 100644--- a/frontend/test/access-settings.test.tsx+++ b/frontend/test/access-settings.test.tsx@@ -24,7 +24,7 @@ it('系统口令可直接转为可选密码且关闭需要明确提交', async (host.querySelector('form')!.dispatchEvent(new Event('submit', { cancelable: true })); await settle();expect(JSON.parse((fetcher.mock.calls[0] as unknown as [string, RequestInit])[1].body as string)).toMatchObject({ action: 'disable', confirm_disable: true });expect(receipt).toHaveBeenCalledWith('已关闭访问密码');- expect(host.textContent).toContain('未设置密码');+ expect(host.querySelector('.geist-note-warning')?.textContent).toContain('未设置访问密码');});it('关闭选项位于输入上方且保留草稿并要求当前密码验证', async () => {@@ -77,7 +77,9 @@ it('长度提示紧贴字段且提交不合法内容时变为字段错误', asynconst fetcher = vi.fn(); vi.stubGlobal('fetch', fetcher);render(<AccessSettings initial={{ mode: 'open', revision: 'one' }} receipt={vi.fn()} />, host);expect(host.querySelector('.configfieldset-heading #accessTitle')).not.toBeNull();- expect(host.querySelector('.configfieldset-heading > .confighelp')?.textContent).toContain('未设置密码');+ // 没有密码是当前状态,画成警示 Note;标题下那行灰色小字只留给填表提示。+ expect(host.querySelector('.geist-note-warning')?.textContent).toContain('未设置访问密码');+ expect(host.querySelector('.configfieldset-heading > .confighelp')).toBeNull();const field = host.querySelector<HTMLInputElement>('#access-password')!;expect(field.nextElementSibling?.textContent).toContain('至少 8 个字符');host.querySelector('form')!.dispatchEvent(new Event('submit', { cancelable: true })); await settle();diff --git a/web/dist/peach-ui.js b/web/dist/peach-ui.jsindex 6dc477208..d19f9d53e 100644--- a/web/dist/peach-ui.js+++ b/web/dist/peach-ui.js@@ -1911,7 +1911,7 @@ function Pn({ initial: e, receipt: t }) {noValidate: !0,formRef: m,error: v,- help: n.mode === "open" ? "未设置密码,能连接到 Peach 的设备可直接访问。" : n.mode === "legacy" ? "当前使用系统生成的访问口令。你可以设置自己的密码,或关闭登录要求。" : n.mode === "locked" ? "访问设置无法读取,请在本机检查配置文件。" : "已设置密码。新设备需要登录,保持登录时间在登录页选择。",+ help: n.mode === "legacy" ? "当前使用系统生成的访问口令。你可以设置自己的密码,或关闭登录要求。" : n.mode === "locked" ? "访问设置无法读取,请在本机检查配置文件。" : n.mode === "password" ? "已设置密码。新设备需要登录,保持登录时间在登录页选择。" : void 0,footer: n.mode !== "locked" && /* @__PURE__ */ q(F, { children: [/* @__PURE__ */ q("p", { children: "保存后立即生效。" }), /* @__PURE__ */ q("button", {class: "geist-button primary",type: "submit",@@ -1919,6 +1919,10 @@ function Pn({ initial: e, receipt: t }) {children: "保存配置"})] }),children: [+ n.mode === "open" ? /* @__PURE__ */ q("div", { dangerouslySetInnerHTML: { __html: g("能连接到 Peach 的设备打开地址就能看馆藏,不需要登录。", {+ variant: "warning",+ label: "未设置访问密码"+ }) } }) : null,n.mode === "password" || n.mode === "legacy" ? /* @__PURE__ */ q("label", {class: "configcheck",children: [/* @__PURE__ */ q("span", {@@ -2559,15 +2563,28 @@ function Gn() {scope: "row",children: e.name}),- /* @__PURE__ */ q("td", { children: e.cache }),- /* @__PURE__ */ q("td", { children: e.read }),- /* @__PURE__ */ q("td", { children: e.task })+ /* @__PURE__ */ q("td", {+ "data-label": "缓存上限",+ children: e.cache+ }),+ /* @__PURE__ */ q("td", {+ "data-label": "读取长度(默认 / 最小)",+ children: e.read+ }),+ /* @__PURE__ */ q("td", {+ "data-label": "同时处理视频",+ children: e.task+ })] }, e.name)) })]})}),/* @__PURE__ */ q("ul", {class: "cloudguide-notes",- children: [/* @__PURE__ */ q("li", { children: "缓存上限和清理方式填在 CloudDrive「设置」里,清理方式选 LRU。上限不要填 0,系统盘至少留 40 GiB;填完重开设置页确认存住了。" }), /* @__PURE__ */ q("li", { children: "读取长度和下载线程填在每个网盘各自的下载设置里,线程都从 2 开始。" })]+ children: [+ /* @__PURE__ */ q("li", { children: "缓存上限和清理方式填在 CloudDrive「设置」里,清理方式选 LRU。上限不要填 0,系统盘至少留 40 GiB;填完重开设置页确认存住了。" }),+ /* @__PURE__ */ q("li", { children: "读取长度和下载线程填在每个网盘各自的下载设置里,线程都从 2 开始。" }),+ /* @__PURE__ */ q("li", { children: "Buffer Cache 占内存,磁盘缓存和文件夹缓存占硬盘,改一个管不住另外两个。" })+ ]}),/* @__PURE__ */ q("p", {class: "confighelp",