Peach: Local-first video metadata scraper and media manager.
fix: 整理设置分组并支持关闭悬停放大
longmeidao02dcb7b45486
diff --git a/docs/reference-snapshots/geist-settings.md b/docs/reference-snapshots/geist-settings.mdindex 73ee81700..856058c34 100644--- a/docs/reference-snapshots/geist-settings.md+++ b/docs/reference-snapshots/geist-settings.md@@ -69,3 +69,13 @@ Fieldset 正文 `p-5` 为 20px;副标题 `pt-2` 为 8px,`pb-5` 为 20px;| 来源标题与网址 | 采集来源 | 使用 8px 标题组,不使用负外边距补偿 |Peach 的表单组、卡片和页头使用上述一致性约定;不将它们宣称为 Vercel 对所有管理页面的统一强制值。复核候选、重复文件、高清版、统计和回收站的表格、媒体网格、数值及紧凑元数据保留各自密度;这些与表单帮助文字不是同一场景。此轮没有数据层、API、凭据或生产入口变更。++## 设置面板分组与布尔开关(2026-09-06)++当前官方 HTML:Toggle https://vercel.com/geist/toggle ,SHA-256 `87efc6d9ccc986f5c3e4d3140e8cd9105d274a3a7c04f9bb870da694cbf737f4`;Separator https://vercel.com/geist/separator ,SHA-256 `45ee368f0b857483782ce983dc0f9eebd521b850ea18d220956d5d0dbf8205b0`。通过 HTTPX 严格 TLS 获取。Toggle 表示立即生效的布尔设置;Separator 区分独立内容,官方没有要求所有行都加线。++Peach 按界面、浏览、播放、搜索、关注、安全排列。主题和导航属于界面;JAV 封面和合并分卷属于浏览;悬停放大属于播放。排序与方向共用一行,随机排序禁用方向。独立设置之间加线,同一设置的关联控件之间不加线;卡片之间使用间距。行位置按相邻关系判断,不按 div / label 类型判断。++Toggle 复用已测量的中号 36×20、17px 圆点;按用户截图使用白色圆点,开态保留 Peach 主题蓝,属于明确的色彩差异。合并分卷、详情自动播放、安全模式使用 switch 语义。悬停放大的 0 值表示关闭,保存在浏览器设置,普通预览保持原行为。++影响面:页面及本地设置契约、共享卡片悬停、源测试与计时行为测试适用;数据层和 API 无变更。首页及实体列表复用 wireHover,其他未使用该函数的页面不受影响。没有真实账本写入、生产替换、发布或智能体规则变更。diff --git a/frontend/test/settings-controls.test.ts b/frontend/test/settings-controls.test.tsnew file mode 100644index 000000000..0f6dca9af--- /dev/null+++ b/frontend/test/settings-controls.test.ts@@ -0,0 +1,36 @@+import {readFileSync} from 'node:fs';+import {resolve} from 'node:path';+import {describe, it, expect, vi, afterEach} from 'vitest';++const source = readFileSync(resolve(process.cwd(), '../web/app.js'), 'utf8');+const armSource = source.match(/const armLong=(.*);/)![1];++describe('悬停放大设置', () => {+ afterEach(() => vi.useRealTimers());+ it('关闭时不启动计时,开启后按延迟放大', () => {+ vi.useFakeTimers();+ const card = document.createElement('div');+ const settings = {hoverDelaySeconds: 0};+ const arm = new Function('el', 'appSettings', `let longTimer; return ${armSource}`)(card, settings);+ arm();+ vi.advanceTimersByTime(10000);+ expect(card.className).toBe('');+ settings.hoverDelaySeconds = 3;+ arm();+ expect(card.classList.contains('previewing')).toBe(true);+ vi.advanceTimersByTime(2999);+ expect(card.classList.contains('longhover')).toBe(false);+ vi.advanceTimersByTime(1);+ expect(card.classList.contains('longhover')).toBe(true);+ });+ it('计时中关闭后不进入放大状态', () => {+ vi.useFakeTimers();+ const card = document.createElement('div');+ const settings = {hoverDelaySeconds: 3};+ const arm = new Function('el', 'appSettings', `let longTimer; return ${armSource}`)(card, settings);+ arm();+ settings.hoverDelaySeconds = 0;+ vi.advanceTimersByTime(3000);+ expect(card.classList.contains('longhover')).toBe(false);+ });+});diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex 8fddd0a8d..6c3ff1fb2 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -5726,7 +5726,7 @@ class WebUiSourceTests(unittest.TestCase):"""# 顶栏不出现独立开关,开关在设置面板「安全」组。self.assertPageLacks('id="censorBtn"')- self.assertPageContains('id="censorSetting" aria-describedby="sfwDescription"')+ self.assertPageContains('id="censorSetting" role="switch" aria-describedby="sfwDescription"')self.assertPageContains('<b>SFW 模式</b><small id="sfwDescription">')self.assertPageContains('模糊、降低饱和度并压暗全站图片和视频,包括封面、头像与详情预览;停止悬停预览。文字、品牌标识和来源图标保持可见。')self.assertPageLacks('共享屏幕或截图前开启,遮住全站封面与预览图。')@@ -5894,7 +5894,7 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageLacks("data-sidebar-add-select")self.assertPageContains("const OPTIONAL_SIDEBAR_KEYS=['playlists','immerse','stats','review','data-cleanup','trash','follow-manage','quality']")self.assertPageContains("if(DIRECT_MANAGE_NAV[k]){openManage(DIRECT_MANAGE_NAV[k]);return}")- self.assertPageContains(".settingscard{display:flex;flex-direction:column;width:min(520px,100%);max-height:min(720px,90vh);max-height:min(720px,90dvh);overflow:hidden")+ self.assertPageContains(".settingscard{display:flex;flex-direction:column;width:min(520px,100%);max-height:min(720px,90vh);max-height:min(720px,90dvh);overflow:clip")self.assertPageContains(".settingsscroll{flex:1;min-height:0;overflow-y:auto")self.assertPageContains("document.dispatchEvent(new CustomEvent('peachambientchange'")self.assertPageContains(".settingrow .gselect{min-width:148px}")@@ -6824,6 +6824,14 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains("if(!grid.querySelector('.catalog-skeleton'))return;")self.assertPageContains("if(!returnSurfaceReady)clearIdleCatalogLoading();")+ def test_settings_sort_pair_and_hover_off(self):+ self.assertPageContains('class="settingsortcontrols"')+ self.assertPageContains("field.disabled=appSettings.defaultSort==='seed'")+ self.assertPageContains("['hoverDelaySetting','悬停放大',[['0','关闭']")+ self.assertPageContains('allowedSetting(+appSettings.hoverDelaySeconds,[0,3,5,8],5)')+ self.assertPageContains('if(!appSettings.hoverDelaySeconds)return;')+ self.assertPageContains("if(appSettings.hoverDelaySeconds)el.classList.add('longhover')")+def test_group_collapse_is_a_setting_and_defaults_to_on(self):"""合并分卷与版本可以关掉,关掉后同番号的每一卷/每一版各占一张卡。@@ -6832,7 +6840,7 @@ class WebUiSourceTests(unittest.TestCase):"""self.assertPageContains("groupCollapse:true,sidebarOrder:DEFAULT_SIDEBAR_ORDER};")self.assertPageContains("appSettings.groupCollapse=appSettings.groupCollapse!==false;")- self.assertPageContains('<input type="checkbox" id="groupCollapseSetting">')+ self.assertPageContains('<input type="checkbox" id="groupCollapseSetting" class="ptoggle" role="switch">')self.assertPageContains("$('#groupCollapseSetting').checked=appSettings.groupCollapse;")self.assertPageContains("$('#groupCollapseSetting').onchange=e=>{appSettings.groupCollapse=!!e.target.checked;"diff --git a/web/app.js b/web/app.jsindex 09f590325..747766fba 100644--- a/web/app.js+++ b/web/app.js@@ -417,7 +417,7 @@ if((+appSettings.sortDefaultsVersion||0)<3&&SORT_ALIASES[appSettings.defaultSortappSettings.sortDefaultsVersion=3;appSettings.batchSize=allowedSetting(+appSettings.batchSize,[30,60,90],60);appSettings.defaultSort=allowedSetting(appSettings.defaultSort,SORT_KEYS,'seed');-appSettings.hoverDelaySeconds=allowedSetting(+appSettings.hoverDelaySeconds,[3,5,8],5);+appSettings.hoverDelaySeconds=allowedSetting(+appSettings.hoverDelaySeconds,[0,3,5,8],5);appSettings.seekSeconds=allowedSetting(+appSettings.seekSeconds,[5,10,30],10);appSettings.ambientMode=appSettings.ambientMode!==false;appSettings.theaterMode=appSettings.theaterMode===true;@@ -480,14 +480,15 @@ const SETTING_SELECTS=[['defaultSortSetting','默认排序',[['seed','随机'],['rating','评分'],['o','高潮计数'],['plays','观看次数'],['dur','时长'],['size','体积'],['new','入库时间'],['played','观看时间']],()=>appSettings.defaultSort,- value=>{appSettings.defaultSort=value;saveSettings();state.sort=appSettings.defaultSort;+ value=>{appSettings.defaultSort=value;syncSortDirectionSetting();saveSettings();state.sort=appSettings.defaultSort;state.dir=preferredDirection(state.sort,appSettings.defaultSort,appSettings.defaultSortDirection);if(location.pathname==='/')load(true)}],['defaultSortDirectionSetting','默认排序方向',[['desc','降序'],['asc','升序']],()=>appSettings.defaultSortDirection==='asc'?'asc':'desc',value=>{appSettings.defaultSortDirection=value;saveSettings();state.dir=preferredDirection(state.sort,appSettings.defaultSort,appSettings.defaultSortDirection);if(location.pathname==='/')load(true)}],- ['hoverDelaySetting','悬停放大',[['3','3 秒'],['5','5 秒'],['8','8 秒']],+ ['hoverDelaySetting','悬停放大',[['0','关闭'],['3','3 秒'],['5','5 秒'],['8','8 秒']],()=>appSettings.hoverDelaySeconds,- value=>{appSettings.hoverDelaySeconds=+value||5;+ value=>{appSettings.hoverDelaySeconds=allowedSetting(+value,[0,3,5,8],5);+ if(!appSettings.hoverDelaySeconds)document.querySelectorAll('.previewing,.longhover').forEach(el=>el.classList.remove('previewing','longhover'));document.documentElement.style.setProperty('--hover-delay',`${appSettings.hoverDelaySeconds}s`);saveSettings()}],['seekSecondsSetting','快进 / 快退',[['5','5 秒'],['10','10 秒'],['30','30 秒']],()=>appSettings.seekSeconds,@@ -502,6 +503,12 @@ const SETTING_SELECTS=[['180','每 3 小时'],['360','每 6 小时'],['720','每 12 小时'],['1440','每天']],()=>'0',value=>saveFollowSchedule(+value)],];+function syncSortDirectionSetting(){+ const field=$('#defaultSortDirectionSetting .gselect');+ if(field)field.disabled=appSettings.defaultSort==='seed';+ const help=$('#sortDirectionHelp');+ if(help)help.textContent=appSettings.defaultSort==='seed'?'随机排序不使用方向。':'打开首页时使用的排序与方向。';+}function renderSettingSelects(){for(const [id,label,options,read,apply] of SETTING_SELECTS){const mount=$(`#${id}`);if(!mount)continue;@@ -509,6 +516,7 @@ function renderSettingSelects(){const field=wireSelectField(mount.firstElementChild);field.addEventListener('change',()=>apply(field.value));}+ syncSortDirectionSetting();}function syncSettingsPanel(){$('#groupCollapseSetting').checked=appSettings.groupCollapse;@@ -1739,7 +1747,7 @@ function wireHover(el,it){const pic=el.querySelector('.pic'); if(!pic)return;el.dataset.hoverMode=it.location==='local'?'video':'frames';let longTimer=null;- const armLong=()=>{clearTimeout(longTimer);el.classList.add('previewing');longTimer=setTimeout(()=>el.classList.add('longhover'),Math.max(1,appSettings.hoverDelaySeconds)*1000)};+ const armLong=()=>{clearTimeout(longTimer);if(!appSettings.hoverDelaySeconds)return;el.classList.add('previewing');longTimer=setTimeout(()=>{if(appSettings.hoverDelaySeconds)el.classList.add('longhover')},appSettings.hoverDelaySeconds*1000)};const clearLong=()=>{clearTimeout(longTimer);el.classList.remove('previewing','longhover')};if(it.location!=='local'){ // 远端源:只在接触印相的格子间扫视,零网络流量/* 扫视图是叠在画面之上新建的一层,不改任何已有 `<img>` 的 src。JAV 大图和小图diff --git a/web/css/16-settings.css b/web/css/16-settings.cssindex 970730f2a..6a7c50e74 100644--- a/web/css/16-settings.css+++ b/web/css/16-settings.css@@ -21,7 +21,7 @@ body.settings-open{overflow:hidden}靠一档亮度差加一条 --field-ring 发丝线浮起,不加投影。原来正好反着——白壳里嵌灰块,同一套控件在设置里和在首页上读出的层级相反。投影一并去掉:全站只有两张面这条规则不因为它是弹层就不算,压暗的遮罩已经把它和底下的内容分开了。 */-.settingscard{display:flex;flex-direction:column;width:min(520px,100%);max-height:min(720px,90vh);max-height:min(720px,90dvh);overflow:hidden;animation:settings-dialog-in .35s cubic-bezier(.4,0,.2,1) both;+.settingscard{display:flex;flex-direction:column;width:min(520px,100%);max-height:min(720px,90vh);max-height:min(720px,90dvh);overflow:clip;animation:settings-dialog-in .35s cubic-bezier(.4,0,.2,1) both;border:1px solid var(--field-ring);border-radius:var(--floating-radius);background:var(--page)}.settingsscroll{flex:1;min-height:0;overflow-y:auto;padding:0 20px 20px;overscroll-behavior:contain}.settingshead{z-index:2;display:flex;align-items:center;justify-content:space-between;flex:none;padding:20px 20px 16px;border-bottom:1px solid var(--field-ring);background:var(--ground)}/* 遮罩是唯一还要分主题写的一处:它是写死的实色而不是 token。卡片与分组走 --page、--ground 和 --field-ring,两档主题由 token 自己换,不再需要各写一条。@@ -31,8 +31,11 @@ body.settings-open{overflow:hidden}:root[data-theme="dark"] .settingspanel{background:rgba(0,0,0,.8)}.settingshead h2{margin:0;font-size:var(--fs-xl)}.settingshead button{border:0;background:transparent;color:var(--muted);width:34px;height:34px;border-radius:var(--control-radius);cursor:pointer;display:grid;place-items:center;transition:background-color .12s ease,color .12s ease}.settingshead button:hover{background:var(--hover);color:var(--ink)}.settingshead svg{width:20px;height:20px;stroke:currentColor;fill:none}.settingrow{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:18px;align-items:center;padding:14px 0 14px;border-top:1px solid var(--line-soft)}-.settingrow:first-of-type{border-top:0}.settingrow b{display:block;font-size:var(--fs-md)}.settingrow small{display:block;color:var(--muted);margin-top:3px;line-height:1.45}+.settinggroup>h3+.settingrow{border-top:0}.settingrow b{display:block;font-size:var(--fs-md)}.settingrow small{display:block;color:var(--muted);margin-top:8px;line-height:1.45}.settingrow .gselect{min-width:148px}+.settingsortrow{grid-template-columns:minmax(0,1fr)}+.settingsortcontrols{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:8px}+.settingsortcontrols .gselect{min-width:0;width:100%}.settinggroup{margin:16px 0 0;border:1px solid var(--field-ring);border-radius:var(--floating-radius);background:var(--ground);padding:0 16px 12px}.settinggroup>h3{margin:0;padding:14px 0 10px;font-size:var(--fs-lg);font-weight:600;color:var(--ink)}@@ -41,10 +44,10 @@ body.settings-open{overflow:hidden}中号 36×20 轨道 + 17px 圆点,关 = 灰轨道圆点靠左,开 = 主题蓝圆点靠右;Geist 的「Switch」是分段选择器(radio 语义),布尔开关的正确控件叫 Toggle。 */:is(#censorSetting,#detailAutoplaySetting,.ptoggle){appearance:none;-webkit-appearance:none;width:36px;height:20px;flex:none;- border-radius:var(--pill-radius);background:var(--line);position:relative;cursor:pointer;margin:0;+ border:0;box-sizing:border-box;padding:0;border-radius:var(--pill-radius);background:var(--line);position:relative;cursor:pointer;margin:0;transition:background-color .15s ease}:is(#censorSetting,#detailAutoplaySetting,.ptoggle)::after{content:'';position:absolute;top:1.5px;left:2px;width:17px;height:17px;- border-radius:50%;background:rgba(237,237,237,.84);transition:left .15s ease}+ border-radius:50%;background:#fff;transition:left .15s ease}:is(#censorSetting,#detailAutoplaySetting,.ptoggle):checked{background:var(--tungsten)}:is(#censorSetting,#detailAutoplaySetting,.ptoggle):checked::after{left:17px}:is(#censorSetting,#detailAutoplaySetting,.ptoggle):focus-visible{outline:2px solid var(--tungsten);outline-offset:2px}diff --git a/web/index.html b/web/index.htmlindex abe224f74..cdd055323 100644--- a/web/index.html+++ b/web/index.html@@ -206,15 +206,20 @@<div class="settingshead"><h2 id="settingsTitle">设置</h2><button id="settingsClose" aria-label="关闭设置"><svg viewBox="0 0 24 24"><use href="#i-x"/></svg></button></div><div class="settingsscroll">+ <section class="settinggroup"><h3>界面</h3>+ <div class="settingrow"><span><b>主题</b><small>跟随系统,或固定用浅色、深色。</small></span><div id="themeSetting"></div></div>+ <section class="sidebarsetting" aria-labelledby="sidebarOrderTitle"><span><b id="sidebarOrderTitle">左侧导航</b><small>直接拖动排序;可隐藏入口,也可从具体页面列表重新添加。窄栏和筛选抽屉会保持一致。</small></span><div class="sidebarorder" id="sidebarOrderSetting"></div></section>+ </section><section class="settinggroup"><h3>浏览</h3><div class="settingrow"><span><b>每批作品</b><small>首页每次加载的作品数量。</small></span><div id="batchSizeSetting"></div></div>- <div class="settingrow"><span><b>默认排序</b><small>打开首页时使用的排序。</small></span><div id="defaultSortSetting"></div></div>- <div class="settingrow"><span><b>默认排序方向</b><small>随机排序不使用方向。</small></span><div id="defaultSortDirectionSetting"></div></div>- <div class="settingrow"><span><b>悬停放大</b><small>转圈完成后进入放大预览。</small></span><div id="hoverDelaySetting"></div></div>- <label class="settingrow"><span><b>合并分卷与版本</b><small>同一番号的多个分卷或版次只占一张卡,展示第一个。</small></span><span class="pcheck"><input type="checkbox" id="groupCollapseSetting"><span aria-hidden="true"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="#i-check"/></svg></span></span></label>+ <div class="settingrow settingsortrow"><span><b>默认排序</b><small id="sortDirectionHelp">随机排序不使用方向。</small></span><div class="settingsortcontrols"><div id="defaultSortSetting"></div><div id="defaultSortDirectionSetting" aria-describedby="sortDirectionHelp"></div></div></div>+ <label class="settingrow"><span><b>合并分卷与版本</b><small>同一番号的多个分卷或版次只占一张卡,展示第一个。</small></span><input type="checkbox" id="groupCollapseSetting" class="ptoggle" role="switch"></label>+ <div class="settingrow"><span><b>JAV 默认封面</b><small>首页、接着看和 Mix 等位置共用;缺图时使用另一种封面。</small></span><div id="javImageSetting"></div></div>+ <div class="settingrow"><span><b>JAV 封面默认大小</b><small>JAV 作品列表的默认版式;小图使用所选封面。</small></span><div id="javSizeSetting"></div></div></section><section class="settinggroup"><h3>播放</h3>- <label class="settingrow"><span><b>打开详情自动播放</b><small id="detailAutoplayDescription">打开本地作品或关注视频详情时开始播放;关闭后点击播放按钮开始。</small></span><input type="checkbox" id="detailAutoplaySetting" aria-describedby="detailAutoplayDescription"></label>+ <div class="settingrow"><span><b>悬停放大</b><small>转圈完成后进入放大预览。</small></span><div id="hoverDelaySetting"></div></div>+ <label class="settingrow"><span><b>打开详情自动播放</b><small id="detailAutoplayDescription">打开本地作品或关注视频详情时开始播放;关闭后点击播放按钮开始。</small></span><input type="checkbox" id="detailAutoplaySetting" role="switch" aria-describedby="detailAutoplayDescription"></label><div class="settingrow"><span><b>快进 / 快退</b><small>卡片预览和详情播放器共用。</small></span><div id="seekSecondsSetting"></div></div><div class="settingrow"><span><b>相关推荐</b><small>详情下方一次显示的相似作品数量。</small></span><div id="relatedLimitSetting"></div></div></section>@@ -224,14 +229,8 @@<section class="settinggroup"><h3>关注</h3><div class="settingrow"><span><b>关注自动更新</b><small id="followScheduleState" aria-live="polite">读取运行状态…</small></span><div id="followScheduleSetting"></div></div></section>- <section class="settinggroup"><h3>界面</h3>- <div class="settingrow"><span><b>JAV 默认封面</b><small>首页、接着看和 Mix 等位置共用;缺图时使用另一种封面。</small></span><div id="javImageSetting"></div></div>- <div class="settingrow"><span><b>JAV 封面默认大小</b><small>JAV 作品列表的默认版式;小图使用所选封面。</small></span><div id="javSizeSetting"></div></div>- <div class="settingrow"><span><b>主题</b><small>跟随系统,或固定用浅色、深色。</small></span><div id="themeSetting"></div></div>- <section class="sidebarsetting" aria-labelledby="sidebarOrderTitle"><span><b id="sidebarOrderTitle">左侧导航</b><small>直接拖动排序;可隐藏入口,也可从具体页面列表重新添加。窄栏和筛选抽屉会保持一致。</small></span><div class="sidebarorder" id="sidebarOrderSetting"></div></section>- </section><section class="settinggroup"><h3>安全</h3>- <label class="settingrow"><span><b>SFW 模式</b><small id="sfwDescription">模糊、降低饱和度并压暗全站图片和视频,包括封面、头像与详情预览;停止悬停预览。文字、品牌标识和来源图标保持可见。</small></span><input type="checkbox" id="censorSetting" aria-describedby="sfwDescription"></label>+ <label class="settingrow"><span><b>SFW 模式</b><small id="sfwDescription">模糊、降低饱和度并压暗全站图片和视频,包括封面、头像与详情预览;停止悬停预览。文字、品牌标识和来源图标保持可见。</small></span><input type="checkbox" id="censorSetting" role="switch" aria-describedby="sfwDescription"></label></section></div></div>