Peach: Local-first video metadata scraper and media manager.
docs: 记下托盘首启的 GUI 引导路径、切换判据与首扫标记
longmeidao9573f9ed1d35
diff --git a/README.en.md b/README.en.mdindex 98eb8dbba..111d261c4 100644--- a/README.en.md+++ b/README.en.md@@ -117,6 +117,14 @@ that `peach serve` starts the service and `peach scan local` rescans at any timesources and replication switches are all edited in that settings file, explained item by item in[`docs/OPERATIONS.md`](docs/OPERATIONS.md). The tray is started with `peach-tray`, without arguments.+You can answer in a browser instead of the terminal: skip step three and run `peach-tray` (or+double-click `Peach.exe` / `Peach.app`). Seeing that the machine is not configured yet, the tray starts a+setup service bound to `127.0.0.1` only and opens a browser on it. The page is the same five questions as a+form, plus a "scan now" checkbox that is ticked by default. On submit the tray stops the setup service,+switches to the normal Peach services, and runs the scan in the background if you asked for it. This path+calls the same logic as `peach init` and writes exactly the same files. While it waits, the tray menu reads+"等待完成首次设置" and its first item becomes "重新打开设置页".+To skip the questions, pass arguments: `peach init --no-input` (or any single option such as `--data-root`,`--port` or `--mount local=/mnt/media`) generates the file from the built-in defaults plus your arguments;the same path is taken when stdin is not a terminal. A file written this way carries three example sources,@@ -131,7 +139,7 @@ Five facts:- Ledger paths are always in the Windows shape. On Windows the media directory goes straight into `[media.locations]`; on macOS the declared root is `R:\media` and the directory goes into `[media.mounts]`, where the local mount point does the translation. CloudDrive is not required — any cloud drive that mounts as a local path works; 115 and PikPak are recommendations, not requirements.- The interface is currently available in Chinese only.-The service also starts without a settings file: `/healthz` reports `configured=false`, and the pages prompt you to run `peach init` first.+The service also starts without a settings file: `/healthz` reports `configured=false`, and the home page is the first-run form described above.## Developmentdiff --git a/README.md b/README.mdindex e72c05e93..b9a107f3c 100644--- a/README.md+++ b/README.md@@ -112,6 +112,12 @@ peach-app/端口、来源与复制开关都在那个设置文件里改,逐项说明见 [`docs/OPERATIONS.md`](docs/OPERATIONS.md)。托盘由 `peach-tray` 启动,不带参数。+不想在终端里回答也行:跳过第三步,直接跑 `peach-tray`(或双击 `Peach.exe` / `Peach.app`)。+托盘看到这台机器还没配置,就起一条只监听 `127.0.0.1` 的引导服务并把浏览器打开到它,页面+是同样五个问题的一张表单,外加一个默认勾上的「现在扫描」。提交之后托盘自动停掉引导服务、+换成正常的 Peach 服务,勾了扫描就在后台跑一遍。这条路和 `peach init` 调的是同一组逻辑,+落盘结果完全一样。托盘菜单在等待期间显示「等待完成首次设置」,第一项变成「重新打开设置页」。+不想问答就给参数:`peach init --no-input`(或任何一个参数,例如 `--data-root`、`--port`、`--mount local=/mnt/media`)按内建默认与参数直接生成;stdin 不是终端时也走这条路。这条路写出的设置文件带三个示例来源 `local = R:\media`、`115 = B:/`、`pikpak = A:/`,必须在 `[media.locations]`@@ -125,7 +131,7 @@ peach-app/- 账本里的路径一律是 Windows 形态。Windows 上媒体目录直接写进 `[media.locations]`;macOS 上声明根写 `R:\media`、目录写进 `[media.mounts]`,由本机挂载点负责翻译。CloudDrive 不是必需,任何能挂成本地路径的网盘都行;115 与 PikPak 是推荐项,不是要求。- 界面目前只有中文。-没有设置文件也能启动:`/healthz` 报 `configured=false`,页面提示先跑 `peach init`。+没有设置文件也能启动:`/healthz` 报 `configured=false`,首页是上面那张首次运行表单。## 开发diff --git a/docs/FRONTEND.md b/docs/FRONTEND.mdindex ff1573a6f..a10fe61a3 100644--- a/docs/FRONTEND.md+++ b/docs/FRONTEND.md@@ -20,6 +20,11 @@ Vite + TypeScript + Preact。迁移方式是 strangler:**遗留路由继续拥| `frontend/test/` | vitest 用例与遗留模块的桩 || `web/dist/peach-ui.js` | 构建产物,**进 Git**,由 `/dist/{name}` 提供 |+首次运行页(未配置时的 `GET /` 与 `POST /setup`)不在这张表里:它是 SPA 外壳之外的一张+独立页面,HTML 与样式都自包含在 `src/peach/routes_pages.py`,不引 `web/` 的任何资产,也不是+island。原因是那一套一上来就打 `/api/items`,而未配置的机器还没有数据库;它也没有客户端+状态,原生 `<form method="post">` 不写一行 JS 就能工作。+产物名字不带内容哈希:引用它的 `web/app.js` 不经过构建,构建时改不了那里的路径。缓存由服务端兜住:`/dist/` 与 `/app.js`、`/app.css`、`/js/` 同一档,回`Cache-Control: no-cache` 加一个 mtime+字节数的 ETag——每次都回源问,没变时回 304diff --git a/docs/OPERATIONS.md b/docs/OPERATIONS.mdindex 1371b5d50..65f112c93 100644--- a/docs/OPERATIONS.md+++ b/docs/OPERATIONS.md@@ -17,7 +17,25 @@「现在扫描 <目录>?」(默认是)调 `peach.scan.scan_location` 登记文件,最后打印下一步与扫描摘要。写出的 `[media.locations]` 只有 `local`:Windows 上直接是那个目录、`[media.mounts]` 为空;macOS 上声明根是 `R:\media`、目录写进 `[media.mounts] local`。- 复制、writer 镜像、SMB 一律不问,保持关闭或留空。+ 复制、writer 镜像、SMB 一律不问,保持关闭或留空。建目录、迁库、生成 CA 与口令、写设置文件+ 这一整段在 `onboarding.apply()`,CLI 与设置页调的是同一个函数,只在打印方式上不同。+- 不进终端的那条路是托盘首启的引导服务。`peach-tray` 启动时新鲜读一次设置文件,判据在+ `tray.needs_setup()`:**没有 `config.toml` 且没有账本**才算需要设置。刻意不用+ `PeachConfig.configured`——托盘的单实例锁一启动就在数据根下建出 `state/`,而数据根的发现+ 只看目录在不在,只用 `configured` 的话一次失败的启动就足以让下一次误判成已配置;反过来+ 还没生成过 `config.toml` 的老部署账本是在的,不能被拖进首次设置。+- 需要设置时托盘不构建正常规格(全新机器上 `build_service_specs()` 会因为缺 TLS 材料抛+ `FileNotFoundError`),改起一条 `peach serve --setup --host 127.0.0.1 --port <设置里的端口,+ 默认 8900> --no-mdns --no-ledger-sync`,然后把浏览器打开到 `http://127.0.0.1:<端口>/`。+ 这条服务没有 TLS、口令强制置空(安全边界就是那个绑定地址),首页是首次运行表单,提交端点+ 是 `POST /setup`:应用已配置回 404、非回环调用方回 403、设置文件已存在回 409。+- 切换由 `tray.SetupGate` 做,Windows 托盘与 macOS 菜单栏共用。它挂在健康轮询里(Windows 10 秒、+ macOS 5 秒),每轮新鲜 `settings_file.load_config()`:不再需要设置且 TLS 材料齐了,就停掉引导+ 服务、按新数据根构建正常规格(`build_service_specs(tls_dir=...)`)并启动,托盘进程本身不重启。+ TLS 还没齐(例如这台机器没有 openssl)就原地等下一轮,不会拿一组缺文件的规格去启动。+- 首扫不跑在引导服务里——那个进程在切换的那一刻就被停掉了。表单勾了「现在扫描」只写一个+ 一次性标记 `<数据根>/state/first-scan.request`(内容是来源 ID),托盘切换完成后读走并删除它,+ 用子进程跑 `peach scan <来源>`,输出落在 `<数据根>/logs/tray-scan.out.log`。标记只消费一次。- 给了任何参数、加了 `--no-input`、或 stdin 不是终端,`peach init` 走非交互路径:按内建默认与 `--data-root`/`--host`/`--port`/`--mdns-name`/`--mount local=/mnt/media` 直接生成,写出的文件带 `local`/`115`/`pikpak` 三个示例声明根。已有账本不会被重建,它会提示改用diff --git a/docs/adr/0023-generic-distribution-roadmap.md b/docs/adr/0023-generic-distribution-roadmap.mdindex 5ab1805f9..85f7651ce 100644--- a/docs/adr/0023-generic-distribution-roadmap.md+++ b/docs/adr/0023-generic-distribution-roadmap.md@@ -130,6 +130,7 @@ Peach 要发布到 GitHub 供所有人维护与使用。使用形态不变:每- 分支规则集 `protect-master`(id 22263433):默认分支禁删除、禁强推。Secret scanning、Push protection、Private vulnerability reporting、Dependabot alerts 已开启;Dependabot security updates 未开,自动开 PR 由用户决定。- 公开后的补漏(同日):`MachineCoordinateTests` 改成只写形状不点名的门槛(家目录路径、私网 IP、`.local` 主机名、本机账号与主机名运行时派生);发行名定为 `peach`,目录名 `peach-app` 不变;macOS bundle ID 改中性 ID 由用户定为待办第 28 条。- 开箱引导的顺序由用户定:先 CLI 问答(`peach init` 无参数进入问答并可首扫,逻辑在 `peach.onboarding`,已在 master),再 GUI 引导(托盘首启打开首次运行页升级成的表单,调同一组函数,待办第 29 条)。+- GUI 引导已落地:未配置的机器上 `peach-tray` 起一条只绑回环的 `peach serve --setup` 引导服务并打开浏览器,首次运行页是表单,`POST /setup` 调与 CLI 同一个 `onboarding.apply()`;`tray.SetupGate` 在健康轮询里新鲜读设置文件,完成后不重启托盘进程就切到正常服务,并消费 `<数据根>/state/first-scan.request` 用子进程跑首扫。需要设置的判据是「没有 config.toml 且没有账本」,端口与失败形态见 `docs/OPERATIONS.md`「首次运行与设置文件」。- 剩余工作只在 `docs/PRODUCT_BACKLOG.md`:独立发行版、口味导入引导、README 瘦身到 `CONTRIBUTING.md` 与 `docs/`、第 28 与 29 条。### 外部评审的取舍(2026-09-05)