Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 管理页正文对齐标题,「这台电脑」等回话再列出

longmeidaob97fb05a475d
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index b5525edc6..b911d48c0 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -4420,13 +4420,13 @@ class WebUiSourceTests(unittest.TestCase):
管理菜单因此不再列它,判断也就不必再摊到菜单上。`/configuration` 这条 URL 留着:
媒体库选单和首次配置引导都指向它,身份注册表也保留这一项。
- 别的设备打开设置照样看得见这一格,里面换成一句话说清在哪儿改——整格藏起来只会
- 让人以为设置少了一块,还得再找一遍。判据是 `/healthz` 的 `configurable`。
+ 别的设备打开设置照样看得见这一格,里面换成一句话说清在哪儿改——服务端回过话之后
+ 它一定在列里,只是内容不同。判据是 `/healthz` 的 `configurable`。
"""
self.assertPageContains("['configuration','配置','folder-cog'],")
self.assertPageContains(
"const manageMenuSections=()=>MANAGE_SECTIONS.filter(([key])=>MANAGE_MENU_SECTIONS.includes(key));")
- self.assertPageContains('<section class="settinggroup"><h3>这台电脑</h3>')
+ self.assertPageContains('<section class="settinggroup" id="machineGroup" hidden><h3>这台电脑</h3>')
self.assertPageContains('<div id="machineSettings" class="machinesettings"></div>')
# 每次打开都重新问一遍:这一格的答案随「从哪台设备打开」变,缓存下来就会骗人。
self.assertPageContains("syncSettingsPanel();void syncMachineSettings();")
@@ -4448,6 +4448,31 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageLacks('href="/configuration"')
self.assertPageLacks("媒体文件夹与服务配置")
+ def test_this_computer_joins_the_rail_once_and_never_as_a_placeholder(self):
+ """「这台电脑」在服务端回话之前不占位,回话之后一次性列出它最终的样子。
+
+ 它是「四个分区」还是「一句话」由服务端决定。先摆一条占位再改写的话,左栏那一列
+ 会先长出一条「这台电脑」、随后变成四条,弹层跟着跳一次高度——用户看到的是一次
+ 无缘无故的重排,而那一刻并没有任何新东西可读。
+
+ 两处配合:这一格开局就是 `hidden`,左栏只收不带 `hidden` 的那几格。少一边都不行——
+ 只藏内容而左栏照收,那一条就成了点不开的空壳。
+ """
+ self.assertPageContains('<section class="settinggroup" id="machineGroup" hidden>')
+ self.assertPageContains(
+ "const host=$('#machineSettings'),group=$('#machineGroup');")
+ self.assertPageContains(
+ "const list=()=>{if(group)group.hidden=false;refreshSettingsTabs?.()};")
+ self.assertPageContains(
+ "const groups=[...settings.querySelectorAll(':scope > .settinggroup:not([hidden])')];")
+ # 两条分支各自列出来:读不到服务端时那一句话也得有人能看见。
+ self.assertPageContains("{label:'该配置需在服务端设备修改'}")
+ self.assertPageContains(" list();\n return;\n }")
+ # 挂到一半被关掉的那次不算数,否则留下的是一条点开什么都没有的「这台电脑」。
+ self.assertPageContains("if(!open()){machineSettingsMounted=false;return}")
+ # 等待期间不铺占位文案:整格不在列里,没有地方放它。
+ self.assertPageLacks("正在读取这台电脑的配置")
+
def test_the_settings_rail_is_split_into_captioned_sections(self):
"""左栏按分区分块:一个小标题带一组条目,「设置」在上、「这台电脑」在下。
@@ -4861,6 +4886,25 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains("function enterManagementSurface()")
self.assertPageContains("loadRequestSeq++;listLoading=false;$('#combo').innerHTML=''")
+ def test_the_media_source_select_stands_on_the_same_line_as_its_neighbours(self):
+ """「媒体来源」那一格和同一网格里的输入框同高、同起点、同间距。
+
+ `.gselect` 在配置页只是个定位外壳,尺寸归里面的 `.gselectfield`。设置开关行那份
+ `.gselect` 尺寸在那边成立——外壳就是控件本身——套到配置页就错三样:外壳 32px 而
+ 按钮 `--control-h` 是 36px,按钮往下探出 10px 把它和下面那条分隔线的间距吃掉;
+ 6px/8px 的内边距把按钮左边缘推右 8px,跟上面那个输入框对不上一条竖线;那 6px 还
+ 叠在 `.configsourcelabel` 自己的 8px 上,标题到控件比隔壁远一截。
+ """
+ board = (Path(__file__).resolve().parents[1] / "web/board.css").read_text(encoding="utf-8")
+ self.assertIn(".settingscard .settingsscroll .machinesettings .gselect"
+ "{min-width:0;min-height:0;height:auto;padding:0}", board)
+ # 压平那一条必须排在给开关行写的那条后面,同权重比它高一级才压得住。
+ self.assertGreater(board.index(".settingscard .settingsscroll .machinesettings .gselect"),
+ board.index(".settingscard .settingsscroll .gselect{min-width:90px;"))
+ # 高度的唯一出处仍是 --control-h,两个控件不各写一个像素数。
+ self.assertIn(".configsource input.geist-input,.configsource .gselectfield"
+ "{height:var(--control-h);min-height:var(--control-h);box-sizing:border-box}", board)
+
def test_sidebar_add_row_wears_the_shared_input_and_primary_button(self):
"""这一行有三条判据:颜色只走 token、高度只引用 --control-h、主次动作分得开。
@@ -5485,6 +5529,20 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains(
".cleanup-layout .geist-breadcrumb,.cleanup-layout .managetitle,.cleanup-layout .pagelede")
+ def test_every_management_page_body_shares_the_title_column(self):
+ """管理区每一页的正文和它的标题一条中线,宽度都由 `--board-content` 说了算。
+
+ Board 层把 `#manageTitle` 钉在 1120 上,正文各自声明的 812 窄列比它每边窄 154px:
+ 在宽屏上就是标题顶着左边、正文整块往右缩一截。四页写在同一条规则里,往管理区新加
+ 一页时照抄这一行,不要在页面自己的 CSS 里另定一个数。
+ """
+ board = (Path(__file__).resolve().parents[1] / "web/board.css").read_text(encoding="utf-8")
+ self.assertIn(".cleanuppage,.configpage,.scraping-page,.activitypage"
+ "{width:100%;max-width:var(--board-content)}", board)
+ self.assertIn("body :is(#manageTitle,#manageCrumb,#manageLede)"
+ "{max-width:var(--board-content);width:100%;margin-left:auto;margin-right:auto}", board)
+ self.assertIn(":root{--railW:88px;--board-content:1120px}", board)
+
def test_returning_home_from_any_surface_moves_the_highlight(self):
"""Logo、侧栏和沉浸关闭都必须清掉隐藏筛选,不能让 `/` 继续请求 JAV。"""
self.assertPageContains("function resetHomeState(){")
diff --git a/web/app.js b/web/app.js
index fbb44706b..bd56db40d 100644
--- a/web/app.js
+++ b/web/app.js
@@ -771,28 +771,35 @@ const actionFailure=(message,error)=>toast(
/* 设置弹层最后一格装的是配置页:媒体文件夹、端口、代理、更新,讲的都是跑着 Peach
的那台电脑,不是这个浏览器。别的设备打开设置照样看得见这一格,里面换成一句话说清
在哪儿改——判据是 `/healthz` 的 `configurable`(服务由托盘管、已完成配置、请求来自
- 本机三条同时成立)。整格藏起来只会让人以为设置少了一块,还得再找一遍。
+ 本机三条同时成立)。
+ 这一格到底是「四个分区」还是「一句话」,得等服务端回话才知道,所以它一开始就 hidden
+ (见 index.html),知道了再一次性列出来。先摆一条占位再改写的话,左栏那一列会先长出
+ 一条「这台电脑」、随后又变成四条,整个弹层跟着跳一次高度。
写在这儿是因为它要用上面那两个模块级绑定;`openSettings` 靠函数声明提升调到它。 */
let machineSettingsMounted=false;
-/* 左栏由 Board 外壳那段(`buildSettingsTabs`)画,它在自己的闭包里。配置页挂上来之后
- 那一列要从一条「这台电脑」变成四条,得让它重画一遍,所以留这个口子。 */
+/* 左栏由 Board 外壳那段(`buildSettingsTabs`)画,它在自己的闭包里。这一格列出来之后
+ 左栏要多一块,得让它重画一遍,所以留这个口子。 */
let refreshSettingsTabs=null;
async function syncMachineSettings(){
- const host=$('#machineSettings');
+ const host=$('#machineSettings'),group=$('#machineGroup');
if(!host||machineSettingsMounted)return;
const open=()=>!$('#settingsPanel').hidden;
- if(!host.childElementCount)host.innerHTML=loadingDotsHtml('正在读取这台电脑的配置');
+ const list=()=>{if(group)group.hidden=false;refreshSettingsTabs?.()};
const runtime=await api('/healthz').catch(()=>null);
if(!open())return;
if(runtime)runtimeConfigurable=!!runtime.configurable;
if(!runtime||!runtimeConfigurable){
host.innerHTML=noteHtml('媒体文件夹、端口、代理与更新属于运行 Peach 服务的设备;在该设备的浏览器打开设置进行修改。',
{label:'该配置需在服务端设备修改'});
+ list();
return;
}
machineSettingsMounted=true;
await mountIsland('configuration',host,{receipt:message=>actionReceipt(message)},{isCurrent:open});
- refreshSettingsTabs?.();
+ /* 挂到一半用户把弹层关了:island 认出自己过期,不会画,这一格里一样东西都没有。
+ 退回未挂状态让下次重来,别留一条点开是空白的「这台电脑」。 */
+ if(!open()){machineSettingsMounted=false;return}
+ list();
}
/* 随机排序每次进入首页都换种子;同一次访问继续复用该种子,保证筛选和分页
@@ -10048,16 +10055,18 @@ function buildSettingsTabs(){
node.classList.remove('board-group-active');node.removeAttribute('role');node.removeAttribute('aria-labelledby')});
}
const keep=settingsTabs?settingsTabs.index:0;
- const groups=[...settings.querySelectorAll(':scope > .settinggroup')];
+ /* `[hidden]` 的那一格不进这一列。「这台电脑」在服务端回话之前就是这个状态:算进来会
+ 先画出一条,等回话再改画成四条,等于让左栏跳两次。 */
+ const groups=[...settings.querySelectorAll(':scope > .settinggroup:not([hidden])')];
const machine=groups.find(node=>node.querySelector(':scope > .machinesettings'));
const item=node=>{const title=node.querySelector('h3').textContent.trim();return{title,icon:SETTINGS_TAB_ICONS[title],nodes:[node]}};
const sections=[{caption:'设置',items:groups.filter(node=>node!==machine).map(item)}];
if(machine){
const page=machine.querySelector('.configpage');
const parts=page?configTabItems(page).map(part=>({...part,icon:SETTINGS_TAB_ICONS[part.title]})):null;
- /* 配置页挂上来了才单独起一块,小标题是「这台电脑」。挂不上来(别的设备、或还在读)
- 时里面只有一句话,那就仍旧排在上面那一列的末尾——小标题和它下面唯一那一条同名,
- 等于把一句话说两遍。 */
+ /* 配置页挂上来了才单独起一块,小标题是「这台电脑」。挂不上来(别的设备)时里面只有
+ 一句话,那就仍旧排在上面那一列的末尾——小标题和它下面唯一那一条同名,等于把一句话
+ 说两遍。 */
if(parts?.length)sections.push({caption:machine.querySelector('h3').textContent.trim(),items:parts});
else sections[0].items.push({...item(machine),nodes:[machine.querySelector('.machinesettings')]});
}
diff --git a/web/board.css b/web/board.css
index 50a5a5204..b9fb21f4c 100644
--- a/web/board.css
+++ b/web/board.css
@@ -407,7 +407,10 @@ body :is(#manageTitle,#manageCrumb,#manageLede){max-width:var(--board-content);w
#manageTitle{font-size:26px;line-height:34px;margin-bottom:24px}
/* Task entry cards and editing panels have different information density. */
-.cleanuppage,.configpage{width:100%;max-width:var(--board-content)}
+/* 管理区每一页的正文跟标题走同一条中线。标题由上面那条 `#manageTitle` 钉在 1120 上,
+ 正文也得钉到同一个数:`.scraping-page` 和 `.activitypage` 自己声明的 812 窄列比标题
+ 每边窄 154px,读起来就是正文整块往右缩了一截。 */
+.cleanuppage,.configpage,.scraping-page,.activitypage{width:100%;max-width:var(--board-content)}
.cleanupgrid{gap:16px}
.cleanupfieldset{border:1px solid var(--line);border-radius:16px;box-shadow:0 1px 2px #00000003}
.cleanupfieldset>.geist-fieldset-content{padding:20px 20px 16px;min-height:120px}
@@ -1081,7 +1084,12 @@ body .reviewactions button.warning,body [data-follow-bulk],body [data-follow-sta
.reviewtabs{overflow-x:auto!important;overflow-y:hidden;scrollbar-width:none!important;touch-action:pan-x pan-y;overscroll-behavior-x:contain}.reviewtabs::-webkit-scrollbar{display:none!important}.reviewtabs .os-scrollbar{display:none!important}
.settingsscroll .settingrow{margin-right:16px}.settingsscroll .settinggroup{border-bottom:0}
.iconswitch.themeswitch[data-board-segments]{padding:4px;border:0;border-radius:24px;background:var(--picked);gap:4px}.iconswitch.themeswitch[data-board-segments]>label{width:32px;height:32px;border-radius:50%}.themeswitch .board-segment-thumb{border-radius:50%;background:var(--ground)}
-.configsource{align-items:start}.configsource input.geist-input,.configsource .gselectfield{height:var(--control-h);min-height:var(--control-h);box-sizing:border-box}.configpage .configcheck{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 20px 12px 16px;border:1px solid var(--color-border-button-default);border-radius:10px;background:var(--color-background-primary-default);cursor:pointer}.configpage .configcheck>.pcheck{order:2}.configpage .configcheck:hover{background:var(--color-background-primary-hover)}
+.configsource{align-items:start}.configsource input.geist-input,.configsource .gselectfield{height:var(--control-h);min-height:var(--control-h);box-sizing:border-box}
+/* 配置页的下拉由里面那枚按钮定尺寸,`.gselect` 只是它的定位外壳。上面给设置开关行写的
+ 那份 `.gselect` 尺寸(32px 高、6px/8px 内边距)在这儿不成立:那边外壳就是控件本身,
+ 这边按钮是 `--control-h`(36px),比外壳高 4px 往下探出 10px,左边缘还被内边距推右
+ 8px——同一格里它和上面那个输入框既不同高、也不从同一条竖线起。 */
+.settingscard .settingsscroll .machinesettings .gselect{min-width:0;min-height:0;height:auto;padding:0}.configpage .configcheck{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 20px 12px 16px;border:1px solid var(--color-border-button-default);border-radius:10px;background:var(--color-background-primary-default);cursor:pointer}.configpage .configcheck>.pcheck{order:2}.configpage .configcheck:hover{background:var(--color-background-primary-hover)}
body .reviewactions button.primary:not(:disabled){background:var(--board-blue);color:#fff;border-color:transparent}body .reviewactions button.error:not(:disabled){background:linear-gradient(180deg,#ff3347,#e60012);color:#fff;border-color:transparent}body .reviewactions button.error:hover:not(:disabled){background:linear-gradient(180deg,#ff6471,#ff3347)}
.card .pic>.badge{padding:4px;border-radius:10px;background:var(--glass-fill);box-shadow:inset 0 1px 0 var(--glass-rim),var(--glass-shadow);backdrop-filter:blur(16px) saturate(145%)}.card .pic>.badge .src{background:transparent;padding:0;width:20px;height:20px}
body .selectiondock{border:0;border-radius:22px;background:var(--glass-drift-a),var(--glass-drift-b),linear-gradient(125deg,var(--glass-sheen),transparent 42%,var(--glass-low)),var(--glass-fill);background-size:200% 200%,200% 200%,auto;background-repeat:no-repeat,no-repeat,repeat;background-position:50% 20%,80% 70%,0 0;animation:glassdriftx 41s linear infinite,glassdrifty 67s linear infinite;backdrop-filter:var(--glass-optic,blur(22px)) saturate(145%);box-shadow:inset 0 1px 0 var(--glass-rim),inset 1px 0 0 var(--glass-low),inset -1px 0 0 var(--glass-low),inset 0 -1px 0 var(--glass-low),var(--glass-shadow)}
diff --git a/web/index.html b/web/index.html
index 3e82a25e6..31ad8bd1d 100644
--- a/web/index.html
+++ b/web/index.html
@@ -300,7 +300,8 @@
<div class="settingrow"><span><b>保持登录时间</b><small>在此浏览器下次登录并勾选“保持登录”时生效。</small></span><div id="loginDaysSetting"></div></div>
<label class="settingrow"><span><b>SFW 模式</b><small id="sfwDescription">模糊、降低饱和度并压暗全站图片和视频,包括封面、头像与详情预览;停止悬停预览。文字、品牌标识和来源图标保持可见。</small></span><input class="ptoggle" type="checkbox" id="censorSetting" role="switch" aria-describedby="sfwDescription"></label>
</section>
- <section class="settinggroup"><h3>这台电脑</h3>
+ <!-- 这一格要等服务端说清它在这台机器上是什么形态才列出来,见 syncMachineSettings。 -->
+ <section class="settinggroup" id="machineGroup" hidden><h3>这台电脑</h3>
<div id="machineSettings" class="machinesettings"></div>
</section>
</div>