Skip to content

armgit / peach

Public Imported from GitHub
0

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

feat(docker): 全新部署走与桌面相同的首次设置页

longmeidaob62bb3aefd99
diff --git a/frontend/src/react/pages/first-access.ts b/frontend/src/react/pages/first-access.ts
new file mode 100644
index 000000000..4a46ce697
--- /dev/null
+++ b/frontend/src/react/pages/first-access.ts
@@ -0,0 +1,3 @@
+/* Docker 首次设置与访问设置共用的那句拒绝说明:来源不是本机或局域网,或带了代理转发头(ADR-0148)。
+ * 服务端 403 正文里是同一句(`routes_auth.FIRST_ACCESS_DENIED`)。 */
+export const FIRST_ACCESS_DENIED = '请从部署 Peach 的机器或同一局域网打开 Peach 完成设置,或在启动容器时设置 PEACH_ACCESS_PASSWORD。';
diff --git a/frontend/src/react/pages/login/access-setup.tsx b/frontend/src/react/pages/login/access-setup.tsx
index 1218a8c32..bca9a83b4 100644
--- a/frontend/src/react/pages/login/access-setup.tsx
+++ b/frontend/src/react/pages/login/access-setup.tsx
@@ -1,4 +1,4 @@
-/* Docker 首次访问设置:还没有访问策略时,登录页换成这一张卡(ADR-0148)。
+/* Docker 访问设置:已经配置过、还没有访问策略的部署,登录页换成这一张卡(ADR-0148)。全新部署走首次设置页。
*
* 和桌面首次设置的访问部分同一套控件:「访问密码」开关、两框密码与一句说明。开着时设访问密码,
* 关掉就是明确选了免登录,按钮跟着写清楚是哪一种。提交走 `POST /api/configuration/access/first`,
@@ -59,7 +59,7 @@ export function AccessSetup({ data, navigate = go }: { data: PageData; navigate?
};
return (
- <AuthCard title="访问设置" lede="第一次打开 Peach,先决定打开时要不要登录。">
+ <AuthCard title="访问设置" lede="这台 Peach 还没有访问设置,先决定打开时要不要登录。">
<form aria-labelledby="auth-card-title" className="flex flex-col gap-6" onSubmit={onSubmit} noValidate>
<CardGroup first>
<div className="flex items-start justify-between gap-4">
diff --git a/frontend/src/react/pages/login/login-page.tsx b/frontend/src/react/pages/login/login-page.tsx
index be53f1b55..6204242dd 100644
--- a/frontend/src/react/pages/login/login-page.tsx
+++ b/frontend/src/react/pages/login/login-page.tsx
@@ -19,13 +19,12 @@ import { Input } from '@/components/base/input/input';
import { Note } from '../../components/note';
import { AuthCard } from '../auth-card';
import type { PageData } from '../page-data';
+import { FIRST_ACCESS_DENIED } from '../first-access';
import { AccessSetup } from './access-setup';
/** 口令不对时框下那句话。限流与参数错误的原因由服务端给。 */
export const WRONG_PASSWORD = '访问密码不正确';
export const WRONG_TOKEN = '访问口令不正确';
-/** Docker 还没有访问策略、来源又不是本机或局域网时,卡头下面那句话。 */
-export const FIRST_ACCESS_DENIED = '请从部署 Peach 的机器或同一局域网打开 Peach 完成访问设置,或在启动容器时设置 PEACH_ACCESS_PASSWORD。';
const tokenHint = (docker: boolean) => (
<>在{docker ? '宿主机' : '运行 Peach 的环境中'}执行 <code className="wrap-anywhere">{docker ? 'docker compose exec peach peach token' : 'peach token'}</code> 查看。</>
diff --git a/frontend/src/react/pages/setup/setup-api.ts b/frontend/src/react/pages/setup/setup-api.ts
index b9f88abab..245999fbc 100644
--- a/frontend/src/react/pages/setup/setup-api.ts
+++ b/frontend/src/react/pages/setup/setup-api.ts
@@ -29,6 +29,10 @@ export interface MountDependency { name: string; message: string; download_url:
export interface SetupQuestions {
peach_proxy?: import('../../bundle').PeachProxyState;
docker?: boolean;
+ /** Docker 固定的数据目录(`/data`),不出题,只在确认页列出;其余部署为 `null`。 */
+ data_root?: string | null;
+ /** 容器启动时已按 `PEACH_ACCESS_PASSWORD` 写下访问密码,访问那一项不再出题。 */
+ access_preset?: boolean;
remote_reporting?: import('../../settings/remote-reporting-settings').RemoteReportingState;
windows: boolean;
standalone: boolean;
@@ -82,7 +86,7 @@ export interface SetupSubmission {
}
export class SetupRequestError extends Error {
- constructor(readonly status: number, message: string, readonly errors?: SetupErrors) {
+ constructor(readonly status: number, message: string, readonly errors?: SetupErrors, readonly docker = false) {
super(message);
}
}
@@ -98,8 +102,8 @@ async function request<T>(url: string, init: RequestInit, fallback: string): Pro
if (init.signal?.aborted) throw cause;
throw new SetupRequestError(0, '连接不到 Peach,请确认它仍在运行后重试');
}
- const body = await response.json().catch(() => null) as { error?: string; errors?: SetupErrors } | null;
- if (!response.ok) throw new SetupRequestError(response.status, body?.error || fallback, body?.errors);
+ const body = await response.json().catch(() => null) as { error?: string; errors?: SetupErrors; docker?: boolean } | null;
+ if (!response.ok) throw new SetupRequestError(response.status, body?.error || fallback, body?.errors, body?.docker === true);
return body as T;
}
diff --git a/frontend/src/react/pages/setup/setup-form.tsx b/frontend/src/react/pages/setup/setup-form.tsx
index f628d4314..854f50df5 100644
--- a/frontend/src/react/pages/setup/setup-form.tsx
+++ b/frontend/src/react/pages/setup/setup-form.tsx
@@ -76,7 +76,8 @@ export function SetupForm({ setup, onDone, onRestore }: { setup: SetupQuestions;
const blank = (path = ''): SetupFolder => ({ path, location: setup.media_source_default, root: '', ...firstLibrary.current,
cost: setup.media_source_default === 'local' ? 'free' : '' });
const folders = useFolderRows<SetupFolder>({
- initial: () => [blank()], blank: () => blank(), pickFolder, describe: describeFailure,
+ // 第一行带上服务端给的默认目录:Docker 是 Compose 挂载媒体的 `/media`,桌面没有默认值。
+ initial: () => [blank(setup.docker ? media?.default ?? '' : '')], blank: () => blank(), pickFolder, describe: describeFailure,
focusAfterPick: true,
});
firstLibrary.current = libraryFields(folders.rows[0]);
@@ -84,7 +85,8 @@ export function SetupForm({ setup, onDone, onRestore }: { setup: SetupQuestions;
() => Object.fromEntries(fields.map((question) => [question.key, question.default])));
const [pickingData, setPickingData] = useState(false);
const [pickError, setPickError] = useState('');
- const [accessOn, setAccessOn] = useState(setup.access_enabled);
+ const preset = Boolean(setup.access_preset);
+ const [accessOn, setAccessOn] = useState(setup.access_enabled && !preset);
const [password, setPassword] = useState('');
const [confirmation, setConfirmation] = useState('');
const [scanNow, setScanNow] = useState(setup.scan_now);
@@ -226,10 +228,12 @@ export function SetupForm({ setup, onDone, onRestore }: { setup: SetupQuestions;
<div data-setup-step-content="" style={{ '--setup-direction': `${direction * 20}px` } as CSSProperties}>
<header data-setup-step-heading="" key={step}>
<h1 id="auth-card-title" data-copy-key={`setup.title.${step}`} ref={stepTitle} tabIndex={-1} className="text-title-1-semibold text-text-primary">
- {step === 0 ? '欢迎使用 Peach' : step === 1 ? '你的媒体,放在哪里?' : step === 2 ? '在哪里使用 Peach?' : '准备好开始了'}
+ {step === 0 ? '欢迎使用 Peach' : step === 1 ? '你的媒体,放在哪里?' : step === 2 ? (setup.docker ? '访问与网络' : '在哪里使用 Peach?') : '准备好开始了'}
</h1>
<p data-copy-key={`setup.description.${step}`} className="text-body-regular text-text-secondary">
- {step === 0 ? '花一点时间,让 Peach 更适合你。' : step === 1 ? '连接已有文件夹,或先进入界面看看。' : step === 2 ? '选择访问范围,也可以为馆藏设置密码。' : '确认这些选择,剩下的交给 Peach。'}
+ {step === 0 ? '花一点时间,让 Peach 更适合你。' : step === 1 ? '连接已有文件夹,或先进入界面看看。'
+ : step === 2 ? (setup.docker ? '为馆藏设置访问密码,并选择资料采集的连接方式。' : '选择访问范围,也可以为馆藏设置密码。')
+ : '确认这些选择,剩下的交给 Peach。'}
</p>
</header>
<div hidden={step !== 0}>
@@ -341,6 +345,10 @@ export function SetupForm({ setup, onDone, onRestore }: { setup: SetupQuestions;
<div hidden={step !== 2}>
<CardGroup first labelledBy="auth-card-title">
{host ? field(host) : null}
+ {preset ? <>
+ <Label elementType="span">访问密码</Label>
+ <Note tone="info">已按 PEACH_ACCESS_PASSWORD 设置访问密码,可在配置页「网络与访问」修改。</Note>
+ </> : <>
<div className="flex items-start justify-between gap-4">
<div className="flex min-w-0 flex-col gap-0.5">
<Label id="setup-password-title" elementType="span">访问密码</Label>
@@ -349,8 +357,9 @@ export function SetupForm({ setup, onDone, onRestore }: { setup: SetupQuestions;
<Switch aria-labelledby="setup-password-title" aria-describedby="setup-access-description"
isSelected={accessOn} onChange={setAccessOn} />
</div>
- <Help>{lan ? '局域网访问推荐设置密码。未设置时,同一网络中能连接 Peach 的设备可直接进入。'
+ <Help>{lan || setup.docker ? '局域网访问推荐设置密码。未设置时,同一网络中能连接 Peach 的设备可直接进入。'
: '只有这台电脑可以访问;设置密码后,打开 Peach 仍需登录。'}</Help>
+ </>}
{accessOn
? <PasswordPair label="访问密码" password={password} confirmation={confirmation}
onPassword={setPassword} onConfirmation={setConfirmation}
@@ -378,12 +387,13 @@ export function SetupForm({ setup, onDone, onRestore }: { setup: SetupQuestions;
: null}
</CardGroup>
- <CardGroup>
+ {/* Docker 的端口与局域网名由 Compose 决定,不出题,也算不出外部访问地址。 */}
+ {setup.docker ? null : <CardGroup>
<Disclosure key={advancedOpenings} summary="高级设置" defaultOpen={advancedOpenings > 0}>
<div className="flex flex-col gap-4">{others.filter(visible).map(field)}</div>
</Disclosure>
<Help><span className="break-all">访问地址:{address}</span></Help>
- </CardGroup>
+ </CardGroup>}
</div>
<div hidden={step !== 3}>
@@ -410,8 +420,9 @@ export function SetupForm({ setup, onDone, onRestore }: { setup: SetupQuestions;
<GroupTitle id="setup-summary-title">确认设置</GroupTitle>
<FactList>
<Fact term="媒体目录">{skipMedia ? '稍后添加' : filled.length ? `${filled.length} 个文件夹 · ${libraries.length} 个媒体库` : '尚未填写'}</Fact>
- <Fact term="数据目录"><span className="break-all">{dataRoot ? values[dataRoot.key] || '尚未填写' : '未取得'}</span></Fact>
- <Fact term="访问范围">{lan ? '同一局域网的设备' : '只有这台电脑'} · {accessOn ? '使用访问密码' : '未设置访问密码'}</Fact>
+ <Fact term="数据目录"><span className="break-all">{dataRoot ? values[dataRoot.key] || '尚未填写' : setup.data_root || '未取得'}</span></Fact>
+ <Fact term="访问范围">{setup.docker ? '按 Compose 端口映射' : lan ? '同一局域网的设备' : '只有这台电脑'} · {
+ preset ? '已按 PEACH_ACCESS_PASSWORD 设置访问密码' : accessOn ? '使用访问密码' : '未设置访问密码'}</Fact>
<Fact term="首次扫描">{!skipMedia && scanNow ? '完成设置后开始' : '稍后手动开始'}</Fact>
{reporting ? <Fact term="诊断反馈">{reporting.usage || reporting.errors ? '已开启,可在上方调整' : '已关闭'}</Fact> : null}
{!skipMedia ? libraries.map(row => <Fact key={row.library_id} term={row.library || '未命名媒体库'}>{processingSummary(row)}</Fact>) : null}
@@ -420,9 +431,9 @@ export function SetupForm({ setup, onDone, onRestore }: { setup: SetupQuestions;
</div>
</div>
</div>
- <footer data-setup-footer="" key={step} data-copy-interact>
+ <footer data-setup-footer="" data-setup-footer-end={step === 0 && !onRestore ? '' : undefined} key={step} data-copy-interact>
{step > 0 ? <Button variant="ghost" onClick={() => { if (!busy) move(step - 1); }} aria-disabled={busy || undefined}>返回</Button>
- : <Button variant="ghost" onClick={onRestore}>使用已有数据</Button>}
+ : onRestore ? <Button variant="ghost" onClick={onRestore}>使用已有数据</Button> : null}
<Button type="submit" {...busyProps(busy)}>{step === 0 ? '开始设置' : step === 3 ? '完成设置' : '继续'}</Button>
</footer>
</form>
diff --git a/frontend/src/react/pages/setup/setup-page.tsx b/frontend/src/react/pages/setup/setup-page.tsx
index 0ab24c64c..d2da64c34 100644
--- a/frontend/src/react/pages/setup/setup-page.tsx
+++ b/frontend/src/react/pages/setup/setup-page.tsx
@@ -1,11 +1,13 @@
/* 首次运行页:取题目、画表单,成功后在同一页换成完成态。
*
- * 题目接口只对运行 Peach 的这台电脑开放;别的设备打开时它回 403,页面不画表单,只说去哪里打开。 */
+ * 题目接口只对运行 Peach 的这台电脑开放(Docker 是部署机器与局域网);别的设备打开时它回 403,
+ * 页面不画表单,只说去哪里打开。Docker 的 403 正文带 `docker`,那句话换成容器的说法。 */
import { useEffect, useState } from 'react';
import { Button } from '@/components/base/buttons/button';
import { Note } from '../../components/note';
+import { FIRST_ACCESS_DENIED } from '../first-access';
import { describeFailure, fetchQuestions, SetupRequestError, type SetupDone, type SetupQuestions } from './setup-api';
import { SetupDoneView } from './setup-done';
import { SetupForm } from './setup-form';
@@ -14,7 +16,7 @@ import { SetupShell } from './setup-scene';
type View =
| { kind: 'loading' }
- | { kind: 'denied' }
+ | { kind: 'denied'; docker: boolean }
| { kind: 'failed'; message: string }
| { kind: 'form'; setup: SetupQuestions }
| { kind: 'done'; done: SetupDone };
@@ -31,7 +33,7 @@ export function SetupPage() {
(cause: unknown) => {
if (controller.signal.aborted) return;
setView(cause instanceof SetupRequestError && cause.status === 403
- ? { kind: 'denied' }
+ ? { kind: 'denied', docker: cause.docker }
: { kind: 'failed', message: describeFailure(cause) });
});
return () => controller.abort();
@@ -42,8 +44,9 @@ export function SetupPage() {
setView({ kind: 'loading' });
setAttempt((count) => count + 1);
};
+ // Docker 的数据目录就是 `/data` 卷,接回已有数据是换卷,不在页面上做。
if (view.kind === 'form' && !restoring) return <SetupForm setup={view.setup}
- onRestore={() => setRestoring(true)} onDone={(done) => setView({ kind: 'done', done })} />;
+ onRestore={view.setup.docker ? undefined : () => setRestoring(true)} onDone={(done) => setView({ kind: 'done', done })} />;
if (view.kind === 'form') return <SetupRestore onBack={() => setRestoring(false)}
onDone={(done) => setView({ kind: 'done', done })} />;
return (
@@ -56,7 +59,8 @@ export function SetupPage() {
<p className="text-body-regular text-text-secondary">花一点时间,让 Peach 更适合你。</p>
</header>
{view.kind === 'loading' ? <div data-setup-loading="" data-skeleton="" role="status" aria-label="正在读取设置"><span /><span /><span /></div> : null}
- {view.kind === 'denied' ? <Note tone="error">请在运行 Peach 的这台电脑上打开设置。</Note> : null}
+ {view.kind === 'denied'
+ ? <Note tone="error">{view.docker ? FIRST_ACCESS_DENIED : '请在运行 Peach 的这台电脑上打开设置。'}</Note> : null}
{view.kind === 'failed'
? <Note tone="error" action={<Button variant="secondary" onClick={retry}>立即重试</Button>}>{view.message}</Note>
: null}
diff --git a/frontend/test/react/entry-pages.test.tsx b/frontend/test/react/entry-pages.test.tsx
index f73078184..7578e1ecc 100644
--- a/frontend/test/react/entry-pages.test.tsx
+++ b/frontend/test/react/entry-pages.test.tsx
@@ -2,7 +2,8 @@ import { describe, expect, it, vi } from 'vitest';
import { ErrorPage } from '../../src/react/pages/error/error-page';
import { AccessSetup, FIRST_ACCESS_URL } from '../../src/react/pages/login/access-setup';
-import { FIRST_ACCESS_DENIED, LoginPage, WRONG_PASSWORD, WRONG_TOKEN } from '../../src/react/pages/login/login-page';
+import { FIRST_ACCESS_DENIED } from '../../src/react/pages/first-access';
+import { LoginPage, WRONG_PASSWORD, WRONG_TOKEN } from '../../src/react/pages/login/login-page';
import { buttonNamed, click, fetchMock, mount, sentBody, settle, submit, switches, type } from './render';
const tokenInput = (root: ParentNode) => root.querySelector<HTMLInputElement>('input[name="token"]');
diff --git a/frontend/test/react/setup-page.test.tsx b/frontend/test/react/setup-page.test.tsx
index 303e6e229..0b73587c4 100644
--- a/frontend/test/react/setup-page.test.tsx
+++ b/frontend/test/react/setup-page.test.tsx
@@ -6,6 +6,7 @@ import { SetupPage } from '../../src/react/pages/setup/setup-page';
import { SETUP_QUESTIONS_URL, SETUP_URL, type SetupDone, type SetupQuestions } from '../../src/react/pages/setup/setup-api';
import { RESTART_REDIRECT_MS } from '../../src/react/restart-redirect';
import { MEDIA_SOURCE_OPTIONS } from '../../src/core/media-sources';
+import { FIRST_ACCESS_DENIED } from '../../src/react/pages/first-access';
import { buttonNamed, choose, click, mount, settle, switches, type } from './render';
import '../../src/copy-editor-core.js';
@@ -505,6 +506,62 @@ describe('完成态', () => {
});
});
+describe('Docker', () => {
+ const docker = (over: Partial<SetupQuestions> = {}) => ({
+ windows: false, docker: true, data_root: '/data', access_preset: false,
+ media_root: { label: '数据库中的路径前缀', placeholder: '自动配置' },
+ questions: [{ key: 'media_dir', label: '媒体目录', help: [], default: '/media', required: true, advanced: false,
+ input: 'folders' as const, prefix: '', suffix: '' }],
+ ...over,
+ });
+
+ it('不出数据目录、访问范围与高级设置,媒体目录预填 /media,也不提供接回已有数据', async () => {
+ const { host, sent } = await open(docker(), { [SETUP_URL]: { status: 200, body: done({ url: '/?onboarding=1' }) } });
+ expect(buttonNamed('使用已有数据', host)).toBeNull();
+ expect(host.querySelector('[aria-label^="首次设置"]')?.getAttribute('aria-label')).toBe('首次设置,第 1 步,共 4 步');
+ await click(buttonNamed('开始设置', host)); await settle();
+ expect(paths(host)[0]?.value).toBe('/media');
+ expect(host.querySelector('#f-data_root')).toBeNull();
+ await click(buttonNamed('继续', host)); await settle();
+ expect(host.querySelector('h1')?.textContent).toBe('访问与网络');
+ expect(radio(host, '只有这台电脑')).toBeUndefined();
+ expect(advanced(host)).toBeUndefined();
+ expect(host.textContent).not.toContain('访问地址:');
+ expect(host.querySelector('#access-password')).not.toBeNull();
+ await type(host.querySelector<HTMLInputElement>('#access-password'), 'correct-password');
+ await type(host.querySelector<HTMLInputElement>('#access-confirm'), 'correct-password');
+ await click(buttonNamed('继续', host)); await settle();
+ expect(host.textContent).toContain('/data');
+ expect(host.textContent).toContain('按 Compose 端口映射 · 使用访问密码');
+ await click(buttonNamed('完成设置', host)); await settle();
+ const body = sent(SETUP_URL);
+ expect(body.media_dir[0]).toMatchObject({ path: '/media' });
+ expect(body).toMatchObject({ access_enabled: true, access_password: 'correct-password' });
+ expect(['data_root', 'host', 'port', 'mdns_name'].filter((key) => key in body)).toEqual([]);
+ });
+
+ it('已按 PEACH_ACCESS_PASSWORD 设好访问密码时只标明已设置,提交不带密码', async () => {
+ const { host, sent } = await open(docker({ access_preset: true }), { [SETUP_URL]: { status: 200, body: done() } });
+ await click(buttonNamed('开始设置', host)); await settle();
+ await click(buttonNamed('继续', host)); await settle();
+ expect(switches(host)).toHaveLength(0);
+ expect(host.querySelector('#access-password')).toBeNull();
+ expect(host.textContent).toContain('已按 PEACH_ACCESS_PASSWORD 设置访问密码');
+ await submitForm(host);
+ const body = sent(SETUP_URL);
+ expect(body.access_enabled).toBe(false);
+ expect('access_password' in body).toBe(false);
+ });
+
+ it('来源不是部署机器或局域网时说清楚去哪里打开,或用 PEACH_ACCESS_PASSWORD', async () => {
+ server({ [SETUP_QUESTIONS_URL]: { status: 403, body: { error: FIRST_ACCESS_DENIED, docker: true } } });
+ const host = await mount(<SetupPage />);
+ await settle();
+ expect(host.querySelector('form')).toBeNull();
+ expect(host.querySelector('[role="alert"]')?.textContent).toBe(FIRST_ACCESS_DENIED);
+ });
+});
+
it('别的设备打开时读题接口回 403,只说去哪里打开、不画表单', async () => {
server({ [SETUP_QUESTIONS_URL]: { status: 403, body: { error: 'setup is loopback-only' } } });
const host = await mount(<SetupPage />);
diff --git a/src/peach/api.py b/src/peach/api.py
index 7d05470fc..9010ffb2d 100644
--- a/src/peach/api.py
+++ b/src/peach/api.py
@@ -35,7 +35,7 @@ from starlette.exceptions import HTTPException as StarletteHTTPException
from starlette.datastructures import MutableHeaders
from starlette.middleware.gzip import DEFAULT_EXCLUDED_CONTENT_TYPES, GZipMiddleware
-from . import (__version__, browser_transport, feeds, ledger_backups, tunnel, web_contract,
+from . import (__version__, browser_transport, distribution, feeds, ledger_backups, tunnel, web_contract,
web_feeds, web_follow, web_settings)
from . import routes_api, routes_auth, routes_configuration, routes_jav_browser, routes_media, routes_pages, routes_subtitles
from .buildinfo import frozen_build
@@ -73,12 +73,13 @@ from .previews import (
from .follow_secrets import credential_store_for
from .push_discovery import PushDiscoveryService
from .web_downloads import build_download_service
+from .web_local_access import local_client
from .sample_images import SampleCache
from .sample_images import cache_root as sample_cache_root
from .providers import OpenCodeGoClient, default_registry
from .repository import LedgerDatabase, LedgerRepository
from .review_mirror import ReviewMirror
-from .routes_auth import AssetLoginRequired, PageLoginRequired
+from .routes_auth import FIRST_ACCESS_DENIED, AssetLoginRequired, PageLoginRequired
# 两档缓存时长的实现在 `routes_media`,这里再导出:它们是对外的缓存契约,
# tests/test_follow_web.py 按 `api.MEDIA_CACHE_SECONDS` 断言两者的关系。
from .routes_media import AVATAR_CACHE_SECONDS, MEDIA_CACHE_SECONDS # noqa: F401
@@ -142,6 +143,30 @@ class ResponseHeadersMiddleware:
await self.app(scope, receive, send_headers)
+class FirstSetupSourceMiddleware:
+ """Docker 首次设置完成前,服务没有口令也没有访问策略,谁连得上谁就能调接口(ADR-0148)。
+
+ 这段时间 `/api/` 与写请求只收 `local_client` 认的来源:本机或私有网络、不带代理转发头。
+ 页面壳与静态资源照常给,来源不满足的浏览器也能看到首次设置页上那句说明。配置完成后
+ 服务换成正常模式,由口令与访问策略把关,这一层不再起作用。
+ """
+
+ def __init__(self, app):
+ self.app = app
+
+ async def __call__(self, scope, receive, send):
+ if scope["type"] == "http" and distribution.docker():
+ request = Request(scope)
+ settings = request.app.state.settings
+ if (not settings.configured
+ and (scope["path"].startswith("/api/") or scope["method"] not in {"GET", "HEAD"})
+ and not local_client(request)):
+ response = JSONResponse({"error": FIRST_ACCESS_DENIED, "docker": True}, status_code=403)
+ await response(scope, receive, send)
+ return
+ await self.app(scope, receive, send)
+
+
#: Starlette 自己抛的那几种 HTTPException 带的是英文 detail,给人看之前换成中文。
_DEFAULT_DETAILS = {
"Not Found": "这个地址下没有页面。",
@@ -690,6 +715,7 @@ def create_app(
name="vendor",
)
+ app.add_middleware(FirstSetupSourceMiddleware)
app.add_middleware(ResponseHeadersMiddleware)
# JSON 契约、页面脚本与样式是仅有的几类大文本响应,压下去省的字节最多:
diff --git a/src/peach/routes_auth.py b/src/peach/routes_auth.py
index f59b0bffa..7fc72a1b5 100644
--- a/src/peach/routes_auth.py
+++ b/src/peach/routes_auth.py
@@ -322,11 +322,15 @@ def set_auth_cookie(response: Response, request: Request, *, days: int = 30, log
response.delete_cookie("tok", path="/")
+#: Docker 首次设置或访问设置的来源不满足时给的那句话;页面上的同一句写在页面包里。
+FIRST_ACCESS_DENIED = "请从部署 Peach 的机器或同一局域网打开 Peach 完成设置,或在启动容器时设置 PEACH_ACCESS_PASSWORD。"
+
+
def login_mode(request: Request) -> str:
"""登录页画哪一种,由服务端判定后交给页面,页面不自己猜。
有访问策略时是 `password`,框里填访问密码。没有策略(`legacy`)时,非 Docker 部署
- 填自动生成的访问口令;Docker 没有只绑回环的首次设置页,改在这里设访问密码或选免登录
+ 填自动生成的访问口令;Docker 已经配置过(全新部署走首次设置页)时改在这里设访问密码或选免登录
(`setup`),来源须过 `local_client`:本机或私有网络、不带代理转发头。来源不满足的是
`denied`,只能用口令登录(ADR-0148)。
"""
diff --git a/src/peach/routes_configuration.py b/src/peach/routes_configuration.py
index 1ba40e0fa..74e9fd78c 100644
--- a/src/peach/routes_configuration.py
+++ b/src/peach/routes_configuration.py
@@ -32,7 +32,7 @@ from . import (access, auth, certs, data_storage, distribution, entry_links, err
web_downloads)
from .config import REPLICATION_ENABLED
from .jobs import JobAlreadyRunning
-from .routes_auth import (login_mode, origin_allowed, require_auth, require_authenticated_client, safe_next, same_origin,
+from .routes_auth import (FIRST_ACCESS_DENIED, login_mode, origin_allowed, require_auth, require_authenticated_client, safe_next, same_origin,
set_auth_cookie, sessions as access_sessions)
from .web_entry import runtime_fact_entries
from .web_local_access import local_client, managed_configuration
@@ -1073,13 +1073,9 @@ def save_access(request: Request, body: dict[str, Any] = Body(default_factory=di
return response
-#: Docker 首次访问设置的来源不满足时给的那句话;页面上的同一句写在登录页里。
-FIRST_ACCESS_DENIED = "请从部署 Peach 的机器或同一局域网打开 Peach 完成访问设置,或在启动容器时设置 PEACH_ACCESS_PASSWORD。"
-
-
@router.post("/api/configuration/access/first")
def first_access(request: Request, body: dict[str, Any] = Body(default_factory=dict)):
- """Docker 首次访问设置:还没有访问策略时,设访问密码或明确选择免登录(ADR-0148)。
+ """Docker 访问设置:已经配置过、还没有访问策略的部署设访问密码或明确选择免登录(ADR-0148)。
这时没有登录可言,边界只剩来源:`login_mode` 判 `setup` 才收,即本机或私有网络、
不带代理转发头;提交再按 `origin_allowed` 看是不是 Peach 自己的页面发的,首次设置时隧道
diff --git a/src/peach/routes_pages.py b/src/peach/routes_pages.py
index 7b30ebe30..89cd54aff 100644
--- a/src/peach/routes_pages.py
+++ b/src/peach/routes_pages.py
@@ -44,8 +44,9 @@ from .config import PROJECT_ROOT
from .diagnostic_browser import BUNDLE_CHUNK_NAME
from .entities import resolve_entity, resolve_entity_id
from .media_libraries import LIBRARY_ICONS
-from .routes_auth import (origin_allowed, query_auth_redirect, require_asset_auth, require_page_auth,
- set_auth_cookie)
+from .routes_auth import (FIRST_ACCESS_DENIED, origin_allowed, query_auth_redirect, require_asset_auth,
+ require_page_auth, set_auth_cookie)
+from .web_local_access import local_client
from .web_entry import page_shell, runtime_fact_entries
from .web_state import FAVICON
@@ -162,8 +163,11 @@ def _setup_destination(config, *, history_guide: bool) -> str:
def _normal_url(config) -> str:
"""设置完成之后本机浏览器要去的地址。
- 独立包即使对局域网监听,本机也走回环;源码部署才走由托盘维护的 HTTPS 固定入口。
+ 独立包即使对局域网监听,本机也走回环;源码部署才走由托盘维护的 HTTPS 固定入口。Docker 的
+ 外部地址由宿主机端口映射决定,服务自己不知道,留在当前地址。
"""
+ if distribution.docker():
+ return "/"
if distribution.standalone() or config.server.host in _LOOPBACK:
return f"http://127.0.0.1:{config.server.port}/"
return f"https://{config.server.mdns_name}.local/"
@@ -421,12 +425,19 @@ def _setup_guard(request: Request, *, submit: bool) -> None:
形态各不相同因为原因各不相同:已经配置过的机器上这些端点根本不存在(404,不是
「禁止」——把它做成一条可探测的 403 等于对外宣告这里有个初始化入口);非回环调用方是
403(引导服务只绑 127.0.0.1,能走到这里说明有人转发了它);独立包认地址栏里的主机名,
- 不是回环写法也是 403。提交再按 `origin_allowed` 看来源:从别的页面发来的表单不收,
- 隧道地址在首启时不算本机。
+ 不是回环写法也是 403。Docker 的请求都从网桥进来,不能只认回环,改按 `local_client`
+ 收本机与私有网络、不带代理转发头的来源(ADR-0148),403 正文带 `docker` 让页面说清楚去哪里打开。
+ 提交再按 `origin_allowed` 看来源:从别的页面发来的表单不收,隧道地址在首启时不算本机。
"""
settings = request.app.state.settings
if settings.configured:
raise HTTPException(status_code=404, detail="not found")
+ if distribution.docker():
+ if not local_client(request):
+ raise HTTPException(status_code=403, detail={"message": FIRST_ACCESS_DENIED, "docker": True})
+ if submit and not origin_allowed(request, guard="setup", tunnels=False):
+ raise HTTPException(status_code=403, detail="请从 Peach 设置页提交")
+ return
host = request.client.host if request.client else ""
if host not in _LOOPBACK:
raise HTTPException(status_code=403, detail="setup is loopback-only")
@@ -447,9 +458,10 @@ def setup_questions(request: Request):
只是不看 Origin:配置完成后这里 404,运行事实不再对外。
"""
_setup_guard(request, submit=False)
- from . import peach_proxy, remote_reporting
+ from . import access, peach_proxy, remote_reporting
windows = os.name == "nt"
- asked = onboarding.questions(settings_file.active(), windows=windows)
+ docker = distribution.docker()
+ asked = _asked(onboarding.questions(settings_file.active(), windows=windows), docker=docker)
host_labels = dict(onboarding.HOST_OPTIONS)
from .media_configuration import SOURCE_OPTIONS
items = []
@@ -459,7 +471,7 @@ def setup_questions(request: Request):
item: dict[str, object] = {
"key": question.key, "label": view["label"],
"help": [line for line in (view["help"], note) if line],
- "default": "" if question.key == "media_dir" else question.default,
+ "default": (DOCKER_MEDIA_DIR if docker else "") if question.key == "media_dir" else question.default,
# 星号与 `required` 跟着输入框走:两段式单选总有一项选中,不标。
"required": question.key != "host",
# 目录和访问范围属于首次设置主流程,端口与局域网名称按需展开。
@@ -485,11 +497,25 @@ def setup_questions(request: Request):
"scan_now": True,
"history_guide": False,
"peach_proxy": peach_proxy.describe(settings_file.active().directory("secrets")),
- "docker": os.environ.get("PEACH_DISTRIBUTION") == "docker",
+ "docker": docker,
+ # Docker 的数据目录固定是卷挂载点,不出题;完成前的确认页照样列出它。
+ "data_root": str(settings_file.active().data_root) if docker else None,
+ # 容器启动时已按 `PEACH_ACCESS_PASSWORD` 写下访问密码,页面不再出这一题。
+ "access_preset": access.load(settings_file.active().directory("secrets") / "access.json")["mode"] == "password",
"remote_reporting": remote_reporting.snapshot(),
})
+#: Docker 首次设置不出的题:数据目录是 `/data` 卷,监听地址、端口与局域网名由 Compose 决定。
+DOCKER_FIXED_QUESTIONS = frozenset({"data_root", "host", "port", "mdns_name"})
+#: Compose 把宿主机媒体目录挂到容器里的这个位置。
+DOCKER_MEDIA_DIR = "/media"
+
+
+def _asked(asked, *, docker: bool):
+ return tuple(question for question in asked if question.key not in DOCKER_FIXED_QUESTIONS) if docker else asked
+
+
def _json_text(value: object) -> str:
return "" if value is None else str(value)
@@ -535,7 +561,7 @@ async def setup_submit_json(request: Request):
submitted: dict[str, object] = {
key: _json_text(body[key])
for key in ("data_root", "host", "port", "mdns_name", "access_password", "access_confirm")
- if body.get(key) is not None}
+ if body.get(key) is not None and not (distribution.docker() and key in DOCKER_FIXED_QUESTIONS)}
submitted.update(_submitted_media_rows(body.get("media_dir")))
submitted["skip_media"] = body.get("skip_media") is True
scan_now = body.get("scan_now") is True and not submitted["skip_media"]
@@ -599,16 +625,22 @@ def _setup_done(config, *, scan_now: bool = False, history_guide: bool = False,
"history_guide": history_guide,
"restored": restored,
"standalone": distribution.standalone(),
- # 独立包的完成页过一会儿自己跳到入口;时长由前端定,与配置页保存后的跳转同一个数。
- "redirect": destination if distribution.standalone() else None,
+ # 独立包与 Docker 的完成页过一会儿自己跳到入口:服务要先换成正常模式。时长由前端定,
+ # 与配置页保存后的跳转同一个数。
+ "redirect": destination if distribution.standalone() or distribution.docker() else None,
"facts": runtime_fact_entries(config),
})
@router.post("/api/setup/restore")
async def setup_restore(request: Request):
- """接回用户指定的已有数据目录;只记录位置,沿用其中的配置、账本和访问密码。"""
+ """接回用户指定的已有数据目录;只记录位置,沿用其中的配置、账本和访问密码。
+
+ Docker 的数据目录就是 `/data` 卷,接回已有数据是换卷,不在这里做。
+ """
_setup_guard(request, submit=True)
+ if distribution.docker():
+ raise HTTPException(status_code=404, detail="not found")
try:
body = await request.json()
raw = body.get("data_root") if isinstance(body, dict) else None
diff --git a/src/peach/server.py b/src/peach/server.py
index 1b48aa4c8..2a5d74f72 100644
--- a/src/peach/server.py
+++ b/src/peach/server.py
@@ -54,6 +54,9 @@ def initialize() -> None:
return
if config.directory("database").joinpath("ledger.db").exists():
raise RuntimeError("已有数据库但缺少配置文件,请恢复 config.toml 后启动")
+ if distribution.docker():
+ # 全新数据卷不替用户答题:服务以未配置状态起来,浏览器打开就是首次设置页(ADR-0148)。
+ return
process = launch("init", "--no-input")
try:
code = process.wait(timeout=120)
@@ -67,7 +70,8 @@ def seed_access_password(config) -> str:
"""还没有访问策略时,用 `PEACH_ACCESS_PASSWORD` 写下 password 策略;返回给日志的一行,不含明文。
已有策略时忽略它:改密码走配置页,环境变量不能在每次重启时把它改回去。值不合规时只报原因、
- 照常启动,浏览器打开后仍会进入访问设置;拒绝启动会让容器反复重启。
+ 照常启动,浏览器打开后仍可在首次设置或访问设置里设密码;拒绝启动会让容器反复重启。
+ 还没有设置文件时也照写:首次设置会沿用这份策略,访问那一项标成已设置。
"""
password = os.environ.pop(ACCESS_PASSWORD_ENV, "")
if not password:
@@ -86,9 +90,15 @@ def seed_access_password(config) -> str:
def supervise(host: str, port: int, stopping: threading.Event) -> int:
service = scanner = None
+ serving_configured = False
def serve() -> subprocess.Popen:
- return launch("serve", "--host", host, "--port", str(port), "--no-mdns", "--no-ledger-sync")
+ # 还没有设置文件时起的是首次设置服务,与托盘首启同一个 `--setup`;设置一提交、设置文件
+ # 出现,下面的循环就把它换成正常服务。
+ nonlocal serving_configured
+ serving_configured = settings_file.load_config().present
+ setup = () if serving_configured else ("--setup",)
+ return launch("serve", *setup, "--host", host, "--port", str(port), "--no-mdns", "--no-ledger-sync")
def stop_all() -> None:
nonlocal service, scanner
@@ -110,7 +120,7 @@ def supervise(host: str, port: int, stopping: threading.Event) -> int:
continue
config = settings_file.load_config()
reload_path = config.directory("state") / onboarding.RELOAD_NAME
- if service is None or reload_path.exists():
+ if service is None or reload_path.exists() or config.present != serving_configured:
stop_process(service)
service = serve()
reload_path.unlink(missing_ok=True)
@@ -153,7 +163,9 @@ def main(argv: list[str] | None = None) -> int:
if seeded:
print(seeded, flush=True)
print(f"Peach 服务监听:{args.host}:{args.port}。容器外部访问地址以宿主机端口映射为准。", flush=True)
- if access.load(config.directory("secrets") / "access.json")["mode"] == "legacy":
+ if distribution.docker() and not config.present:
+ print("首次设置:从部署机器或局域网的浏览器打开 Peach,按页面完成设置。", flush=True)
+ elif access.load(config.directory("secrets") / "access.json")["mode"] == "legacy":
print("首次打开:从部署机器或局域网的浏览器打开 Peach,设置访问密码或选择免登录。" if distribution.docker()
else "首次登录:在运行 Peach 的环境中执行 peach token 查看口令,登录后设置访问密码。", flush=True)
if os.environ.get('PEACH_DISTRIBUTION') == 'docker':
diff --git a/tests/test_access.py b/tests/test_access.py
index 27d6da90b..887186119 100644
--- a/tests/test_access.py
+++ b/tests/test_access.py
@@ -584,7 +584,7 @@ class DockerFirstAccessTests(ConfigurationPageCase):
self.assertEqual(self.mode(page), "denied")
refused = await self.submit(client, **body)
self.assertEqual(refused.status_code, 403)
- self.assertEqual(refused.json()["detail"], routes_configuration.FIRST_ACCESS_DENIED)
+ self.assertEqual(refused.json()["detail"], routes_auth.FIRST_ACCESS_DENIED)
foreign = await self.device().post("/api/configuration/access/first", json=body,
headers={"Origin": "https://evil.example"})
self.assertEqual(foreign.status_code, 403)
diff --git a/tests/test_onboarding.py b/tests/test_onboarding.py
index 430d9a927..117386817 100644
--- a/tests/test_onboarding.py
+++ b/tests/test_onboarding.py
@@ -1002,6 +1002,95 @@ class SetupJsonContractTests(_SetupHttpCase):
self.assertEqual(data["url"], "http://127.0.0.1:8900/?onboarding=1")
[email protected](HAS_HTTP_DEPS, "需要 fastapi 与 httpx")
+class DockerFirstSetupTests(_SetupHttpCase):
+ """全新 Docker 走同一张首次设置页:来源按本机或私有网络判,数据目录固定为卷(ADR-0148)。"""
+
+ QUESTIONS = "/api/setup/questions"
+ SUBMIT = "/api/setup"
+ LAN = ("192.0.2.20", 51000)
+
+ def setUp(self):
+ super().setUp()
+ environment = mock.patch.dict(os.environ, {"PEACH_DISTRIBUTION": "docker", "PEACH_HEADLESS_MANAGED": "1"})
+ environment.start()
+ self.addCleanup(environment.stop)
+
+ def _body(self, **overrides):
+ root = "" if NATIVE_WINDOWS else "R:\\media"
+ body = {"media_dir": [{"path": str(self.media), "location": "local", "root": root, "cost": "free"}],
+ "scan_now": True, "access_enabled": True,
+ "access_password": "correct-password", "access_confirm": "correct-password"}
+ body.update(overrides)
+ return body
+
+ def test_lan_peers_get_the_questions_without_data_root_address_or_port(self):
+ data = self._send("GET", self.QUESTIONS, client=self.LAN).json()
+ self.assertTrue(data["docker"])
+ self.assertEqual([item["key"] for item in data["questions"]], ["media_dir"])
+ self.assertEqual(data["questions"][0]["default"], "/media")
+ self.assertEqual(data["data_root"], str(self.data_root))
+ self.assertTrue(data["access_enabled"], "Docker 对局域网开放,访问密码默认开")
+ self.assertFalse(data["access_preset"])
+
+ def test_public_and_forwarded_sources_are_refused_everywhere_but_the_page_shell(self):
+ from peach.routes_auth import FIRST_ACCESS_DENIED
+ refused = {"error": FIRST_ACCESS_DENIED, "docker": True}
+ for client, headers in ((("8.8.8.8", 1), {}), (self.LAN, {"X-Forwarded-For": "8.8.8.8"}),
+ (("127.0.0.1", 1), {"Forwarded": "for=8.8.8.8"})):
+ with self.subTest(client=client, headers=headers):
+ for method, path, body in (("GET", self.QUESTIONS, None), ("POST", self.SUBMIT, self._body()),
+ ("GET", "/api/configuration", None)):
+ response = self._send(method, path, json=body, headers=headers, client=client)
+ self.assertEqual((response.status_code, response.json()), (403, refused), path)
+ page = self._send("GET", "/", headers=headers, client=client)
+ self.assertEqual(page.status_code, 200)
+ self.assertIn('data-page="setup"', page.text)
+ foreign = self._send("POST", self.SUBMIT, json=self._body(), client=self.LAN,
+ headers={"Origin": "http://elsewhere.example"})
+ self.assertEqual((foreign.status_code, foreign.json()), (403, {"error": "请从 Peach 设置页提交"}))
+ self.assertFalse(self.data_root.exists(), "被拒的提交不落任何文件")
+
+ def test_a_lan_submission_initializes_the_fixed_data_root_and_writes_the_access_policy(self):
+ from peach import access, auth
+ body = self._body(data_root=str(self.root / "elsewhere"), host="1", port="9999", mdns_name="other")
+ response = self._send("POST", self.SUBMIT, json=body, client=self.LAN)
+ self.assertEqual(response.status_code, 200, response.text)
+ done = response.json()
+ self.assertEqual((done["url"], done["redirect"]), ("/?onboarding=1", "/?onboarding=1"))
+ self.assertTrue(done["scan_requested"])
+ self.assertFalse((self.root / "elsewhere").exists(), "数据目录不出题,提交里带了也不认")
+ saved = self._loaded()
+ self.assertTrue(saved.present)
+ self.assertEqual(saved.data_root, self.data_root)
+ self.assertEqual((saved.server.port, saved.server.mdns_name), (8900, "peach"))
+ self.assertTrue((self.data_root / "database" / "ledger.db").is_file())
+ self.assertTrue(auth.token_path(saved.directory("secrets")).is_file())
+ policy = access.load(saved.directory("secrets") / "access.json")
+ self.assertEqual(policy["mode"], "password")
+ self.assertTrue(access.verify(policy, "correct-password"))
+ self.assertEqual(onboarding.take_first_scan_request(saved), "configured")
+
+ def test_no_password_writes_an_open_policy(self):
+ from peach import access
+ response = self._send("POST", self.SUBMIT, json=self._body(access_enabled=False), client=self.LAN)
+ self.assertEqual(response.status_code, 200, response.text)
+ self.assertEqual(access.load(self.data_root / "secrets" / "access.json")["mode"], "open")
+
+ def test_a_password_preset_by_the_environment_is_kept_and_marked(self):
+ from peach import access
+ path = self.config.directory("secrets") / "access.json"
+ access.save(path, "container-secret")
+ self.assertTrue(self._send("GET", self.QUESTIONS, client=self.LAN).json()["access_preset"])
+ response = self._send("POST", self.SUBMIT, json=self._body(access_enabled=False), client=self.LAN)
+ self.assertEqual(response.status_code, 200, response.text)
+ self.assertTrue(access.verify(access.load(path), "container-secret"))
+
+ def test_restoring_another_data_root_is_not_offered(self):
+ response = self._send("POST", "/api/setup/restore", json={"data_root": str(self.root)}, client=self.LAN)
+ self.assertEqual(response.status_code, 404)
+
+
class StandaloneConfigurationTests(_Case):
def test_automatic_update_settings_roundtrip_and_access_boundaries(self):
from peach.automatic_updates import AutomaticUpdates
diff --git a/tests/test_server.py b/tests/test_server.py
index 8138d9d88..578f0811f 100644
--- a/tests/test_server.py
+++ b/tests/test_server.py
@@ -150,6 +150,46 @@ class ServerTests(unittest.TestCase):
patch.object(server, "launch", return_value=process):
self.assertEqual(server.supervise("127.0.0.1", 8900, threading.Event()), 17)
+ def test_a_fresh_docker_volume_starts_unconfigured_without_init(self):
+ with tempfile.TemporaryDirectory() as directory:
+ config = settings_file.load_config(environ={"PEACH_DATA_ROOT": str(Path(directory).resolve())})
+ with patch.dict(server.os.environ, {"PEACH_DISTRIBUTION": "docker"}), \
+ patch.object(server.settings_file, "load_config", return_value=config), \
+ patch.object(server, "launch") as launch:
+ server.initialize()
+ launch.assert_not_called()
+ self.assertFalse(config.path.exists())
+ config.directory("database").mkdir(parents=True)
+ config.directory("database").joinpath("ledger.db").write_bytes(b"existing")
+ with self.assertRaisesRegex(RuntimeError, "已有数据库"):
+ server.initialize()
+ launch.assert_not_called()
+
+ def test_the_setup_service_is_replaced_once_the_settings_file_appears(self):
+ from dataclasses import replace
+ from unittest.mock import Mock
+ with tempfile.TemporaryDirectory() as directory:
+ absent = settings_file.load_config(environ={"PEACH_DATA_ROOT": str(Path(directory).resolve())})
+ present = replace(absent, present=True)
+ state = {"configured": False}
+ stopping = threading.Event()
+ launched = []
+
+ def start(*arguments):
+ launched.append(arguments)
+ if len(launched) == 1:
+ state["configured"] = True # 首次设置提交,设置文件写好了
+ else:
+ stopping.set()
+ return Mock(poll=Mock(return_value=None))
+
+ with patch.object(server.settings_file, "load_config",
+ side_effect=lambda: present if state["configured"] else absent), \
+ patch("peach.data_storage.poll_headless", return_value=False), \
+ patch.object(server, "launch", side_effect=start):
+ self.assertEqual(server.supervise("0.0.0.0", 8900, stopping), 0)
+ self.assertEqual([arguments[:2] for arguments in launched], [("serve", "--setup"), ("serve", "--host")])
+
def test_access_password_from_the_environment_is_written_once_and_never_echoed(self):
from peach import access
with tempfile.TemporaryDirectory() as directory:
diff --git a/web/dist/peach-pages.js b/web/dist/peach-pages.js
index fa62df1d3..e6a4109cf 100644
--- a/web/dist/peach-pages.js
+++ b/web/dist/peach-pages.js
@@ -2,7 +2,7 @@
(function() {
try {
var e = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, t = new e.Error().stack;
- t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "3db88257-e295-4896-9c98-6d8a7be05798", e._sentryDebugIdIdentifier = "sentry-dbid-3db88257-e295-4896-9c98-6d8a7be05798");
+ t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "56a3ac81-61da-4987-ab16-4073f28b195b", e._sentryDebugIdIdentifier = "sentry-dbid-56a3ac81-61da-4987-ab16-4073f28b195b");
} 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, t.exports), e = null), t.exports), s = (e, i, o, s) => {
@@ -19254,8 +19254,8 @@ function mm({ tone: e, title: t, action: n, extra: r, children: i, actionLayout:
});
}
}
-// src/react/boardui/components/base/switch/switch.tsx
-var hm = Ft({
+// src/react/pages/first-access.ts
+var hm = "请从部署 Peach 的机器或同一局域网打开 Peach 完成设置,或在启动容器时设置 PEACH_ACCESS_PASSWORD。", gm = Ft({
sm: {
track: "h-4 w-7",
trackRadius: {
@@ -19317,8 +19317,8 @@ var hm = Ft({
}
}
});
-function gm({ state: e, size: t = "md", shape: n = "pill" }) {
- let r = hm[t];
+function _m({ state: e, size: t = "md", shape: n = "pill" }) {
+ let r = gm[t];
return /* @__PURE__ */ (0, z.jsx)("span", {
"aria-hidden": !0,
className: R("relative shrink-0 transition-colors duration-200 ease", r.track, r.trackRadius[n], e.isSelected ? R("bg-linear-to-b from-accent-500 to-accent-600", r.onShadow) : "bg-background-tertiary-default", e.isDisabled && "opacity-50", e.isFocusVisible && "ring-2 ring-border-focus-ring ring-offset-2"),
@@ -19328,12 +19328,12 @@ function gm({ state: e, size: t = "md", shape: n = "pill" }) {
})
});
}
-function _m({ className: e, children: t, size: n = "md", shape: r = "pill", ref: i, ...a }) {
+function vm({ className: e, children: t, size: n = "md", shape: r = "pill", ref: i, ...a }) {
return /* @__PURE__ */ (0, z.jsx)(Wp, {
ref: i,
...a,
className: (t) => R("group inline-flex items-center gap-2 select-none", t.isDisabled ? "cursor-not-allowed" : "cursor-pointer", typeof e == "function" ? e(t) : e),
- children: (e) => /* @__PURE__ */ (0, z.jsxs)(z.Fragment, { children: [/* @__PURE__ */ (0, z.jsx)(gm, {
+ children: (e) => /* @__PURE__ */ (0, z.jsxs)(z.Fragment, { children: [/* @__PURE__ */ (0, z.jsx)(_m, {
state: e,
size: n,
shape: r
@@ -19344,7 +19344,7 @@ function _m({ className: e, children: t, size: n = "md", shape: r = "pill", ref:
});
}
// src/react/settings/password-pair.tsx
-function vm({ label: e, password: t, confirmation: n, onPassword: r, onConfirmation: i, disabled: a = !1, passwordError: o, passwordHint: s, confirmationError: c, confirmationInvalid: l = !1 }) {
+function ym({ label: e, password: t, confirmation: n, onPassword: r, onConfirmation: i, disabled: a = !1, passwordError: o, passwordHint: s, confirmationError: c, confirmationInvalid: l = !1 }) {
return /* @__PURE__ */ (0, z.jsxs)(z.Fragment, { children: [/* @__PURE__ */ (0, z.jsx)(pm, {
id: "access-password",
type: "password",
@@ -19374,45 +19374,45 @@ function vm({ label: e, password: t, confirmation: n, onPassword: r, onConfirmat
})] });
}
// src/react/settings/busy-props.ts
-function ym(e) {
+function bm(e) {
return e ? {
"aria-busy": !0,
"aria-disabled": !0
} : {};
}
// src/ui-kit/collapse.ts
-var bm = /* @__PURE__ */ new WeakMap();
-function xm(e, t, n) {
- Sm(t, n, () => e.open, (t) => {
+var xm = /* @__PURE__ */ new WeakMap();
+function Sm(e, t, n) {
+ Cm(t, n, () => e.open, (t) => {
e.open = t;
});
}
-function Sm(e, t, n, r) {
+function Cm(e, t, n, r) {
e.classList.add("ui-fcollapse");
- let i = (bm.get(e) || 0) + 1;
- bm.set(e, i);
- let a = () => bm.get(e) === i;
+ let i = (xm.get(e) || 0) + 1;
+ xm.set(e, i);
+ let a = () => xm.get(e) === i;
if (t) {
e.inert = !1;
let t = n() ? e.getBoundingClientRect().height : 0;
- r(!0), wm(e, t, a);
- } else e.inert = !0, e.classList.remove("ui-fcollapse-settled"), e.style.height = e.getBoundingClientRect().height + "px", e.getBoundingClientRect(), e.style.height = "0px", Cm(e, () => {
+ r(!0), Tm(e, t, a);
+ } else e.inert = !0, e.classList.remove("ui-fcollapse-settled"), e.style.height = e.getBoundingClientRect().height + "px", e.getBoundingClientRect(), e.style.height = "0px", wm(e, () => {
a() && (r(!1), e.style.height = "");
});
}
-function Cm(e, t) {
+function wm(e, t) {
let n = !1, r, i = (a) => {
a && a.propertyName !== "height" || n || (n = !0, e.removeEventListener("transitionend", i), clearTimeout(r), t());
};
e.addEventListener("transitionend", i), r = setTimeout(i, 260);
}
-function wm(e, t, n = () => !0) {
- e.classList.remove("ui-fcollapse-settled"), e.style.height = t + "px", e.getBoundingClientRect(), e.style.height = e.scrollHeight + "px", Cm(e, () => {
+function Tm(e, t, n = () => !0) {
+ e.classList.remove("ui-fcollapse-settled"), e.style.height = t + "px", e.getBoundingClientRect(), e.style.height = e.scrollHeight + "px", wm(e, () => {
n() && (e.style.height = "auto", e.classList.add("ui-fcollapse-settled"));
});
}
// ../resources/media-sources.json
-var Tm = [
+var Em = [
{
id: "local",
name: "本地磁盘",
@@ -19461,21 +19461,21 @@ var Tm = [
cloud: !0,
icon: "database"
}
-], Em = Tm, Dm = Tm.map((e) => [e.id, e.label]);
-Tm.map((e) => e.id);
-var Om = Tm.filter((e) => e.cloud).map((e) => e.id), km = Object.fromEntries(Tm.map((e) => [e.id, e.name])), Am = {
+], Dm = Em, Om = Em.map((e) => [e.id, e.label]);
+Em.map((e) => e.id);
+var km = Em.filter((e) => e.cloud).map((e) => e.id), Am = Object.fromEntries(Em.map((e) => [e.id, e.name])), jm = {
local: "hard-drive",
guangya: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAEWUlEQVR42sWXT2hcVRTGf/fNYCZdN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V61GW5AfKy14R2Myw5u9Z2sX7PBtY0OxqdPgizAFQmmF8H5wNb/NTFnb+qL0cPf+jfD0xekF/3l9I73XyRrgvMYEzPAUrumzNcHbL3jTfhPeeNndHvpmW/cL9G+yPgAd53Ie2v6dvhw4+eO9Weiw+mcXq7tWmjdoOUbtDdkUZYvnUPK0fWulbBekPNLAAXsMCu2fGP8H7561f9HyQ2H/n6PZOxnrSJv01dgyBhsDxYWdwYHQnLC0ojLyAyrpOjWk6cVHXSp31TaRhJhvvVAVAdfZZF/vDlIj63uc1tbnOb29zmNre5zW1ucwP+G1ME77lSc/kUAAAAAElFTkSuQmCC"
-}, jm = {
- ...Object.fromEntries(Em.map((e) => [e.id, Am[e.id] || e.icon])),
+}, Mm = {
+ ...Object.fromEntries(Dm.map((e) => [e.id, jm[e.id] || e.icon])),
online: "rss",
smb: "network"
};
// src/react/boardui/components/application/settings/settings-rows.tsx
-function Mm({ label: e, description: t, children: n }) {
+function Nm({ label: e, description: t, children: n }) {
return /* @__PURE__ */ (0, z.jsxs)("div", {
className: R("flex min-h-[52px] w-full items-center justify-between gap-4 py-2.5 pr-2.5", "border-b border-separator-border last:border-b-0"),
children: [/* @__PURE__ */ (0, z.jsxs)("div", {
@@ -19491,7 +19491,7 @@ function Mm({ label: e, description: t, children: n }) {
});
}
// src/react/boardui/components/base/buttons/link-button.tsx
-var Nm = Ft({
+var Pm = Ft({
base: "inline-flex items-center justify-center gap-1 whitespace-nowrap font-sans select-none cursor-pointer rounded-sm underline-offset-3 hover:underline transition-colors duration-150 ease outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-border-focus-ring disabled:cursor-not-allowed disabled:no-underline aria-disabled:cursor-not-allowed aria-disabled:no-underline",
size: {
medium: "text-body-medium",
@@ -19508,15 +19508,15 @@ var Nm = Ft({
secondary: "text-text-secondary active:text-text-primary disabled:text-text-tertiary aria-disabled:text-text-tertiary"
}
});
-function Pm({ variant: e = "primary", size: t = "medium", leadingIcon: n, trailingIcon: r, children: i, className: a, disabled: o = !1, ...s }) {
- let c = R(Nm.base, Nm.size[t], Nm.variant[e], a), l = /* @__PURE__ */ (0, z.jsxs)(z.Fragment, { children: [
+function Fm({ variant: e = "primary", size: t = "medium", leadingIcon: n, trailingIcon: r, children: i, className: a, disabled: o = !1, ...s }) {
+ let c = R(Pm.base, Pm.size[t], Pm.variant[e], a), l = /* @__PURE__ */ (0, z.jsxs)(z.Fragment, { children: [
n ? /* @__PURE__ */ (0, z.jsx)(n, {
- className: Nm.icon[t],
+ className: Pm.icon[t],
"aria-hidden": !0
}) : null,
i != null && /* @__PURE__ */ (0, z.jsx)("span", { children: i }),
r ? /* @__PURE__ */ (0, z.jsx)(r, {
- className: Nm.icon[t],
+ className: Pm.icon[t],
"aria-hidden": !0
}) : null
] });
@@ -19542,13 +19542,13 @@ function Pm({ variant: e = "primary", size: t = "medium", leadingIcon: n, traili
});
}
// src/react/settings/section.tsx
-function Fm({ children: e }) {
+function Im({ children: e }) {
return /* @__PURE__ */ (0, z.jsx)("div", {
className: "ui-settings-rows flex flex-col empty:hidden",
children: e
});
}
-function Im({ divided: e = !1, children: t }) {
+function Lm({ divided: e = !1, children: t }) {
return e ? /* @__PURE__ */ (0, z.jsx)("div", {
className: "flex flex-col gap-4 border-t border-separator-border py-4 pr-3 empty:hidden [&>.ui-settings-facts]:-mr-3",
children: t
@@ -19557,22 +19557,22 @@ function Im({ divided: e = !1, children: t }) {
children: t
});
}
-function Lm({ role: e, children: t }) {
+function Rm({ role: e, children: t }) {
return /* @__PURE__ */ (0, z.jsx)("p", {
role: e,
className: "text-body-2-regular text-text-secondary",
children: t
});
}
-function Rm({ children: e }) {
+function zm({ children: e }) {
return /* @__PURE__ */ (0, z.jsx)("p", {
role: "alert",
className: "text-body-2-regular text-text-error-primary",
children: e
});
}
-function zm({ href: e, children: t, leadingIcon: n }) {
- return /* @__PURE__ */ (0, z.jsx)(Pm, {
+function Bm({ href: e, children: t, leadingIcon: n }) {
+ return /* @__PURE__ */ (0, z.jsx)(Fm, {
href: e,
target: "_blank",
rel: "noopener noreferrer",
@@ -19586,13 +19586,13 @@ function zm({ href: e, children: t, leadingIcon: n }) {
})
});
}
-function Bm({ children: e }) {
+function Vm({ children: e }) {
return /* @__PURE__ */ (0, z.jsx)("dl", {
className: "ui-settings-facts flex flex-col empty:hidden",
children: e
});
}
-function Vm({ term: e, children: t }) {
+function Hm({ term: e, children: t }) {
return /* @__PURE__ */ (0, z.jsxs)("div", {
className: "flex min-h-11 items-center justify-between gap-4 border-b border-separator-border py-2.5 pr-3 last:border-b-0",
children: [/* @__PURE__ */ (0, z.jsx)("dt", {
@@ -19604,10 +19604,10 @@ function Vm({ term: e, children: t }) {
})]
});
}
-function Hm({ summary: e, defaultOpen: t = !1, isOpen: n, children: r, trailing: i = !1, onOpenChange: a, contentClassName: o }) {
+function Um({ summary: e, defaultOpen: t = !1, isOpen: n, children: r, trailing: i = !1, onOpenChange: a, contentClassName: o }) {
let s = (0, j.useId)(), c = (0, j.useRef)(null), l = (0, j.useRef)(null), u = (0, j.useRef)(!1), [d, f] = (0, j.useState)(n ?? t);
return (0, j.useLayoutEffect)(() => {
- n !== void 0 && n !== d && c.current && l.current && (xm(c.current, l.current, n), f(n));
+ n !== void 0 && n !== d && c.current && l.current && (Sm(c.current, l.current, n), f(n));
}, [n, d]), /* @__PURE__ */ (0, z.jsxs)("details", {
ref: (e) => {
c.current = e, e && (n ?? t) && !u.current && (u.current = !0, e.open = !0);
@@ -19616,7 +19616,7 @@ function Hm({ summary: e, defaultOpen: t = !1, isOpen: n, children: r, trailing:
"aria-expanded": d,
"aria-controls": s,
onClick: (e) => {
- e.preventDefault(), c.current && l.current && (xm(c.current, l.current, !d), f(!d), a?.(!d));
+ e.preventDefault(), c.current && l.current && (Sm(c.current, l.current, !d), f(!d), a?.(!d));
},
className: `${i ? "w-full" : "w-fit"} flex cursor-pointer list-none items-center gap-1 rounded-sm text-body-2-medium text-text-secondary outline-none select-none hover:text-text-primary focus-visible:ring-2 focus-visible:ring-border-focus-ring`,
children: [
@@ -19641,7 +19641,7 @@ function Hm({ summary: e, defaultOpen: t = !1, isOpen: n, children: r, trailing:
})]
});
}
-function Um({ name: e }) {
+function Wm({ name: e }) {
return /* @__PURE__ */ (0, z.jsx)("svg", {
"aria-hidden": !0,
"data-source-mark": e,
@@ -19651,22 +19651,22 @@ function Um({ name: e }) {
children: /* @__PURE__ */ (0, z.jsx)("use", { href: `#i-${e}` })
});
}
-function Wm({ mark: e }) {
+function Gm({ mark: e }) {
return e.startsWith("data:image/png;base64,") ? /* @__PURE__ */ (0, z.jsx)("img", {
src: e,
alt: "",
width: 16,
height: 16,
className: "size-(--icon-inline) shrink-0"
- }) : /* @__PURE__ */ (0, z.jsx)(Um, { name: e });
+ }) : /* @__PURE__ */ (0, z.jsx)(Wm, { name: e });
}
// src/react/pages/login/access-setup.tsx
-var Gm = "/api/configuration/access/first", Km = (e) => window.location.assign(e);
-function qm({ data: e, navigate: t = Km }) {
+var Km = "/api/configuration/access/first", qm = (e) => window.location.assign(e);
+function Jm({ data: e, navigate: t = qm }) {
let [n, r] = (0, j.useState)(!0), [i, a] = (0, j.useState)(""), [o, s] = (0, j.useState)(""), [c, l] = (0, j.useState)({}), [u, d] = (0, j.useState)(""), [f, p] = (0, j.useState)(!1);
return /* @__PURE__ */ (0, z.jsx)(Bt, {
title: "访问设置",
- lede: "第一次打开 Peach,先决定打开时要不要登录。",
+ lede: "这台 Peach 还没有访问设置,先决定打开时要不要登录。",
children: /* @__PURE__ */ (0, z.jsxs)("form", {
"aria-labelledby": "auth-card-title",
className: "flex flex-col gap-6",
@@ -19683,7 +19683,7 @@ function qm({ data: e, navigate: t = Km }) {
next: e.next || "/"
};
try {
- let e = await fetch(Gm, {
+ let e = await fetch(Km, {
method: "POST",
credentials: "same-origin",
body: JSON.stringify(a),
@@ -19720,7 +19720,7 @@ function qm({ data: e, navigate: t = Km }) {
className: "text-body-2-regular text-text-secondary",
children: "开启后,访问 Peach 需要先登录。"
})]
- }), /* @__PURE__ */ (0, z.jsx)(_m, {
+ }), /* @__PURE__ */ (0, z.jsx)(vm, {
"aria-labelledby": "access-setup-title",
"aria-describedby": "access-setup-description",
isSelected: n,
@@ -19729,8 +19729,8 @@ function qm({ data: e, navigate: t = Km }) {
}
})]
}),
- /* @__PURE__ */ (0, z.jsx)(Lm, { children: "局域网访问推荐设置密码。未设置时,同一网络中能连接 Peach 的设备可直接进入。" }),
- n ? /* @__PURE__ */ (0, z.jsx)(vm, {
+ /* @__PURE__ */ (0, z.jsx)(Rm, { children: "局域网访问推荐设置密码。未设置时,同一网络中能连接 Peach 的设备可直接进入。" }),
+ n ? /* @__PURE__ */ (0, z.jsx)(ym, {
label: "访问密码",
password: i,
confirmation: o,
@@ -19759,14 +19759,14 @@ function qm({ data: e, navigate: t = Km }) {
/* @__PURE__ */ (0, z.jsx)(Rt, {
type: "submit",
className: "w-full",
- ...ym(f),
+ ...bm(f),
children: n ? "设置密码并进入" : "免登录进入"
})
]
})
});
}
-var Jm = "请从部署 Peach 的机器或同一局域网打开 Peach 完成访问设置,或在启动容器时设置 PEACH_ACCESS_PASSWORD。", Ym = (e) => /* @__PURE__ */ (0, z.jsxs)(z.Fragment, { children: [
+var Ym = (e) => /* @__PURE__ */ (0, z.jsxs)(z.Fragment, { children: [
"在",
e ? "宿主机" : "运行 Peach 的环境中",
"执行 ",
@@ -19777,7 +19777,7 @@ var Jm = "请从部署 Peach 的机器或同一局域网打开 Peach 完成访
" 查看。"
] });
function Xm({ data: e }) {
- return e.mode === "setup" ? /* @__PURE__ */ (0, z.jsx)(qm, { data: e }) : /* @__PURE__ */ (0, z.jsx)(Zm, { data: e });
+ return e.mode === "setup" ? /* @__PURE__ */ (0, z.jsx)(Jm, { data: e }) : /* @__PURE__ */ (0, z.jsx)(Zm, { data: e });
}
function Zm({ data: e }) {
let t = e.mode === "legacy" || e.mode === "denied", [n, r] = (0, j.useState)(e.error || (e.invalid === "true" ? t ? "访问口令不正确" : "访问密码不正确" : ""));
@@ -19785,7 +19785,7 @@ function Zm({ data: e }) {
title: "Peach",
children: [e.mode === "denied" ? /* @__PURE__ */ (0, z.jsx)(mm, {
tone: "warning",
- children: Jm
+ children: hm
}) : null, /* @__PURE__ */ (0, z.jsxs)("form", {
method: "post",
action: "/login",
@@ -19832,8 +19832,9 @@ function Zm({ data: e }) {
var Qm = "/api/pick-folder", $m = "/api/setup/questions", eh = "/api/setup", th = class extends Error {
status;
errors;
- constructor(e, t, n) {
- super(t), this.status = e, this.errors = n;
+ docker;
+ constructor(e, t, n, r = !1) {
+ super(t), this.status = e, this.errors = n, this.docker = r;
}
};
async function nh(e, t, n) {
@@ -19851,7 +19852,7 @@ async function nh(e, t, n) {
throw t.signal?.aborted ? e : new th(0, "连接不到 Peach,请确认它仍在运行后重试");
}
let i = await r.json().catch(() => null);
- if (!r.ok) throw new th(r.status, i?.error || n, i?.errors);
+ if (!r.ok) throw new th(r.status, i?.error || n, i?.errors, i?.docker === !0);
return i;
}
var rh = (e) => nh($m, { signal: e }, "没能读取设置题目"), ih = (e) => nh(eh, {
@@ -20016,14 +20017,14 @@ function hh({ done: e }) {
}), /* @__PURE__ */ (0, z.jsxs)("div", { children: [/* @__PURE__ */ (0, z.jsx)("p", {
className: "text-body-regular text-text-primary",
children: e.restored ? "已连接已有数据目录。" : e.skip_media ? "可在「媒体库与入库」添加媒体目录并开始扫描。" : e.scan_requested ? "首次扫描已排队,在后台整理媒体库,期间可以照常使用 Peach。" : "稍后在配置页开始扫描媒体库。"
- }), /* @__PURE__ */ (0, z.jsx)(Hm, {
+ }), /* @__PURE__ */ (0, z.jsx)(Um, {
summary: "运行信息",
- children: /* @__PURE__ */ (0, z.jsx)(Bm, { children: e.facts.map((e) => /* @__PURE__ */ (0, z.jsxs)(Vm, {
+ children: /* @__PURE__ */ (0, z.jsx)(Vm, { children: e.facts.map((e) => /* @__PURE__ */ (0, z.jsxs)(Hm, {
term: e.term,
children: [e.value, e.install_tool ? /* @__PURE__ */ (0, z.jsx)("span", {
className: "text-text-secondary",
children: "可在配置页「应用与维护」里安装。"
- }) : e.download_url ? /* @__PURE__ */ (0, z.jsx)(zm, {
+ }) : e.download_url ? /* @__PURE__ */ (0, z.jsx)(Bm, {
href: e.download_url,
children: e.download_label ?? e.download_url
}) : null]
@@ -20778,7 +20779,7 @@ Object.fromEntries(Object.entries({
later: "/watch-later",
flagged: "/flagged",
ads: "/junk-files"
-}).map(([e, t]) => [t, e])), typeof Intl < "u" && typeof Intl.Segmenter == "function" && new Intl.Segmenter(void 0, { granularity: "grapheme" }), { ...km };
+}).map(([e, t]) => [t, e])), typeof Intl < "u" && typeof Intl.Segmenter == "function" && new Intl.Segmenter(void 0, { granularity: "grapheme" }), { ...Am };
// src/ui-kit/scroll.ts
var Zg = /* @__PURE__ */ new Map(), Qg, $g = 240, e_ = 50, t_ = 70, n_ = .55, r_ = .35, i_ = 480;
function a_(e, t) {
@@ -21015,7 +21016,7 @@ function g_({ className: e }) {
children: /* @__PURE__ */ (0, z.jsx)("use", { href: "#i-folder-search" })
});
}
-var __ = Dm, v_ = (e) => jm[e] || "database", y_ = (e) => Om.includes(e);
+var __ = Om, v_ = (e) => Mm[e] || "database", y_ = (e) => km.includes(e);
function b_({ label: e, className: t, children: n }) {
return /* @__PURE__ */ (0, z.jsxs)("div", {
className: R("flex min-w-0 flex-col gap-1", t),
@@ -21060,12 +21061,12 @@ function S_({ index: e, cost: t, error: n, onChange: r }) {
children: "代理保护"
})]
}),
- n ? /* @__PURE__ */ (0, z.jsx)(Rm, { children: n }) : null
+ n ? /* @__PURE__ */ (0, z.jsx)(zm, { children: n }) : null
]
});
}
function C_() {
- return /* @__PURE__ */ (0, z.jsx)(Lm, { children: "读取策略选「代理保护」时,会限制自动读取视频。" });
+ return /* @__PURE__ */ (0, z.jsx)(Rm, { children: "读取策略选「代理保护」时,会限制自动读取视频。" });
}
function w_({ initial: e, blank: t, pickFolder: n, describe: r, focusAfterPick: i = !1 }) {
let [a, o] = (0, j.useState)(e), [s, c] = (0, j.useState)([]), [l, u] = (0, j.useState)(null), [d, f] = (0, j.useState)(null), p = (0, j.useRef)(!1), m = (0, j.useRef)([]);
@@ -21145,7 +21146,7 @@ function T_({ label: e, path: t, onPath: n, error: r, inputRef: i, picking: a, o
icon: g_,
"aria-label": "选择文件夹",
onClick: o,
- ...ym(a)
+ ...bm(a)
}),
s ? /* @__PURE__ */ (0, z.jsx)(Rt, {
variant: "danger",
@@ -21175,7 +21176,7 @@ function E_({ index: e, value: t, onChange: n, options: r = __ }) {
children: r.map(([e, t]) => /* @__PURE__ */ (0, z.jsxs)(Dh, {
id: e,
textValue: t,
- children: [/* @__PURE__ */ (0, z.jsx)(Wm, { mark: v_(e) }), t]
+ children: [/* @__PURE__ */ (0, z.jsx)(Gm, { mark: v_(e) }), t]
}, e))
})
});
@@ -21226,7 +21227,7 @@ var D_ = [
["tags", "主题"]
];
function O_(e) {
- let t = e === "local" ? "" : jm[e];
+ let t = e === "local" ? "" : Mm[e];
return t ? [t, "自动识别"] : ["hard-drive", "默认"];
}
var k_ = "auto";
@@ -21245,7 +21246,7 @@ function A_({ value: e, label: t, kind: n = "local", onChange: r }) {
children: /* @__PURE__ */ (0, z.jsxs)("span", {
"data-icon-choice": !0,
className: "flex items-center gap-2",
- children: [/* @__PURE__ */ (0, z.jsx)(Wm, { mark: e || l }), ((e) => e && D_.find(([t]) => t === e)?.[1] || u)(e)]
+ children: [/* @__PURE__ */ (0, z.jsx)(Gm, { mark: e || l }), ((e) => e && D_.find(([t]) => t === e)?.[1] || u)(e)]
})
}), /* @__PURE__ */ (0, z.jsx)(Cf, {
triggerRef: i,
@@ -21272,7 +21273,7 @@ function A_({ value: e, label: t, kind: n = "local", onChange: r }) {
value: e || k_,
"aria-label": e ? t : u,
className: "flex h-10 cursor-pointer items-center justify-center rounded-lg text-foreground-icon-secondary outline-none hover:bg-dropdown-item-hover-background focus-visible:ring-2 focus-visible:ring-border-focus-ring data-selected:bg-dropdown-item-hover-background data-selected:text-text-primary",
- children: /* @__PURE__ */ (0, z.jsx)(Wm, { mark: e || l })
+ children: /* @__PURE__ */ (0, z.jsx)(Gm, { mark: e || l })
}, e || k_))
}),
/* @__PURE__ */ (0, z.jsxs)("div", {
@@ -21748,7 +21749,7 @@ function K_({ name: e, value: t, onChange: n }) {
});
}
function q_({ name: e, value: t, onChange: n }) {
- return /* @__PURE__ */ (0, z.jsx)(Hm, {
+ return /* @__PURE__ */ (0, z.jsx)(Um, {
defaultOpen: !0,
summary: `${e} 的处理步骤(${t.length}/${U_.length})`,
children: /* @__PURE__ */ (0, z.jsx)("div", {
@@ -21937,10 +21938,10 @@ function nv({ tone: e = "neutral", ...t }) {
}
// src/react/settings/remote-reporting-settings.tsx
function rv({ value: e, onChange: t, busy: n = !1 }) {
- return /* @__PURE__ */ (0, z.jsxs)(z.Fragment, { children: [/* @__PURE__ */ (0, z.jsx)(Fm, { children: /* @__PURE__ */ (0, z.jsx)(Mm, {
+ return /* @__PURE__ */ (0, z.jsxs)(z.Fragment, { children: [/* @__PURE__ */ (0, z.jsx)(Im, { children: /* @__PURE__ */ (0, z.jsx)(Nm, {
label: "发送版本统计与错误诊断(推荐)",
description: "上传版本、系统信息、故障类型、代码位置与发生次数。",
- children: /* @__PURE__ */ (0, z.jsx)(_m, {
+ children: /* @__PURE__ */ (0, z.jsx)(vm, {
"aria-label": "发送版本统计与错误诊断(推荐)",
isSelected: e.usage && e.errors,
onChange: (n) => t({
@@ -21948,9 +21949,9 @@ function rv({ value: e, onChange: t, busy: n = !1 }) {
usage: n,
errors: n
}),
- ...ym(n)
+ ...bm(n)
})
- }) }), e.available ? null : /* @__PURE__ */ (0, z.jsx)(Im, {
+ }) }), e.available ? null : /* @__PURE__ */ (0, z.jsx)(Lm, {
divided: !0,
children: /* @__PURE__ */ (0, z.jsx)("span", {
className: "self-start",
@@ -22013,78 +22014,78 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
...g.current,
cost: e.media_source_default === "local" ? "free" : ""
}), v = w_({
- initial: () => [_()],
+ initial: () => [_(e.docker ? u?.default ?? "" : "")],
blank: () => _(),
pickFolder: oh,
describe: sh,
focusAfterPick: !0
});
g.current = iv(v.rows[0]);
- let [y, b] = (0, j.useState)(() => Object.fromEntries(f.map((e) => [e.key, e.default]))), [x, S] = (0, j.useState)(!1), [C, w] = (0, j.useState)(""), [T, E] = (0, j.useState)(e.access_enabled), [D, O] = (0, j.useState)(""), [k, ee] = (0, j.useState)(""), [A, te] = (0, j.useState)(e.scan_now), [ne, re] = (0, j.useState)(!1), [M, ie] = (0, j.useState)(e.remote_reporting), [ae, oe] = (0, j.useState)(e.peach_proxy?.mode ?? "environment"), [se, ce] = (0, j.useState)(""), [le, ue] = (0, j.useState)({}), [de, fe] = (0, j.useState)(""), [pe, me] = (0, j.useState)(""), [he, ge] = (0, j.useState)(!1), [_e, N] = (0, j.useState)(!1), [P, ve] = (0, j.useState)(0), ye = (0, j.useRef)(null), be = (0, j.useRef)(null), [xe, Se] = (0, j.useState)(0);
+ let [y, b] = (0, j.useState)(() => Object.fromEntries(f.map((e) => [e.key, e.default]))), [x, S] = (0, j.useState)(!1), [C, w] = (0, j.useState)(""), T = !!e.access_preset, [E, D] = (0, j.useState)(e.access_enabled && !T), [O, k] = (0, j.useState)(""), [ee, A] = (0, j.useState)(""), [te, ne] = (0, j.useState)(e.scan_now), [re, M] = (0, j.useState)(!1), [ie, ae] = (0, j.useState)(e.remote_reporting), [oe, se] = (0, j.useState)(e.peach_proxy?.mode ?? "environment"), [ce, le] = (0, j.useState)(""), [ue, de] = (0, j.useState)({}), [fe, pe] = (0, j.useState)(""), [me, he] = (0, j.useState)(""), [ge, _e] = (0, j.useState)(!1), [N, P] = (0, j.useState)(!1), [ve, ye] = (0, j.useState)(0), be = (0, j.useRef)(null), xe = (0, j.useRef)(null), [Se, Ce] = (0, j.useState)(0);
(0, j.useEffect)(() => {
- xe && [...ye.current?.querySelectorAll("input[aria-invalid=\"true\"]") ?? []].find((e) => !e.closest("[hidden]"))?.focus();
- }, [xe]);
- let Ce = (e) => e ? /* @__PURE__ */ (0, z.jsx)("span", {
+ Se && [...be.current?.querySelectorAll("input[aria-invalid=\"true\"]") ?? []].find((e) => !e.closest("[hidden]"))?.focus();
+ }, [Se]);
+ let we = (e) => e ? /* @__PURE__ */ (0, z.jsx)("span", {
role: "alert",
children: e
- }, xe) : void 0, we = (e) => !e.visible_when || Object.entries(e.visible_when).every(([e, t]) => y[e] === t), Te = (e, t) => b((n) => ({
+ }, Se) : void 0, Te = (e) => !e.visible_when || Object.entries(e.visible_when).every(([e, t]) => y[e] === t), Ee = (e, t) => b((n) => ({
...n,
[e]: t
- })), Ee = async (n) => {
- if (n.preventDefault(), he) return;
+ })), De = async (n) => {
+ if (n.preventDefault(), ge) return;
if (r < 3) {
l(r + 1);
return;
}
- let i = ne ? -1 : v.rows.findIndex((e) => !e.cost);
+ let i = re ? -1 : v.rows.findIndex((e) => !e.cost);
if (i >= 0) {
- N(!0), l(1), requestAnimationFrame(() => ye.current?.querySelector(`[data-media-read-policy="${i}"] button`)?.focus());
+ P(!0), l(1), requestAnimationFrame(() => be.current?.querySelector(`[data-media-read-policy="${i}"] button`)?.focus());
return;
}
- ge(!0), me("");
+ _e(!0), he("");
let a = {
- media_dir: ne ? [] : v.rows.map((e) => ({
+ media_dir: re ? [] : v.rows.map((e) => ({
...e,
library: e.library?.trim() || "未命名媒体库"
})),
- skip_media: ne,
- access_enabled: T,
- scan_now: !ne && A,
+ skip_media: re,
+ access_enabled: E,
+ scan_now: !re && te,
peach_proxy: {
- mode: ae,
- proxy: ae === "proxy" ? se : ""
+ mode: oe,
+ proxy: oe === "proxy" ? ce : ""
},
...e.history_guide ? { history_guide: !0 } : {},
- ...M ? { remote_reporting: {
- usage: M.usage,
- errors: M.errors
+ ...ie ? { remote_reporting: {
+ usage: ie.usage,
+ errors: ie.errors
} } : {}
};
- for (let e of f) we(e) && (a[e.key] = y[e.key] ?? "");
- T && Object.assign(a, {
- access_password: D,
- access_confirm: k
+ for (let e of f) Te(e) && (a[e.key] = y[e.key] ?? "");
+ E && Object.assign(a, {
+ access_password: O,
+ access_confirm: ee
});
try {
t(await ih(a));
} catch (e) {
if (e instanceof th && e.status === 400 && e.errors) {
let t = e.errors, { rows: n, table: r } = sv(t.media_dir, v.rows.length);
- v.setErrors(n), fe(r), ue(t), ov.some((e) => t[e]) && ve((e) => e + 1), t.access_password && E(!0), l(t.media_dir || d && t[d.key] ? 1 : 2), Se((e) => e + 1);
- } else me(sh(e));
+ v.setErrors(n), pe(r), de(t), ov.some((e) => t[e]) && ye((e) => e + 1), t.access_password && D(!0), l(t.media_dir || d && t[d.key] ? 1 : 2), Ce((e) => e + 1);
+ } else he(sh(e));
} finally {
- ge(!1);
+ _e(!1);
}
- }, De = (e) => {
- let t = lv(le[e.key]), n = e.help.join("");
+ }, Oe = (e) => {
+ let t = lv(ue[e.key]), n = e.help.join("");
return e.input === "choice" ? /* @__PURE__ */ (0, z.jsxs)(m_, {
id: `setup-${e.key}`,
label: e.label,
value: y[e.key] ?? e.default,
- onChange: (t) => Te(e.key, t),
+ onChange: (t) => Ee(e.key, t),
options: e.options ?? [],
isInvalid: !!t,
- children: [n ? /* @__PURE__ */ (0, z.jsx)(Lm, { children: n }) : null, t ? /* @__PURE__ */ (0, z.jsx)(Rm, { children: t }, xe) : null]
+ children: [n ? /* @__PURE__ */ (0, z.jsx)(Rm, { children: n }) : null, t ? /* @__PURE__ */ (0, z.jsx)(zm, { children: t }, Se) : null]
}, e.key) : /* @__PURE__ */ (0, z.jsx)(h_, {
id: `f-${e.key}`,
label: e.label,
@@ -22093,34 +22094,34 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
autoComplete: "off",
spellCheck: "false",
value: y[e.key] ?? "",
- onChange: (t) => Te(e.key, t),
+ onChange: (t) => Ee(e.key, t),
prefix: e.prefix,
suffix: e.suffix,
validationBehavior: "aria",
isInvalid: !!t,
- hint: Ce(t) ?? (n || void 0)
+ hint: we(t) ?? (n || void 0)
}, e.key);
- }, Oe = async () => {
+ }, ke = async () => {
if (d && !x) {
S(!0), w("");
try {
let e = await oh(y[d.key] ?? "");
- e && Te(d.key, e);
+ e && Ee(d.key, e);
} catch (e) {
w(sh(e));
} finally {
S(!1);
}
}
- }, ke = d ? lv(le[d.key]) || C : "", Ae = v.rows.map((e) => e.path.trim()).filter(Boolean), je = v.rows.some((e) => y_(e.location)), Me = [...new Map(v.rows.map((e) => [e.library_id, e])).values()], Ne = (e, t) => v.rows.forEach((n, r) => {
+ }, Ae = d ? lv(ue[d.key]) || C : "", je = v.rows.map((e) => e.path.trim()).filter(Boolean), Me = v.rows.some((e) => y_(e.location)), Ne = [...new Map(v.rows.map((e) => [e.library_id, e])).values()], Pe = (e, t) => v.rows.forEach((n, r) => {
n.library_id === e.library_id && v.edit(r, t);
- }), Pe = y.host === "2", Fe = Pe && !e.standalone ? `https://${y.mdns_name || "peach"}.local/` : `http://${Pe ? `${y.mdns_name || "peach"}.local` : "127.0.0.1"}:${y.port || "8900"}/`;
+ }), Fe = y.host === "2", Ie = Fe && !e.standalone ? `https://${y.mdns_name || "peach"}.local/` : `http://${Fe ? `${y.mdns_name || "peach"}.local` : "127.0.0.1"}:${y.port || "8900"}/`;
return /* @__PURE__ */ (0, z.jsx)(mh, {
step: r,
children: /* @__PURE__ */ (0, z.jsxs)("form", {
- ref: ye,
+ ref: be,
noValidate: !0,
- onSubmit: (e) => void Ee(e),
+ onSubmit: (e) => void De(e),
"aria-labelledby": "auth-card-title",
"data-setup-form-panel": "",
children: [
@@ -22159,11 +22160,11 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
ref: s,
tabIndex: -1,
className: "text-title-1-semibold text-text-primary",
- children: r === 0 ? "欢迎使用 Peach" : r === 1 ? "你的媒体,放在哪里?" : r === 2 ? "在哪里使用 Peach?" : "准备好开始了"
+ children: r === 0 ? "欢迎使用 Peach" : r === 1 ? "你的媒体,放在哪里?" : r === 2 ? e.docker ? "访问与网络" : "在哪里使用 Peach?" : "准备好开始了"
}), /* @__PURE__ */ (0, z.jsx)("p", {
"data-copy-key": `setup.description.${r}`,
className: "text-body-regular text-text-secondary",
- children: r === 0 ? "花一点时间,让 Peach 更适合你。" : r === 1 ? "连接已有文件夹,或先进入界面看看。" : r === 2 ? "选择访问范围,也可以为馆藏设置密码。" : "确认这些选择,剩下的交给 Peach。"
+ children: r === 0 ? "花一点时间,让 Peach 更适合你。" : r === 1 ? "连接已有文件夹,或先进入界面看看。" : r === 2 ? e.docker ? "为馆藏设置访问密码,并选择资料采集的连接方式。" : "选择访问范围,也可以为馆藏设置密码。" : "确认这些选择,剩下的交给 Peach。"
})]
}, r),
/* @__PURE__ */ (0, z.jsx)("div", {
@@ -22215,17 +22216,17 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
children: u.label
}),
/* @__PURE__ */ (0, z.jsx)(Qp, {
- isSelected: ne,
- onChange: re,
+ isSelected: re,
+ onChange: M,
children: "稍后添加媒体库"
}),
- ne ? /* @__PURE__ */ (0, z.jsx)(Lm, { children: "完成设置后,可在「媒体库与入库」添加自己的媒体目录。" }) : /* @__PURE__ */ (0, z.jsxs)(z.Fragment, { children: [
- de ? /* @__PURE__ */ (0, z.jsx)(Rm, { children: de }, xe) : null,
+ re ? /* @__PURE__ */ (0, z.jsx)(Rm, { children: "完成设置后,可在「媒体库与入库」添加自己的媒体目录。" }) : /* @__PURE__ */ (0, z.jsxs)(z.Fragment, { children: [
+ fe ? /* @__PURE__ */ (0, z.jsx)(zm, { children: fe }, Se) : null,
/* @__PURE__ */ (0, z.jsx)("div", {
role: "group",
"aria-labelledby": "setup-media-title",
className: "flex flex-col gap-3",
- children: Me.map((e) => /* @__PURE__ */ (0, z.jsxs)("div", {
+ children: Ne.map((e) => /* @__PURE__ */ (0, z.jsxs)("div", {
"data-library-block": "",
"data-setup-library-block": "",
children: [
@@ -22236,7 +22237,7 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
label: `${e.library || "未命名媒体库"} 图标`,
value: e.library_icon || "",
kind: e.location,
- onChange: (t) => Ne(e, { library_icon: t })
+ onChange: (t) => Pe(e, { library_icon: t })
}),
/* @__PURE__ */ (0, z.jsx)(pm, {
className: "w-full",
@@ -22244,20 +22245,20 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
placeholder: "媒体库名称",
maxLength: 80,
value: e.library || "",
- onChange: (t) => Ne(e, { library: t })
+ onChange: (t) => Pe(e, { library: t })
}),
/* @__PURE__ */ (0, z.jsx)(J_, {
id: e.library_id || "",
name: e.library || "未命名媒体库",
value: e.library_color || "",
- onChange: (t) => Ne(e, { library_color: t })
+ onChange: (t) => Pe(e, { library_color: t })
}),
/* @__PURE__ */ (0, z.jsx)("div", {
"data-setup-library-policy": "",
children: /* @__PURE__ */ (0, z.jsx)(K_, {
name: e.library || "未命名媒体库",
value: e.library_policy || "auto",
- onChange: (t) => Ne(e, {
+ onChange: (t) => Pe(e, {
library_policy: t,
library_stages: t === "custom" ? e.library_stages || W_.join(",") : ""
})
@@ -22268,7 +22269,7 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
e.library_policy === "custom" ? /* @__PURE__ */ (0, z.jsx)(q_, {
name: e.library || "未命名媒体库",
value: e.library_stages?.split(",").filter(Boolean) ?? W_,
- onChange: (t) => Ne(e, { library_stages: t.join(",") })
+ onChange: (t) => Pe(e, { library_stages: t.join(",") })
}) : null,
/* @__PURE__ */ (0, z.jsxs)("div", {
"data-library-folders": "",
@@ -22278,12 +22279,12 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
label: `${u.label} ${n + 1}`,
path: t.path,
onPath: (e) => v.edit(n, { path: e }),
- error: Ce(v.errors[n]),
+ error: we(v.errors[n]),
inputRef: v.inputRef(n),
picking: v.picking === n,
onPick: () => void v.pick(n),
onRemove: v.rows.length > 1 ? () => {
- v.remove(n), be.current?.focus();
+ v.remove(n), xe.current?.focus();
} : void 0,
children: /* @__PURE__ */ (0, z.jsxs)(x_, { children: [
/* @__PURE__ */ (0, z.jsx)(E_, {
@@ -22298,10 +22299,10 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
/* @__PURE__ */ (0, z.jsx)(S_, {
index: n,
cost: t.cost ?? "",
- error: _e && !t.cost ? "请选择媒体读取策略" : void 0,
+ error: N && !t.cost ? "请选择媒体读取策略" : void 0,
onChange: (e) => v.edit(n, { cost: e })
}),
- Me.length > 1 ? /* @__PURE__ */ (0, z.jsx)(b_, {
+ Ne.length > 1 ? /* @__PURE__ */ (0, z.jsx)(b_, {
label: "移到媒体库",
className: "w-full @lg:w-60",
children: /* @__PURE__ */ (0, z.jsx)(Eh, {
@@ -22310,7 +22311,7 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
selectedKey: t.library_id,
renderValue: /* @__PURE__ */ (0, z.jsxs)("span", {
className: "flex min-w-0 items-center gap-2",
- children: [/* @__PURE__ */ (0, z.jsx)(Wm, { mark: t.library_icon || O_(t.location)[0] }), /* @__PURE__ */ (0, z.jsx)("span", {
+ children: [/* @__PURE__ */ (0, z.jsx)(Gm, { mark: t.library_icon || O_(t.location)[0] }), /* @__PURE__ */ (0, z.jsx)("span", {
className: "truncate",
children: t.library || "未命名媒体库"
})]
@@ -22347,14 +22348,14 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
}, e.library_id))
}),
/* @__PURE__ */ (0, z.jsx)(Rt, {
- ref: be,
+ ref: xe,
variant: "secondary",
className: "self-start",
"data-copy-interact": !0,
onClick: () => {
v.add(), v.edit(v.rows.length, {
library_id: Oh(),
- library: `媒体库 ${Me.length + 1}`,
+ library: `媒体库 ${Ne.length + 1}`,
library_icon: "",
library_color: "",
library_policy: "auto",
@@ -22363,18 +22364,18 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
},
children: "添加媒体库"
}),
- je ? /* @__PURE__ */ (0, z.jsxs)(z.Fragment, { children: [
+ Me ? /* @__PURE__ */ (0, z.jsxs)(z.Fragment, { children: [
/* @__PURE__ */ (0, z.jsx)(C_, {}),
- /* @__PURE__ */ (0, z.jsxs)(Lm, { children: [e.cloud.help, /* @__PURE__ */ (0, z.jsx)(zm, {
+ /* @__PURE__ */ (0, z.jsxs)(Rm, { children: [e.cloud.help, /* @__PURE__ */ (0, z.jsx)(Bm, {
href: e.cloud.link.url,
children: e.cloud.link.label
})] }),
- e.cloud.dependencies.map((e) => /* @__PURE__ */ (0, z.jsxs)(Lm, { children: [e.message, /* @__PURE__ */ (0, z.jsx)(zm, {
+ e.cloud.dependencies.map((e) => /* @__PURE__ */ (0, z.jsxs)(Rm, { children: [e.message, /* @__PURE__ */ (0, z.jsx)(Bm, {
href: e.download_url,
children: e.download_label
})] }, e.name))
] }) : null,
- u.help.map((e) => /* @__PURE__ */ (0, z.jsx)(Lm, { children: e }, e))
+ u.help.map((e) => /* @__PURE__ */ (0, z.jsx)(Rm, { children: e }, e))
] })
]
}) : null, d ? /* @__PURE__ */ (0, z.jsxs)(Vt, {
@@ -22398,18 +22399,18 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
autoComplete: "off",
spellCheck: "false",
value: y[d.key] ?? "",
- onChange: (e) => Te(d.key, e),
+ onChange: (e) => Ee(d.key, e),
validationBehavior: "aria",
- isInvalid: !!ke,
- hint: Ce(ke)
+ isInvalid: !!Ae,
+ hint: we(Ae)
}), /* @__PURE__ */ (0, z.jsx)(_h, {
icon: g_,
"aria-label": "选择数据目录",
- onClick: () => void Oe(),
- ...ym(x)
+ onClick: () => void ke(),
+ ...bm(x)
})]
}),
- d.help.map((e) => /* @__PURE__ */ (0, z.jsx)(Lm, { children: e }, e))
+ d.help.map((e) => /* @__PURE__ */ (0, z.jsx)(Rm, { children: e }, e))
]
}) : null]
}),
@@ -22420,8 +22421,14 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
first: !0,
labelledBy: "auth-card-title",
children: [
- p ? De(p) : null,
- /* @__PURE__ */ (0, z.jsxs)("div", {
+ p ? Oe(p) : null,
+ T ? /* @__PURE__ */ (0, z.jsxs)(z.Fragment, { children: [/* @__PURE__ */ (0, z.jsx)(sm, {
+ elementType: "span",
+ children: "访问密码"
+ }), /* @__PURE__ */ (0, z.jsx)(mm, {
+ tone: "info",
+ children: "已按 PEACH_ACCESS_PASSWORD 设置访问密码,可在配置页「网络与访问」修改。"
+ })] }) : /* @__PURE__ */ (0, z.jsxs)(z.Fragment, { children: [/* @__PURE__ */ (0, z.jsxs)("div", {
className: "flex items-start justify-between gap-4",
children: [/* @__PURE__ */ (0, z.jsxs)("div", {
className: "flex min-w-0 flex-col gap-0.5",
@@ -22434,23 +22441,22 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
className: "text-body-2-regular text-text-secondary",
children: "开启后,访问 Peach 需要先登录。"
})]
- }), /* @__PURE__ */ (0, z.jsx)(_m, {
+ }), /* @__PURE__ */ (0, z.jsx)(vm, {
"aria-labelledby": "setup-password-title",
"aria-describedby": "setup-access-description",
- isSelected: T,
- onChange: E
+ isSelected: E,
+ onChange: D
})]
- }),
- /* @__PURE__ */ (0, z.jsx)(Lm, { children: Pe ? "局域网访问推荐设置密码。未设置时,同一网络中能连接 Peach 的设备可直接进入。" : "只有这台电脑可以访问;设置密码后,打开 Peach 仍需登录。" }),
- T ? /* @__PURE__ */ (0, z.jsx)(vm, {
+ }), /* @__PURE__ */ (0, z.jsx)(Rm, { children: Fe || e.docker ? "局域网访问推荐设置密码。未设置时,同一网络中能连接 Peach 的设备可直接进入。" : "只有这台电脑可以访问;设置密码后,打开 Peach 仍需登录。" })] }),
+ E ? /* @__PURE__ */ (0, z.jsx)(ym, {
label: "访问密码",
- password: D,
- confirmation: k,
- onPassword: O,
- onConfirmation: ee,
- passwordError: Ce(lv(le.access_password)),
+ password: O,
+ confirmation: ee,
+ onPassword: k,
+ onConfirmation: A,
+ passwordError: we(lv(ue.access_password)),
passwordHint: "请输入 8–256 个字符。",
- confirmationInvalid: !!le.access_password
+ confirmationInvalid: !!ue.access_password
}) : null
]
}),
@@ -22461,7 +22467,7 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
id: "setup-proxy-title",
children: "Peach 代理"
}),
- /* @__PURE__ */ (0, z.jsx)(Lm, { children: "用于资料采集、封面和工具下载,可在配置页修改。" }),
+ /* @__PURE__ */ (0, z.jsx)(Rm, { children: "用于资料采集、封面和工具下载,可在配置页修改。" }),
/* @__PURE__ */ (0, z.jsxs)("div", {
className: "flex flex-col items-start gap-1.5",
children: [/* @__PURE__ */ (0, z.jsx)(sm, {
@@ -22469,19 +22475,19 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
id: "setup-proxy-mode-label",
children: "连接方式"
}), /* @__PURE__ */ (0, z.jsx)(X_, {
- mode: ae,
- onChange: oe,
+ mode: oe,
+ onChange: se,
labelledBy: "setup-proxy-mode-label"
})]
}),
- ae === "proxy" ? /* @__PURE__ */ (0, z.jsx)(Z_, {
+ oe === "proxy" ? /* @__PURE__ */ (0, z.jsx)(Z_, {
id: "setupProxyAddress",
- value: se,
- onChange: ce,
+ value: ce,
+ onChange: le,
saved: e.peach_proxy?.proxy_saved,
- error: Ce(lv(le.peach_proxy))
- }) : le.peach_proxy ? /* @__PURE__ */ (0, z.jsx)(Rm, { children: lv(le.peach_proxy) }, xe) : null,
- e.docker && ae === "proxy" && Q_(se) ? /* @__PURE__ */ (0, z.jsx)(mm, {
+ error: we(lv(ue.peach_proxy))
+ }) : ue.peach_proxy ? /* @__PURE__ */ (0, z.jsx)(zm, { children: lv(ue.peach_proxy) }, Se) : null,
+ e.docker && oe === "proxy" && Q_(ce) ? /* @__PURE__ */ (0, z.jsx)(mm, {
tone: "warning",
title: "请填写容器可访问的代理地址",
children: "回环地址指向容器自身;宿主机代理需使用容器可访问的宿主机地址。"
@@ -22493,16 +22499,16 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
}) : null
]
}),
- /* @__PURE__ */ (0, z.jsxs)(Vt, { children: [/* @__PURE__ */ (0, z.jsx)(Hm, {
+ e.docker ? null : /* @__PURE__ */ (0, z.jsxs)(Vt, { children: [/* @__PURE__ */ (0, z.jsx)(Um, {
summary: "高级设置",
- defaultOpen: P > 0,
+ defaultOpen: ve > 0,
children: /* @__PURE__ */ (0, z.jsx)("div", {
className: "flex flex-col gap-4",
- children: m.filter(we).map(De)
+ children: m.filter(Te).map(Oe)
})
- }, P), /* @__PURE__ */ (0, z.jsx)(Lm, { children: /* @__PURE__ */ (0, z.jsxs)("span", {
+ }, ve), /* @__PURE__ */ (0, z.jsx)(Rm, { children: /* @__PURE__ */ (0, z.jsxs)("span", {
className: "break-all",
- children: ["访问地址:", Fe]
+ children: ["访问地址:", Ie]
}) })] })
]
}),
@@ -22515,58 +22521,58 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
children: [/* @__PURE__ */ (0, z.jsx)(Ht, {
id: "setup-options-title",
children: "首次扫描"
- }), ne ? /* @__PURE__ */ (0, z.jsx)(Lm, { children: "添加媒体目录后,再选择处理方式并开始扫描。" }) : /* @__PURE__ */ (0, z.jsxs)(z.Fragment, { children: [/* @__PURE__ */ (0, z.jsxs)("div", {
+ }), re ? /* @__PURE__ */ (0, z.jsx)(Rm, { children: "添加媒体目录后,再选择处理方式并开始扫描。" }) : /* @__PURE__ */ (0, z.jsxs)(z.Fragment, { children: [/* @__PURE__ */ (0, z.jsxs)("div", {
className: "flex flex-col gap-1.5",
children: [/* @__PURE__ */ (0, z.jsx)(Qp, {
- isSelected: A,
- onChange: te,
- children: cv(Ae)
- }), /* @__PURE__ */ (0, z.jsx)(Lm, { children: A ? "扫描会在后台开始,期间可以进入 Peach。" : "先保存处理方式,稍后在「媒体库与入库」开始扫描。" })]
- }), v.rows.some((e) => e.cost === "metered") ? /* @__PURE__ */ (0, z.jsx)(Lm, { children: "开启代理保护的目录不会自动读取视频信息或生成预览;播放时会读取视频。" }) : null] })]
+ isSelected: te,
+ onChange: ne,
+ children: cv(je)
+ }), /* @__PURE__ */ (0, z.jsx)(Rm, { children: te ? "扫描会在后台开始,期间可以进入 Peach。" : "先保存处理方式,稍后在「媒体库与入库」开始扫描。" })]
+ }), v.rows.some((e) => e.cost === "metered") ? /* @__PURE__ */ (0, z.jsx)(Rm, { children: "开启代理保护的目录不会自动读取视频信息或生成预览;播放时会读取视频。" }) : null] })]
}),
- pe ? /* @__PURE__ */ (0, z.jsx)(Rm, { children: pe }) : null,
- M ? /* @__PURE__ */ (0, z.jsxs)(Vt, { children: [
+ me ? /* @__PURE__ */ (0, z.jsx)(zm, { children: me }) : null,
+ ie ? /* @__PURE__ */ (0, z.jsxs)(Vt, { children: [
/* @__PURE__ */ (0, z.jsx)(Ht, { children: "版本统计与错误诊断" }),
/* @__PURE__ */ (0, z.jsx)(rv, {
- value: M,
- onChange: ie
+ value: ie,
+ onChange: ae
}),
- /* @__PURE__ */ (0, z.jsx)(Lm, { children: "馆藏与口味明细上传默认关闭,可在「应用与维护」查看并选择。" })
+ /* @__PURE__ */ (0, z.jsx)(Rm, { children: "馆藏与口味明细上传默认关闭,可在「应用与维护」查看并选择。" })
] }) : null,
/* @__PURE__ */ (0, z.jsxs)(Vt, {
labelledBy: "setup-summary-title",
children: [/* @__PURE__ */ (0, z.jsx)(Ht, {
id: "setup-summary-title",
children: "确认设置"
- }), /* @__PURE__ */ (0, z.jsxs)(Bm, { children: [
- /* @__PURE__ */ (0, z.jsx)(Vm, {
+ }), /* @__PURE__ */ (0, z.jsxs)(Vm, { children: [
+ /* @__PURE__ */ (0, z.jsx)(Hm, {
term: "媒体目录",
- children: ne ? "稍后添加" : Ae.length ? `${Ae.length} 个文件夹 · ${Me.length} 个媒体库` : "尚未填写"
+ children: re ? "稍后添加" : je.length ? `${je.length} 个文件夹 · ${Ne.length} 个媒体库` : "尚未填写"
}),
- /* @__PURE__ */ (0, z.jsx)(Vm, {
+ /* @__PURE__ */ (0, z.jsx)(Hm, {
term: "数据目录",
children: /* @__PURE__ */ (0, z.jsx)("span", {
className: "break-all",
- children: d ? y[d.key] || "尚未填写" : "未取得"
+ children: d ? y[d.key] || "尚未填写" : e.data_root || "未取得"
})
}),
- /* @__PURE__ */ (0, z.jsxs)(Vm, {
+ /* @__PURE__ */ (0, z.jsxs)(Hm, {
term: "访问范围",
children: [
- Pe ? "同一局域网的设备" : "只有这台电脑",
+ e.docker ? "按 Compose 端口映射" : Fe ? "同一局域网的设备" : "只有这台电脑",
" · ",
- T ? "使用访问密码" : "未设置访问密码"
+ T ? "已按 PEACH_ACCESS_PASSWORD 设置访问密码" : E ? "使用访问密码" : "未设置访问密码"
]
}),
- /* @__PURE__ */ (0, z.jsx)(Vm, {
+ /* @__PURE__ */ (0, z.jsx)(Hm, {
term: "首次扫描",
- children: !ne && A ? "完成设置后开始" : "稍后手动开始"
+ children: !re && te ? "完成设置后开始" : "稍后手动开始"
}),
- M ? /* @__PURE__ */ (0, z.jsx)(Vm, {
+ ie ? /* @__PURE__ */ (0, z.jsx)(Hm, {
term: "诊断反馈",
- children: M.usage || M.errors ? "已开启,可在上方调整" : "已关闭"
+ children: ie.usage || ie.errors ? "已开启,可在上方调整" : "已关闭"
}) : null,
- ne ? null : Me.map((e) => /* @__PURE__ */ (0, z.jsx)(Vm, {
+ re ? null : Ne.map((e) => /* @__PURE__ */ (0, z.jsx)(Hm, {
term: e.library || "未命名媒体库",
children: av(e)
}, e.library_id))
@@ -22579,21 +22585,22 @@ function uv({ setup: e, onDone: t, onRestore: n }) {
}),
/* @__PURE__ */ (0, z.jsxs)("footer", {
"data-setup-footer": "",
+ "data-setup-footer-end": r === 0 && !n ? "" : void 0,
"data-copy-interact": !0,
children: [r > 0 ? /* @__PURE__ */ (0, z.jsx)(Rt, {
variant: "ghost",
onClick: () => {
- he || l(r - 1);
+ ge || l(r - 1);
},
- "aria-disabled": he || void 0,
+ "aria-disabled": ge || void 0,
children: "返回"
- }) : /* @__PURE__ */ (0, z.jsx)(Rt, {
+ }) : n ? /* @__PURE__ */ (0, z.jsx)(Rt, {
variant: "ghost",
onClick: n,
children: "使用已有数据"
- }), /* @__PURE__ */ (0, z.jsx)(Rt, {
+ }) : null, /* @__PURE__ */ (0, z.jsx)(Rt, {
type: "submit",
- ...ym(he),
+ ...bm(ge),
children: r === 0 ? "开始设置" : r === 3 ? "完成设置" : "继续"
})]
}, r)
@@ -22677,7 +22684,7 @@ function dv({ onDone: e, onBack: t }) {
children: "返回首次设置"
}), /* @__PURE__ */ (0, z.jsx)(Rt, {
type: "submit",
- ...ym(o),
+ ...bm(o),
children: o ? "正在连接数据目录…" : "使用此目录"
})]
})
@@ -22694,14 +22701,17 @@ function fv() {
kind: "form",
setup: e
}), (n) => {
- e.signal.aborted || t(n instanceof th && n.status === 403 ? { kind: "denied" } : {
+ e.signal.aborted || t(n instanceof th && n.status === 403 ? {
+ kind: "denied",
+ docker: n.docker
+ } : {
kind: "failed",
message: sh(n)
});
}), () => e.abort();
}, [n]), e.kind === "done" ? /* @__PURE__ */ (0, z.jsx)(hh, { done: e.done }) : e.kind === "form" && !i ? /* @__PURE__ */ (0, z.jsx)(uv, {
setup: e.setup,
- onRestore: () => a(!0),
+ onRestore: e.setup.docker ? void 0 : () => a(!0),
onDone: (e) => t({
kind: "done",
done: e
@@ -22753,7 +22763,7 @@ function fv() {
}) : null,
e.kind === "denied" ? /* @__PURE__ */ (0, z.jsx)(mm, {
tone: "error",
- children: "请在运行 Peach 的这台电脑上打开设置。"
+ children: e.docker ? hm : "请在运行 Peach 的这台电脑上打开设置。"
}) : null,
e.kind === "failed" ? /* @__PURE__ */ (0, z.jsx)(mm, {
tone: "error",
@@ -22782,4 +22792,4 @@ E();
var mv = document.getElementById("peach-page"), hv = mv ? pv[mv.dataset.page ?? ""] : void 0;
mv && hv && (0, M.createRoot)(mv).render(/* @__PURE__ */ (0, z.jsx)(hv, { data: { ...mv.dataset } }));
-//# debugId=3db88257-e295-4896-9c98-6d8a7be05798
\ No newline at end of file
+//# debugId=56a3ac81-61da-4987-ab16-4073f28b195b
\ No newline at end of file