Skip to content

armgit / peach

Public Imported from GitHub
0

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

feat(setup): 首次运行页按站内规范重排,题面改成通俗名词

longmeidao3be97c347aba
diff --git a/README.en.md b/README.en.md
index ca3fa7689..1a6082bae 100644
--- a/README.en.md
+++ b/README.en.md
@@ -105,11 +105,11 @@ Run without arguments, `peach init` asks five questions in the terminal; pressin
| Question | Default |
| --- | --- |
-| Data root (ledger, caches and the settings file live here) | `peach-data/` next to the repository |
-| Local media directory (source `local`, must already exist) | `~\Videos` (`~/Movies` on macOS); required when that folder is missing |
-| Listen scope: 1 = this machine only (127.0.0.1), 2 = LAN (0.0.0.0) | `1` |
-| Service port | `8900` |
-| LAN name (`<name>.local`, published only when listening on the LAN) | `peach` |
+| 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` |
+| Port | `8900` |
+| LAN address (`<name>.local`, published only when LAN access is allowed) | `peach` |
It then creates the data root, migrates the ledger to the latest schema, generates the local CA, writes
`<data root>/config.toml`, asks "scan <directory> now?" (default yes) to register that directory's files
diff --git a/README.md b/README.md
index 067b42289..14d997976 100644
--- a/README.md
+++ b/README.md
@@ -101,11 +101,11 @@ Windows 调试用户下载 [GitHub Releases](https://github.com/longmeidao/peach
| 问题 | 默认值 |
| --- | --- |
-| 数据根(账本、缓存与设置文件都放这里) | 仓库同级的 `peach-data/` |
-| 本地媒体目录(来源 `local`,必须已存在) | `~\Videos`(macOS 为 `~/Movies`),不存在则必填 |
-| 监听范围:1 = 仅本机(127.0.0.1),2 = 局域网(0.0.0.0) | `1` |
-| 服务端口 | `8900` |
-| 局域网名字(`<名字>.local`,只在监听局域网时发布) | `peach` |
+| 数据目录(账本、缓存和设置文件都放在这里) | 仓库同级的 `peach-data/` |
+| 媒体文件夹(必须已经存在,作为来源 `local`) | `~\Videos`(macOS 为 `~/Movies`),不存在则必填 |
+| 谁可以访问:1 = 只有这台电脑,2 = 同一局域网的设备 | `1` |
+| 端口 | `8900` |
+| 局域网访问地址(`<名字>.local`,只在允许局域网访问时发布) | `peach` |
回答完它建数据根、把账本迁到最新 schema、生成本机 CA、写出 `<数据根>/config.toml`,然后问
「现在扫描 <目录>?」(默认是)把那个目录的文件登记进账本,最后打印下一步。设置文件里只有你
diff --git a/docs/OPERATIONS.md b/docs/OPERATIONS.md
index d9ad5c91f..fa7987845 100644
--- a/docs/OPERATIONS.md
+++ b/docs/OPERATIONS.md
@@ -13,7 +13,7 @@
的 `peach-data/`、都没有就是「未配置」。优先级是环境变量 > 设置文件 > 内建默认。
- 全新机器只跑 `peach init`。不带参数且 stdin 是终端时进问答(题目、默认值与落盘逻辑在
`src/peach/onboarding.py`,托盘设置页复用同一组函数):问数据根、一个已存在的本地媒体
- 目录、监听范围(仅本机/局域网)、端口、局域网名字,每题回车取默认,连续三次无效即退出且
+ 目录、谁可以访问(只有这台电脑/同一局域网的设备)、端口、局域网访问地址,每题回车取默认,连续三次无效即退出且
不写任何文件。然后建齐 `database`/`generated`/`sources`/`state`/`secrets`/`logs`/
`tools`/`review` 八个目录、把账本迁到最新 schema、生成本机 CA 与访问口令、写出设置文件,问一句
「现在扫描 <目录>?」(默认是)调 `peach.scan.scan_location` 登记文件,最后打印下一步与
diff --git a/src/peach/onboarding.py b/src/peach/onboarding.py
index 5e38fbb7d..3affaf3bd 100644
--- a/src/peach/onboarding.py
+++ b/src/peach/onboarding.py
@@ -52,7 +52,7 @@ RELOAD_NAME = "configuration-reload.request"
#: 监听范围的两个选项:(提交值, 说明)。题目文本和设置页的下拉都由它生成,
#: 所以两处永远是同一批选项,改一个不会漏掉另一个。
-HOST_OPTIONS = (("1", "仅本机(127.0.0.1)"), ("2", "局域网(0.0.0.0)"))
+HOST_OPTIONS = (("1", "只有这台电脑"), ("2", "同一局域网的设备"))
#: 首扫题的题面。CLI 在后面接 `(Y/n)`,设置页把它当勾选框的标签。
SCAN_PROMPT = "现在扫描 {target}?"
@@ -119,7 +119,7 @@ def validate_host(raw: str) -> str:
try:
return _HOST_CHOICES[key]
except KeyError:
- raise ValueError("填 1(仅本机)或 2(局域网)") from None
+ raise ValueError("填 1(只有这台电脑)或 2(同一局域网的设备)") from None
def validate_port(raw: str) -> int:
@@ -170,16 +170,16 @@ def questions(
home = Path.home() if home is None else home
media_default = default_media_dir(home, windows=windows)
return (
- Question("data_root", "数据根(账本、缓存与设置文件都放这里)",
+ Question("data_root", "数据目录(账本、缓存和设置文件都放在这里)",
str(config.data_root), validate_data_root),
- Question("media_dir", "本地媒体目录(来源 local,必须已存在)",
+ 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),
+ "谁可以访问:" + ",".join(f"{value} = {label}" for value, label in HOST_OPTIONS),
"1", validate_host),
- Question("port", "服务端口", str(config.server.port), validate_port),
- Question("mdns_name", "局域网名字(<名字>.local,只在监听局域网时发布)",
+ 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_pages.py b/src/peach/routes_pages.py
index c0e92f85a..86bc494c1 100644
--- a/src/peach/routes_pages.py
+++ b/src/peach/routes_pages.py
@@ -39,7 +39,7 @@ from .web_state import FAVICON
router = APIRouter()
-#: 回环地址的三种写法。既用来判提交端点的调用方,也用来判「仅本机」那个监听选择。
+#: 回环地址的三种写法。既用来判提交端点的调用方,也用来判「只有这台电脑」那个监听选择。
_LOOPBACK = frozenset({"127.0.0.1", "::1", "localhost"})
#: 首次运行页的样式。刻意不引用 `web/` 里的任何资产:那一套一上来就会去打
@@ -48,36 +48,79 @@ _LOOPBACK = frozenset({"127.0.0.1", "::1", "localhost"})
_SETUP_STYLE = """<style>
*{box-sizing:border-box}
body{margin:0;padding:48px 24px;background:var(--ground);color:var(--ink);
-font:16px/1.6 system-ui,-apple-system,"Segoe UI","Microsoft YaHei",sans-serif}
-main{max-width:560px;margin:0 auto}h1{font-size:28px;font-weight:600;margin:24px 0 8px}
-h2{font-size:18px;font-weight:600;margin-top:32px;padding-top:24px;border-top:1px solid var(--line)}
+font:var(--fs-md)/1.6 system-ui,-apple-system,"Segoe UI","Microsoft YaHei",sans-serif}
+main{max-width:560px;margin:0 auto}
+.mark{display:block;width:40px;height:40px;border-radius:50%}
+h1{font-size:var(--fs-3xl);font-weight:600;line-height:1.25;margin:16px 0 0}
+.lede{margin:6px 0 0;color:var(--muted)}
+h2{font-size:var(--fs-lg);font-weight:600;margin-top:32px;padding-top:24px;border-top:1px solid var(--line)}
p{color:var(--ink-2)}a{color:var(--tungsten);text-underline-offset:3px}
-code{background:var(--surface);border-radius:var(--badge-radius);padding:2px 6px}
-dt{color:var(--muted);font-size:14px}dd{margin:0 0 12px;overflow-wrap:anywhere}
-label{display:block;margin:24px 0 8px;color:var(--ink)}
-input[type=text],input[type=number],select{width:100%;height:44px;
-padding:0 12px;border:1px solid var(--line);border-radius:var(--control-radius);
-background:var(--ground);color:var(--ink);font:inherit}
+code{font:var(--fs-xs)/1.5 ui-monospace,Consolas,"Cascadia Mono",monospace;
+background:var(--surface);border:1px solid var(--line-soft);border-radius:var(--badge-radius);
+padding:2px 6px;overflow-wrap:anywhere}
+dt{color:var(--muted);font-size:var(--fs-sm)}dd{margin:0 0 12px;overflow-wrap:anywhere}
+form{margin-top:32px}
+.field{margin-top:24px}
+.field>label,.field>.legend{display:block;margin:0 0 8px;font-weight:500;color:var(--ink)}
+.req{color:var(--drop);margin-right:4px}
+input[type=text],input[type=number]{width:100%;height:var(--control-h);padding:0 12px;
+border:1px solid var(--line);border-radius:var(--control-radius);background:var(--ground);
+color:var(--ink);font:inherit}
+.affix{display:flex;align-items:center;height:var(--control-h);border:1px solid var(--line);
+border-radius:var(--control-radius);background:var(--ground)}
+.affix input[type=text]{flex:1 1 auto;min-width:0;height:100%;border:0;border-radius:0;background:transparent}
+.affix input[type=text]:focus-visible{outline:0}
+.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)}
+.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;
+border-radius:var(--control-radius);color:var(--ink-2);cursor:pointer}
+.switch input{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}
+.switch label:hover{color:var(--ink)}
+.switch label:has(input:checked){background:var(--hover);color:var(--ink)}
+.switch label:has(input:focus-visible){outline:2px solid var(--tungsten);outline-offset:2px}
:focus-visible{outline:2px solid var(--tungsten);outline-offset:3px}
-.note{margin:8px 0 0;color:var(--ink-2);font-size:14px}
+.help{margin:6px 0 0;color:var(--muted);font-size:var(--fs-sm)}
details{margin-top:24px}summary{cursor:pointer;min-height:44px;display:list-item}
-.bad{margin:8px 0 0;color:var(--drop);font-size:14px}
-.check{display:flex;align-items:center;gap:12px;min-height:44px;margin:24px 0 0}
-.check input{width:18px;height:18px;margin:0}
-button{margin-top:24px;width:100%;min-height:44px;border:1px solid var(--ink);
+.bad{margin:6px 0 0;color:var(--drop);font-size:var(--fs-sm)}
+.check{display:flex;align-items:center;gap:12px;min-height:44px;margin:24px 0 0;cursor:pointer}
+.pcheck{position:relative;display:grid;place-items:center;width:20px;height:20px;flex:none}
+.pcheck input{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}
+.pcheck>span{width:18px;height:18px;border:1px solid var(--border-15);border-radius:var(--badge-radius);
+display:grid;place-items:center;background:var(--ground);color:transparent}
+.pcheck>span svg{display:block;width:13px;height:13px;stroke:currentColor;fill:none;stroke-width:2.5}
+.check:hover .pcheck>span{background:var(--hover)}
+.pcheck input:checked+span{border-color:var(--ink-2);color:var(--ink)}
+.pcheck input:focus-visible+span{outline:2px solid var(--tungsten);outline-offset:2px}
+button{margin-top:32px;width:100%;height:var(--control-h);border:1px solid var(--ink);
border-radius:var(--control-radius);cursor:pointer;background:var(--ink);color:var(--ground);
-font:500 16px system-ui,sans-serif}
+font:500 var(--fs-md) system-ui,sans-serif}
button:hover{background:color-mix(in srgb,var(--ink) 88%,var(--ground));color:var(--ground)}
-@media(max-width:440px){body{padding:24px 20px}h1{font-size:24px}}
+@media(max-width:760px){input[type=text],input[type=number]{font-size:16px}}
+@media(max-width:440px){body{padding:24px 20px}h1{font-size:var(--fs-2xl)}}
</style>"""
_SETUP_HEAD = ('<!doctype html>\n<html lang="zh-CN"><head><meta charset="utf-8">'
'<meta name="viewport" content="width=device-width,initial-scale=1">'
- '<meta name="color-scheme" content="light">')
+ '<meta name="color-scheme" content="light">'
+ '<link rel="icon" href="/peach-logo.png" type="image/png">')
-#: 键 -> 输入控件类型。题目、默认值与顺序全部来自 `onboarding.questions()`,
-#: 这里只决定同一道题在浏览器里长什么样,不另抄一份字段清单。
-_SETUP_WIDGETS = {"host": "select", "port": "number"}
+#: 键 -> 页面上的题目与一句说明。顺序、默认值与校验仍然来自 `onboarding.questions()`,
+#: 这里只决定同一道题在浏览器里怎么称呼:命令行那份题面要把可选值写进去,页面用控件表达。
+_SETUP_COPY = {
+ "data_root": ("数据目录", "账本、缓存和设置文件都放在这里。"),
+ "media_dir": ("媒体文件夹", "Peach 从这个文件夹读取视频和图片,文件夹必须已经存在。"),
+ "host": ("谁可以访问", ""),
+ "port": ("端口", "浏览器地址里冒号后面的数字,一般不用改。"),
+ "mdns_name": ("局域网访问地址", "其他设备在浏览器里输入这个地址就能打开 Peach,只在允许局域网访问时生效。"),
+}
+_STANDALONE_COPY = {"port": ("本机访问端口", "浏览器地址里冒号后面的数字,一般不用改。")}
+
+#: 与站内共用勾选框相同的字形(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>')
def _document(title: str, body: str) -> str:
@@ -87,36 +130,44 @@ def _document(title: str, body: str) -> str:
f"</head><body><main>{body}</main></body></html>\n")
-def _field_html(
- question, value: str, error: str, note: str,
-) -> str:
+def _copy_for(key: str, fallback: str) -> tuple[str, str]:
+ if distribution.standalone() and key in _STANDALONE_COPY:
+ return _STANDALONE_COPY[key]
+ return _SETUP_COPY.get(key, (fallback, ""))
+
+
+def _field_html(question, value: str, error: str, note: str) -> str:
key = escape(question.key, quote=True)
- prompt = question.prompt
- if distribution.standalone():
- prompt = {"media_dir": "媒体文件夹", "port": "本机访问端口"}.get(question.key, prompt)
- label = f'<label for="f-{key}">{escape(prompt)}</label>'
- if _SETUP_WIDGETS.get(question.key) == "select":
+ title, help_text = _copy_for(question.key, question.prompt)
+ star = '<span class="req" aria-hidden="true">*</span>'
+ if question.key == "host":
options = "".join(
- f'<option value="{escape(choice, quote=True)}"'
- f'{" selected" if choice == value else ""}>{escape(text)}</option>'
+ 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
)
- control = f'<select id="f-{key}" name="{key}">{options}</select>'
+ control = (f'<div class="switch" role="radiogroup" aria-labelledby="l-{key}">'
+ f'{options}</div>')
+ label = f'<span class="legend" id="l-{key}">{escape(title)}</span>'
else:
- kind = _SETUP_WIDGETS.get(question.key, "text")
+ kind = "number" if question.key == "port" else "text"
control = (f'<input id="f-{key}" name="{key}" type="{kind}" required autocomplete="off" '
- f'aria-invalid="{"true" if error else "false"}" '
+ f'spellcheck="false" aria-invalid="{"true" if error else "false"}" '
f'value="{escape(value, quote=True)}">')
- tail = f'<p class="note">{escape(note)}</p>' if note else ""
+ if question.key == "mdns_name":
+ control = f'<div class="affix">{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)
tail += f'<p class="bad" role="alert">{escape(error)}</p>' if error else ""
- return label + control + tail
+ return f'<div class="field">{label}{control}{tail}</div>'
def setup_page(
config, *, windows: bool, values: dict[str, str] | None = None,
errors: dict[str, str] | None = None, scan_now: bool = True,
) -> str:
- """首次运行表单。题目、默认值与顺序全部来自 `onboarding.questions()`。
+ """首次运行表单。题目顺序、默认值与校验全部来自 `onboarding.questions()`。
校验失败时带着 `values` 和 `errors` 重新渲染:已经填对的几项不能让人再填一遍,
错在哪一项也要写在那一项底下,而不是页首一句「有字段不合法」。
@@ -143,19 +194,22 @@ def setup_page(
field = f'<details{opened}><summary>高级设置</summary>{field}</details>'
fields.append(field)
media_value = values.get("media_dir") or next(
- (q.default for q in asked if q.key == "media_dir"), "") or "这个目录"
- scan_label = onboarding.SCAN_PROMPT.format(target=media_value)
- if distribution.standalone():
- scan_label = "完成设置后扫描媒体文件夹"
+ (q.default for q in asked if q.key == "media_dir"), "")
+ if distribution.standalone() or not media_value:
+ scan_text = "完成设置后扫描媒体文件夹"
+ else:
+ scan_text = f"完成设置后扫描 <code>{escape(media_value)}</code>"
body = (
+ '<header><img class="mark" src="/peach-logo.png" alt="" width="40" height="40">'
"<h1>欢迎使用 Peach</h1>"
- "<p>选择一个媒体文件夹,开始整理你的馆藏。</p>"
+ '<p class="lede">选一个媒体文件夹,开始整理你的馆藏。</p></header>'
'<form method="post" action="/setup">'
+ "".join(fields)
- + f'<label class="check"><input type="checkbox" name="scan_now" value="y"'
+ + '<label class="check"><span class="pcheck">'
+ '<input type="checkbox" name="scan_now" value="y"'
+ (" checked" if scan_now else "")
- + f'>{escape(scan_label)}</label>'
- '<p class="note">扫描只读取文件名、大小和修改时间,不改动任何媒体文件。</p>'
+ + f'><span aria-hidden="true">{_CHECK_SVG}</span></span><span>{scan_text}</span></label>'
+ '<p class="help">扫描只读取文件名、大小和修改时间,不改动任何媒体文件。</p>'
'<button type="submit">完成设置</button></form>'
)
return _document("Peach · 首次运行", body)
@@ -203,7 +257,7 @@ def setup_done_page(applied, *, windows: bool, scan_requested: bool) -> str:
def _normal_url(config) -> str:
- """设置完成之后正常服务的地址。仅本机就给回环,局域网给 `<名字>.local`。"""
+ """设置完成之后正常服务的地址。只有这台电脑就给回环,局域网给 `<名字>.local`。"""
if config.server.host in _LOOPBACK:
return f"http://127.0.0.1:{config.server.port}/"
return f"https://{config.server.mdns_name}.local/"
diff --git a/src/peach/tray.py b/src/peach/tray.py
index 8fbace9f1..54f173fe2 100644
--- a/src/peach/tray.py
+++ b/src/peach/tray.py
@@ -660,7 +660,7 @@ def configured_service_specs(config) -> tuple[ServiceSpec, ...]:
return build_service_specs(tls_dir=config.directory("secrets") / "tls",
mdns_hostname=normal_hostname(config))
if config.server.host != "127.0.0.1":
- raise ValueError("独立测试包仅支持本机访问,请在配置中选择仅本机")
+ raise ValueError("独立测试包只支持本机访问,请在配置中选择「只有这台电脑」")
return (ServiceSpec("http", setup_url(config) + "healthz",
(str(_peach_executable()), "serve", "--host", "127.0.0.1",
"--port", str(config.server.port), "--no-mdns", "--no-ledger-sync"),
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 0954b041a..5649b367e 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -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("本地媒体目录(来源 local,必须已存在)"), 2)
+ self.assertEqual(prompts.count("媒体文件夹(必须已经存在)"), 2)
self.assertIn("目录不存在", output)
self.assertFalse(missing.exists(), "问答不替人建媒体目录")
diff --git a/tests/test_onboarding.py b/tests/test_onboarding.py
index 9df4629b5..e8e994ea3 100644
--- a/tests/test_onboarding.py
+++ b/tests/test_onboarding.py
@@ -188,11 +188,11 @@ 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], [
- "数据根(账本、缓存与设置文件都放这里)",
- "本地媒体目录(来源 local,必须已存在)",
- "监听范围:1 = 仅本机(127.0.0.1),2 = 局域网(0.0.0.0)",
- "服务端口",
- "局域网名字(<名字>.local,只在监听局域网时发布)",
+ "数据目录(账本、缓存和设置文件都放在这里)",
+ "媒体文件夹(必须已经存在)",
+ "谁可以访问:1 = 只有这台电脑,2 = 同一局域网的设备",
+ "端口",
+ "局域网访问地址(<名字>.local,只在允许局域网访问时发布)",
])
def test_console_ask_shows_the_default_and_treats_eof_as_abort(self):
@@ -367,14 +367,27 @@ class SetupPageTests(_Case):
self.assertIn('<form method="post" action="/setup">', body)
for question in onboarding.questions(self.config, windows=NATIVE_WINDOWS):
self.assertIn(f'name="{question.key}"', body)
- # `<名字>.local` 那一题的题面带尖括号,页面里是转义过的。
- self.assertIn(escape(question.prompt), body)
- self.assertIn('name="scan_now"', body)
- self.assertIn("checked", body)
- # 监听范围是下拉,两个选项由 `HOST_OPTIONS` 给出,不在页面里另写一遍。
+ # 页面用自己的题面:短名词加一句说明,不把命令行那份带可选值的题面搬上来。
+ for title in ("数据目录", "媒体文件夹", "谁可以访问", "端口", "局域网访问地址"):
+ self.assertIn(f">{title}</", 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` 给出。
+ self.assertNotIn("<select", body)
+ self.assertIn('class="switch" role="radiogroup"', body)
for value, label in onboarding.HOST_OPTIONS:
- self.assertIn(f'value="{value}"', body)
- self.assertIn(label, body)
+ 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("<span>.local</span>", body)
+ # 勾选框用站内共用的自绘结构,路径在等宽框里。
+ self.assertIn('<span class="pcheck"><input type="checkbox" name="scan_now" value="y" checked>', body)
+ self.assertIn("完成设置后扫描 <code>", body)
@unittest.skipIf(NATIVE_WINDOWS, "盘符本身就是挂载点,Windows 上没有这句话")
def test_the_mounts_explanation_sits_under_the_media_field_on_posix(self):