Peach: Local-first video metadata scraper and media manager.
feat: 首次运行页默认局域网访问,并与配置页共用勾选框和运行信息
longmeidao01513a820b48
diff --git a/README.en.md b/README.en.mdindex 1a6082bae..fdc93270e 100644--- a/README.en.md+++ b/README.en.md@@ -105,9 +105,9 @@ Run without arguments, `peach init` asks five questions in the terminal; pressin| Question | Default || --- | --- |-| Data directory (ledger, caches and the settings file live here) | `peach-data/` next to the repository |-| Media folder (must already exist; used as source `local`) | `~\Videos` (`~/Movies` on macOS); required when that folder is missing |-| Who can access: 1 = only this computer, 2 = devices on the same LAN | `1` |+| Data directory (the Peach database, caches and the settings file live here) | `peach-data/` next to the repository |+| Media folder (must already exist, may live on an external drive; used as source `local`) | `~\Videos` (`~/Movies` on macOS); required when that folder is missing |+| Who can access: 1 = only this computer, 2 = devices on the same LAN | `2` || Port | `8900` || LAN address (`<name>.local`, published only when LAN access is allowed) | `peach` |diff --git a/README.md b/README.mdindex 14d997976..887e8b452 100644--- a/README.md+++ b/README.md@@ -101,9 +101,9 @@ Windows 调试用户下载 [GitHub Releases](https://github.com/longmeidao/peach| 问题 | 默认值 || --- | --- |-| 数据目录(账本、缓存和设置文件都放在这里) | 仓库同级的 `peach-data/` |-| 媒体文件夹(必须已经存在,作为来源 `local`) | `~\Videos`(macOS 为 `~/Movies`),不存在则必填 |-| 谁可以访问:1 = 只有这台电脑,2 = 同一局域网的设备 | `1` |+| 数据目录(Peach 数据库、缓存和设置文件都放在这里) | 仓库同级的 `peach-data/` |+| 媒体文件夹(必须已经存在,可以在外置硬盘上;作为来源 `local`) | `~\Videos`(macOS 为 `~/Movies`),不存在则必填 |+| 谁可以访问:1 = 只有这台电脑,2 = 同一局域网的设备 | `2` || 端口 | `8900` || 局域网访问地址(`<名字>.local`,只在允许局域网访问时发布) | `peach` |diff --git a/docs/PRODUCT_BACKLOG.md b/docs/PRODUCT_BACKLOG.mdindex faad2f044..834401987 100644--- a/docs/PRODUCT_BACKLOG.md+++ b/docs/PRODUCT_BACKLOG.md@@ -22,7 +22,7 @@5. **厂牌 Logo 补齐与持续校验**:14 个已确认社交 handle 已有内容缓存、provenance、精确/感知哈希、质量与重复门槛及健康报告;仍有 72 个厂牌没有可信 handle,必须继续从官网/公开来源取证,不能猜账号。6. **口味证据持续刷新**:ledger 已实时记录搜索、播放、高潮、喜欢/理由、不合口味和稍后看;浏览器历史现可用 SQLite 一致性副本增量进入私有源库,并生成不含 URL/标题的 creator/tag candidate 与聚合报告。旧 2026-08-13 原始包已确认不在 Windows 外置盘;仍需在 Mac 开启 iCloud Safari、完成首次导入,并把两端每周刷新装成系统计划任务。AI 结论不得直接改真相字段。-## 尚未实现(25 项)+## 尚未实现(26 项)1. AI Provider 的真实调用、能力协商、Credential Manager 凭据和候选审核 UI。2. 剩余单一创作者风格板复核、无标签内容补标。@@ -49,8 +49,9 @@23. 性能基准:用 SFW 合成数据生成 1k/10k/100k/500k 四档库,nightly 测冷启动到 `/healthz`、目录页与详情页 p95、两字以上搜索 p95、本地 SSD 与网盘挂载的 Range 首字节、空闲 RSS、后台扫描时前台退化倍数、备份期间读请求不失败。门槛用「相对上一次基线下降超过 20%」,不给绝对毫秒数——不同机器不可比。数据集与第 16 条的演示数据集共用。24. CI 的 Windows job 太慢,一次 push 的墙钟由它决定。同一批 2786 个用例在 `macos-latest`(arm64)上 57 秒,在 `windows-latest` 上 1475 秒,本机 Windows 是 324 秒——runner 比开发机还慢 4.6 倍。按时间戳差算,250 个用例(9%)吃掉 1119 秒,每个稳定在 4.5 秒上下,形状像每建一个临时文件被 Defender 扫一遍。两条路各自独立:一是在 Windows job 里对 runner 的临时目录加 `Add-MpPreference -ExclusionPath`,先量一轮确认是不是 Defender;二是把 `scripts/test_runner.py` 的域拆成矩阵分片并行跑,代价是每个分片重付一次装依赖的 37 秒。不要为了缩短墙钟把 Windows job 从矩阵里去掉:它是生产平台,也是唯一能拦住 Windows 独有回归的地方。25. 托盘子服务的日志不轮转:`ServiceManager` 以追加模式打开 `logs/tray-<服务>.out.log` 与 `.err.log`,本机一周就长到 28 MB,`tray-scan.out.log` 与 `windows-source-sync.log` 同样只增不减。在起服务前按大小轮转,超过阈值改名保留一代即可;写文件的是子进程的 stdout,不经 `logging`,所以 `RotatingFileHandler` 用不上。+26. 多个媒体文件夹:首次运行页与配置页都只收一个「媒体文件夹」,写进设置文件 `[media.locations]` 的 `local` 项;外置硬盘和第二块盘上的资料只能靠后来手改 `config.toml`。要做的是把表单改成可加减的目录列表(Geist 的做法是列表加一枚「添加」次级按钮,不放在输入框同一行),`onboarding.apply` 与 `peach init` 同步收多值,扫描与 `asset.location` 按声明根逐个落账。上一条来源通用化(第 11 条)先做,否则每个新目录还得起一个硬编码的来源名。-合计:**31 项开放需求**,其中 6 项已有骨架,25 项尚未实现。已完成的需求不在这里留痕,去 Git 历史查。+合计:**32 项开放需求**,其中 6 项已有骨架,26 项尚未实现。已完成的需求不在这里留痕,去 Git 历史查。## 待执行的操作(33 项)diff --git a/src/peach/onboarding.py b/src/peach/onboarding.pyindex 3affaf3bd..251b9f0fd 100644--- a/src/peach/onboarding.py+++ b/src/peach/onboarding.py@@ -170,14 +170,14 @@ def questions(home = Path.home() if home is None else homemedia_default = default_media_dir(home, windows=windows)return (- Question("data_root", "数据目录(账本、缓存和设置文件都放在这里)",+ Question("data_root", "数据目录(Peach 数据库、缓存和设置文件都放在这里)",str(config.data_root), validate_data_root),- Question("media_dir", "媒体文件夹(必须已经存在)",+ Question("media_dir", "媒体文件夹(必须已经存在,可以在外置硬盘上)",str(media_default) if media_default else "",media_dir_validator(windows=windows)),Question("host","谁可以访问:" + ",".join(f"{value} = {label}" for value, label in HOST_OPTIONS),- "1", validate_host),+ "2", validate_host),Question("port", "端口", str(config.server.port), validate_port),Question("mdns_name", "局域网访问地址(<名字>.local,只在允许局域网访问时发布)",config.server.mdns_name, validate_mdns_name),diff --git a/src/peach/routes_configuration.py b/src/peach/routes_configuration.pyindex 7daf62039..5145eff76 100644--- a/src/peach/routes_configuration.py+++ b/src/peach/routes_configuration.py@@ -12,10 +12,9 @@ from urllib.parse import parse_qsfrom fastapi import APIRouter, Depends, HTTPException, Requestfrom fastapi.responses import HTMLResponse-from . import __version__, distribution, onboarding, settings_file+from . import distribution, onboarding, settings_filefrom .routes_auth import require_page_auth-from .routes_pages import _document, _field_html-from .ffmpeg import FFmpegResolver+from .routes_pages import _check_html, _document, _field_html, runtime_facts_htmlrouter = APIRouter()_SAVE_LOCK = threading.Lock()@@ -36,7 +35,7 @@ def page(config, *, values=None, errors=None, saved=False) -> str:f'<p><a href="{url}">进入馆藏</a></p>'f'<meta http-equiv="refresh" content="8;url={url}">')else:- body += '<p>管理这台电脑的媒体文件夹和访问端口。</p>'+ body += '<p class="lede">管理这台电脑的媒体文件夹和访问端口。</p>'if distribution.standalone() and not saved:body += '<form method="post" action="/configuration">'body += f'<input type="hidden" name="revision" value="{revision(config)}">'@@ -46,17 +45,11 @@ def page(config, *, values=None, errors=None, saved=False) -> str:default = media if question.key == "media_dir" else str(config.server.port)body += _field_html(question, values.get(question.key, default),errors.get(question.key, ""), "")- body += ('<label class="check"><input type="checkbox" name="scan_now" value="y">'- '保存后扫描媒体文件夹</label><button type="submit">保存配置</button></form>')+ body += (_check_html("scan_now", "保存后扫描媒体文件夹", checked=False)+ + '<button type="submit">保存配置</button></form>')elif not distribution.standalone():body += '<p>此部署通过配置文件管理服务,请在本机编辑下方文件。</p>'- available = FFmpegResolver(config.directory("tools") / "ffmpeg").ffmpeg() is not None- body += ('<h2>运行信息</h2><dl>'- f'<dt>版本</dt><dd>{escape(__version__)}</dd>'- f'<dt>数据目录</dt><dd>{escape(str(config.data_root))}</dd>'- f'<dt>配置文件</dt><dd>{escape(str(config.path))}</dd>'- f'<dt>日志目录</dt><dd>{escape(str(config.directory("logs")))}</dd>'- f'<dt>FFmpeg</dt><dd>{"可用" if available else "未安装;MP4 可直接播放,转码和缩略图需要安装 FFmpeg。"}</dd></dl>')+ body += runtime_facts_html(config)return _document("Peach · 配置", body)diff --git a/src/peach/routes_pages.py b/src/peach/routes_pages.pyindex 86bc494c1..b72860f4b 100644--- a/src/peach/routes_pages.py+++ b/src/peach/routes_pages.py@@ -73,6 +73,10 @@ border-radius:var(--control-radius);background:var(--ground)}.affix:focus-within{outline:2px solid var(--tungsten);outline-offset:3px}.affix>span{flex:none;padding:0 12px;height:100%;display:grid;place-items:center;color:var(--muted);border-left:1px solid var(--line-soft)}+.affix>span:first-child{border-left:0;border-right:1px solid var(--line-soft)}+.affix:has(input:disabled){background:var(--surface);border-color:var(--border-15)}+.affix input:disabled{color:var(--muted);cursor:not-allowed}+.field:has(input:disabled) .req{visibility:hidden}.switch{display:grid;grid-template-columns:1fr 1fr;padding:3px;border:1px solid var(--line-soft);border-radius:var(--surface-radius);background:var(--surface)}.switch label{position:relative;display:grid;place-items:center;height:calc(var(--control-h) - 8px);padding:0 14px;@@ -110,14 +114,35 @@ _SETUP_HEAD = ('<!doctype html>\n<html lang="zh-CN"><head><meta charset="utf-8">#: 键 -> 页面上的题目与一句说明。顺序、默认值与校验仍然来自 `onboarding.questions()`,#: 这里只决定同一道题在浏览器里怎么称呼:命令行那份题面要把可选值写进去,页面用控件表达。_SETUP_COPY = {- "data_root": ("数据目录", "账本、缓存和设置文件都放在这里。"),- "media_dir": ("媒体文件夹", "Peach 从这个文件夹读取视频和图片,文件夹必须已经存在。"),+ "data_root": ("数据目录", "Peach 数据库、缓存和设置文件都放在这里。"),+ "media_dir": ("媒体文件夹", "Peach 从这个文件夹读取视频和图片,可以是外置硬盘上的文件夹,但必须已经存在。"),"host": ("谁可以访问", ""),"port": ("端口", "浏览器地址里冒号后面的数字,一般不用改。"),- "mdns_name": ("局域网访问地址", "其他设备在浏览器里输入这个地址就能打开 Peach,只在允许局域网访问时生效。"),+ "mdns_name": ("局域网访问地址", "选了「同一局域网的设备」之后,其他设备在浏览器里输入这个地址就能打开 Peach。"),}_STANDALONE_COPY = {"port": ("本机访问端口", "浏览器地址里冒号后面的数字,一般不用改。")}+#: 「谁可以访问」在页面上的顺序:局域网在左边,也是默认选项——Peach 的本意就是给+#: 同一局域网里的设备看。命令行问答按 `HOST_OPTIONS` 的编号顺序念,两边取值一致。+_HOST_ORDER = ("2", "1")++#: 选「只有这台电脑」时局域网地址没有意义,输入框跟着禁用;禁用的字段不随表单提交,+#: 服务端按题目默认值补上。没有脚本时两个字段都可编辑,提交照样成立。+_SETUP_SCRIPT = """<script>+(function(){+ var radios=document.querySelectorAll('input[name="host"]');+ var field=document.getElementById('f-mdns_name');+ if(!radios.length||!field){return;}+ function sync(){+ var lan=false;+ radios.forEach(function(radio){if(radio.checked&&radio.value==="2"){lan=true;}});+ field.disabled=!lan;+ }+ radios.forEach(function(radio){radio.addEventListener('change',sync);});+ sync();+})();+</script>"""+#: 与站内共用勾选框相同的字形(lucide `check`)。这一页不加载站内脚本,所以内联一份。_CHECK_SVG = ('<svg viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round">''<path d="M20 6 9 17l-5-5"/></svg>')@@ -130,6 +155,32 @@ def _document(title: str, body: str) -> str:f"</head><body><main>{body}</main></body></html>\n")+def _check_html(name: str, text_html: str, *, checked: bool) -> str:+ """站内共用的自绘勾选框:文字与框同属一个 label,没有点不到的缝。"""+ return (f'<label class="check"><span class="pcheck"><input type="checkbox" name="{name}" value="y"'+ + (" checked" if checked else "")+ + f'><span aria-hidden="true">{_CHECK_SVG}</span></span><span>{text_html}</span></label>')+++def runtime_facts_html(config) -> str:+ """这台机器上 Peach 的位置与版本:设置完成页和配置页共用同一份。"""+ from . import __version__+ from .ffmpeg import FFmpegResolver++ available = FFmpegResolver(config.directory("tools") / "ffmpeg").ffmpeg() is not None+ ffmpeg = "可用" if available else "未安装;MP4 可直接播放,转码和缩略图需要安装 FFmpeg。"+ rows = (+ ("版本", __version__),+ ("数据目录", str(config.data_root)),+ ("设置文件", str(config.path)),+ ("日志目录", str(config.directory("logs"))),+ ("FFmpeg", ffmpeg),+ )+ return ("<h2>运行信息</h2><dl>"+ + "".join(f"<dt>{escape(term)}</dt><dd>{escape(value)}</dd>" for term, value in rows)+ + "</dl>")++def _copy_for(key: str, fallback: str) -> tuple[str, str]:if distribution.standalone() and key in _STANDALONE_COPY:return _STANDALONE_COPY[key]@@ -141,10 +192,11 @@ def _field_html(question, value: str, error: str, note: str) -> str:title, help_text = _copy_for(question.key, question.prompt)star = '<span class="req" aria-hidden="true">*</span>'if question.key == "host":+ labels = dict(onboarding.HOST_OPTIONS)options = "".join(f'<label><input type="radio" name="{key}" value="{escape(choice, quote=True)}"'- f'{" checked" if choice == value else ""}><span>{escape(text)}</span></label>'- for choice, text in onboarding.HOST_OPTIONS+ f'{" checked" if choice == value else ""}><span>{escape(labels[choice])}</span></label>'+ for choice in _HOST_ORDER)control = (f'<div class="switch" role="radiogroup" aria-labelledby="l-{key}">'f'{options}</div>')@@ -155,7 +207,7 @@ def _field_html(question, value: str, error: str, note: str) -> str:f'spellcheck="false" aria-invalid="{"true" if error else "false"}" 'f'value="{escape(value, quote=True)}">')if question.key == "mdns_name":- control = f'<div class="affix">{control}<span>.local</span></div>'+ control = f'<div class="affix"><span>https://</span>{control}<span>.local</span></div>'label = f'<label for="f-{key}">{star}{escape(title)}</label>'tail = "".join(f'<p class="help">{escape(line)}</p>' for line in (help_text, note) if line)@@ -205,12 +257,10 @@ def setup_page('<p class="lede">选一个媒体文件夹,开始整理你的馆藏。</p></header>''<form method="post" action="/setup">'+ "".join(fields)- + '<label class="check"><span class="pcheck">'- '<input type="checkbox" name="scan_now" value="y"'- + (" checked" if scan_now else "")- + f'><span aria-hidden="true">{_CHECK_SVG}</span></span><span>{scan_text}</span></label>'- '<p class="help">扫描只读取文件名、大小和修改时间,不改动任何媒体文件。</p>'+ + _check_html("scan_now", scan_text, checked=scan_now)+ + '<p class="help">扫描只读取文件名、大小和修改时间,不改动任何媒体文件。</p>''<button type="submit">完成设置</button></form>'+ + _SETUP_SCRIPT)return _document("Peach · 首次运行", body)@@ -223,11 +273,12 @@ def setup_done_page(applied, *, windows: bool, scan_requested: bool) -> str:destination = escape(_normal_url(config), quote=True)scan = "首次扫描已排队。" if scan_requested else "你可以稍后在配置界面开始扫描。"return _document("Peach · 设置完成",- '<h1>设置完成</h1><p>正在启动你的馆藏。' + scan + '</p>'+ '<h1>设置完成</h1><p class="lede">正在启动你的馆藏。' + scan + '</p>'f'<p><a href="{destination}">进入 Peach</a></p>'- f'<meta http-equiv="refresh" content="8;url={destination}">')- ledger = (f"账本已存在,没有动它:{tree.database}" if tree.ledger_existed- else f"账本:{tree.database}(已应用 {tree.migrations} 个迁移)")+ f'<meta http-equiv="refresh" content="8;url={destination}">'+ + runtime_facts_html(config))+ ledger = (f"Peach 数据库已存在,没有动它:{tree.database}" if tree.ledger_existed+ else f"Peach 数据库:{tree.database}(已应用 {tree.migrations} 个迁移)")ca = (f"本机 CA:{tree.ca_cert}" if tree.ca_cert is not Noneelse f"未生成本机 CA({tree.ca_error});装好 openssl 后跑 ""<code>peach init --force</code> 补上。局域网设备要装这份 CA 才不报证书错。")@@ -248,10 +299,7 @@ def setup_done_page(applied, *, windows: bool, scan_requested: bool) -> str:f"{scan}""</ul>"f"{mounts}"- "<dl>"- f"<dt>数据根</dt><dd>{escape(str(config.data_root))}</dd>"- f"<dt>设置文件</dt><dd>{escape(str(applied.settings_path))}</dd>"- "</dl>"+ + runtime_facts_html(config))return _document("Peach · 设置完成", body)diff --git a/tests/test_cli.py b/tests/test_cli.pyindex 5649b367e..2d102c6c9 100644--- a/tests/test_cli.py+++ b/tests/test_cli.py@@ -282,7 +282,7 @@ class InteractiveInitTests(unittest.TestCase):self.assertEqual(loaded.locations, {"local": str(self.media)})self.assertEqual(loaded.mounts, {})self.assertEqual((loaded.server.host, loaded.server.port, loaded.server.mdns_name),- ("127.0.0.1", 8900, "peach"))+ ("0.0.0.0", 8900, "peach"))self.assertFalse(loaded.replication.enabled)for key in settings_file.DIRECTORY_KEYS:self.assertTrue((self.data_root / key).is_dir(), key)@@ -317,7 +317,7 @@ class InteractiveInitTests(unittest.TestCase):code, output, prompts = self._run(["", str(missing), str(self.media), "", "", "", "n"], windows=NATIVE_WINDOWS)self.assertEqual(code, 0)- self.assertEqual(prompts.count("媒体文件夹(必须已经存在)"), 2)+ self.assertEqual(prompts.count("媒体文件夹(必须已经存在,可以在外置硬盘上)"), 2)self.assertIn("目录不存在", output)self.assertFalse(missing.exists(), "问答不替人建媒体目录")diff --git a/tests/test_onboarding.py b/tests/test_onboarding.pyindex e8e994ea3..aefa16f29 100644--- a/tests/test_onboarding.py+++ b/tests/test_onboarding.py@@ -55,7 +55,7 @@ class QuestionTests(_Case):["data_root", "media_dir", "host", "port", "mdns_name"])by_key = {q.key: q for q in asked}self.assertEqual(by_key["data_root"].default, str(self.root / "peach-data"))- self.assertEqual(by_key["host"].default, "1")+ self.assertEqual(by_key["host"].default, "2")self.assertEqual(by_key["port"].default, "8900")self.assertEqual(by_key["mdns_name"].default, "peach")@@ -188,8 +188,8 @@ class InterviewTests(_Case):data_root=self.root / "peach-data", media_dir=self.media, host="0.0.0.0",port=8900, mdns_name="peach-two"))self.assertEqual([prompt for prompt, _ in ask.seen], [- "数据目录(账本、缓存和设置文件都放在这里)",- "媒体文件夹(必须已经存在)",+ "数据目录(Peach 数据库、缓存和设置文件都放在这里)",+ "媒体文件夹(必须已经存在,可以在外置硬盘上)","谁可以访问:1 = 只有这台电脑,2 = 同一局域网的设备","端口","局域网访问地址(<名字>.local,只在允许局域网访问时发布)",@@ -370,20 +370,26 @@ class SetupPageTests(_Case):# 页面用自己的题面:短名词加一句说明,不把命令行那份带可选值的题面搬上来。for title in ("数据目录", "媒体文件夹", "谁可以访问", "端口", "局域网访问地址"):self.assertIn(f">{title}</", body)- self.assertIn("账本、缓存和设置文件都放在这里。", body)+ self.assertIn("Peach 数据库、缓存和设置文件都放在这里。", body)+ self.assertIn("可以是外置硬盘上的文件夹", body)# 品牌标记在标题上方,说明文字在标题下方。self.assertIn('<img class="mark" src="/peach-logo.png"', body)self.assertLess(body.index("<h1>"), body.index('class="lede"'))# 四个要手填的字段前面标红星;「谁可以访问」总有一个选中项,不标。self.assertEqual(body.count('<span class="req"'), 4)- # 「谁可以访问」是两段式单选,不用原生下拉;两个选项由 `HOST_OPTIONS` 给出。+ # 「谁可以访问」是两段式单选,不用原生下拉;两个选项由 `HOST_OPTIONS` 给出,+ # 局域网在左边并且默认选中。self.assertNotIn("<select", body)self.assertIn('class="switch" role="radiogroup"', body)for value, label in onboarding.HOST_OPTIONS:self.assertIn(f'<input type="radio" name="host" value="{value}"', body)self.assertIn(f"<span>{label}</span>", body)- # 局域网访问地址只填名字,`.local` 是框内后缀。- self.assertIn('<div class="affix">', body)+ self.assertIn('<input type="radio" name="host" value="2" checked>', body)+ self.assertLess(body.index('value="2" checked'), body.index('name="host" value="1"'))+ # 选「只有这台电脑」时局域网地址输入框由页内脚本禁用。+ self.assertIn("field.disabled=!lan", body)+ # 局域网访问地址只填名字,框内前缀 `https://`、后缀 `.local` 拼成完整网址。+ self.assertIn('<div class="affix"><span>https://</span><input', body)self.assertIn("<span>.local</span>", body)# 勾选框用站内共用的自绘结构,路径在等宽框里。self.assertIn('<span class="pcheck"><input type="checkbox" name="scan_now" value="y" checked>', body)@@ -404,6 +410,13 @@ class SetupPageTests(_Case):self.assertFalse(missing.exists(), "校验不替人建目录")self.assertFalse(self.data_root.exists(), "校验失败不落任何文件")+ def test_a_disabled_lan_address_falls_back_to_the_default_name(self):+ """选「只有这台电脑」后地址框是禁用的,不随表单提交;服务端按默认值补上。"""+ response = self._post("/setup", self._form(host="1", mdns_name=None))+ self.assertEqual(response.status_code, 200)+ loaded = self._loaded()+ self.assertEqual((loaded.server.host, loaded.server.mdns_name), ("127.0.0.1", "peach"))+def test_a_valid_submission_builds_the_tree_and_shows_what_happens_next(self):response = self._post("/setup", self._form())self.assertEqual(response.status_code, 200)@@ -422,6 +435,12 @@ class SetupPageTests(_Case):body = response.textself.assertIn("设置完成", body)self.assertIn("peach token", body)+ self.assertIn("Peach 数据库:", body)+ self.assertNotIn("账本", body)+ # 完成页尾部是与配置页共用的运行信息:版本、位置和 FFmpeg 一眼可查。+ self.assertIn("<h2>运行信息</h2>", body)+ for term in ("版本", "数据目录", "设置文件", "日志目录", "FFmpeg"):+ self.assertIn(f"<dt>{term}</dt>", body)self.assertIn(str(self.data_root), body)def test_declining_the_scan_leaves_no_marker(self):@@ -474,6 +493,10 @@ class StandaloneConfigurationTests(_Case):page = client.get("/configuration", headers=headers)self.assertEqual(page.status_code, 200)self.assertIn("媒体", page.text)+ # 勾选框与运行信息都复用首启页的实现,不再各写一份。+ self.assertIn('<span class="pcheck"><input type="checkbox" name="scan_now" value="y">', page.text)+ self.assertIn("<h2>运行信息</h2>", page.text)+ self.assertIn("<dt>FFmpeg</dt>", page.text)self.config.directory("state").mkdir(parents=True, exist_ok=True)response = client.post("/configuration", headers=headers, data={"revision": revision(self.config), "media_dir": str(self.media), "port": "9124"})