Peach: Local-first video metadata scraper and media manager.
feat(web): 侧栏玻璃上那几团漂动的光改成自己配色的光晕
longmeidaoa62b04396e48
diff --git a/README.en.md b/README.en.mdindex ab24fac45..a2a051644 100644--- a/README.en.md+++ b/README.en.md@@ -43,7 +43,7 @@ Interface preferences are saved in the current browser and live under Settings:“Video thumbnail capture”, in the same place, belongs to the computer running Peach rather than to each browser: pick precise (a frame every 10 seconds) or coarse (every 30 seconds) and it captures frames in the background, so dragging the progress bar shows the picture at that point in time. It is off by default and only covers videos on local disks; every frame from a mounted cloud drive costs one fetch from the source. The images are cleaned up together with the video on the data management page.-The interface uses Board styling. “Increase contrast” in Settings disables navigation transparency and refraction; “Home glow” is the coloured wash at the top of the home page. Switch preset palettes from the round button at the bottom of the sidebar; Settings turns the glow off and adjusts strength, grain and each of the three spot colours. It shows in both the light and dark themes. Numeric preferences accept custom values within their supported ranges, with switches for optional features.+The interface uses Board styling. “Increase contrast” in Settings disables navigation transparency and refraction; “Sidebar glow” is the slowly drifting coloured light on the sidebar’s glass. Switch preset palettes from the palette button at the bottom of the sidebar; Settings turns the glow off and adjusts strength, grain and each of the three glow colours. It shows in both the light and dark themes. Numeric preferences accept custom values within their supported ranges, with switches for optional features.Choose a media library at the top of the sidebar; theme and settings controls are fixed at the bottom. Set library names and icons in Configuration; matching names group folders into one library. Library selection filters work lists and facets. Cloud libraries use locally served provider icons by default.diff --git a/README.md b/README.mdindex ceff80391..24c2b51e0 100644--- a/README.md+++ b/README.md@@ -43,7 +43,7 @@ Peach 是单用户、本地优先的个人媒体系统。在自己的电脑上同一处的「视频缩略图采集」跟着运行 Peach 的这台电脑走,不是每个浏览器各存一份:选精准(每 10 秒一帧)或粗略(每 30 秒一帧)后它在后台按密度抽帧,拖动进度条时按时间点显示画面。默认关闭,只采集本机磁盘上的片子;网盘上的每抽一帧都要回源拉一次。产物随片子一起在数据管理页清理。-界面采用 Board 风格。设置里的「增加对比度」关闭导航玻璃的透明与折射;「首页光晕」是首页顶部那片彩色光,可以关掉;配色在左栏底部那枚圆钮上挑,设置里的「首页光晕」调强度、颗粒感和三枚光斑各自的颜色,浅色与深色主题都会显示。数量和时间支持范围内自定义,可关闭的功能使用开关控制。+界面采用 Board 风格。设置里的「增加对比度」关闭导航玻璃的透明与折射;「侧栏光晕」是左栏玻璃面上那几团慢慢漂动的光,可以关掉;配色在左栏底部那枚配色钮上挑,设置里的「侧栏光晕」调强度、颗粒感和三枚光晕各自的颜色,浅色与深色主题都会显示。数量和时间支持范围内自定义,可关闭的功能使用开关控制。侧栏顶部选择媒体库,底部切换明暗主题并打开设置。配置中可设置媒体库名称和图标,同名文件夹归入一库;库选择限定作品列表与筛选项。网盘默认显示本机提供的网盘图标。diff --git a/scripts/vendor_web_dependencies.mjs b/scripts/vendor_web_dependencies.mjsindex 57e5f31ab..863e0c1e5 100644--- a/scripts/vendor_web_dependencies.mjs+++ b/scripts/vendor_web_dependencies.mjs@@ -127,9 +127,6 @@ const lucideIcons = new Map([// 数据管理页「空文件夹」那张卡的标识:说的是目录本身,既不是打开它,也不是去里面找。["folder", "folder"],["sun", "sun"], ["moon", "moon"],- // 侧栏底部「光晕配色」:一叠翻开的色卡,挑的是具体哪一枚颜色。设置分区那一枚- // `ri-palette-line` 说的是「界面」这一整组,两者不兼任。- ["swatch-book", "swatch-book"],// 小窗播放:右键菜单里「迷你播放器」是缩进角落的小屏,小窗上的「展开」是对角撑开;// `maximize` 归 JAV 大图版式,不兼任。「循环播放」与「复制视频网址」照 Lucide 本名。["picture-in-picture-2", "picture-in-picture-2"], ["maximize-2", "maximize-2"],@@ -252,6 +249,9 @@ index = index.replace(/Health Icons sperm outline-24px, CC0\/public domain/,index = index.replace(/Phosphor [0-9.]+ regular, MIT/,`Phosphor ${versions["@phosphor-icons/core"]} regular, MIT`);index = index.replaceAll(/\/vendor\/videojs\/[0-9.]+\//g, `/vendor/videojs/${versions["video.js"]}/`);+// `palette-line` 有两个使用者,它们说的是同一件事:设置分区的「界面」页签,和侧栏底部+// 那枚配色钮——那枚钮的弹层底部「详细设置」开的正是「界面」页。一枚字形一个意思,同一个+// 意思也只有一枚字形,所以这里不给配色钮另备一枚。const remixIcons = ["palette-line", "layout-grid-line", "play-circle-line", "search-line", "rss-line", "shield-check-line"];const remixSprite = lfText("node_modules", "remixicon", "fonts", "remixicon.symbol.svg");for (const name of remixIcons) {@@ -261,7 +261,7 @@ for (const name of remixIcons) {index = index.replace(pattern, symbol);}stage("web/vendor/remixicon-LICENSE.txt", lfText("node_modules", "remixicon", "License"));-stage("web/vendor/remixicon-ORIGIN.md", `# Remix Icon ${versions.remixicon}\n\n- npm 包:\`remixicon@${versions.remixicon}\`\n- npm lock integrity:\`${integrity("remixicon")}\`\n- 许可证:Remix Icon License v1.0,见 \`remixicon-LICENSE.txt\`。\n- 消费者:设置导航六枚内联 symbol。完整候选由本地 HTML 审查。\n`);+stage("web/vendor/remixicon-ORIGIN.md", `# Remix Icon ${versions.remixicon}\n\n- npm 包:\`remixicon@${versions.remixicon}\`\n- npm lock integrity:\`${integrity("remixicon")}\`\n- 许可证:Remix Icon License v1.0,见 \`remixicon-LICENSE.txt\`。\n- 消费者:设置导航六枚内联 symbol,其中 \`palette-line\` 同时给侧栏底部那枚配色钮。完整候选由本地 HTML 审查。\n`);stage("web/index.html", index);let app = text("web", "app.js");diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex 13a23db41..00af37aec 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -160,6 +160,9 @@ class WebUiSourceTests(unittest.TestCase):sources.extend(sorted((web / "js").glob("*.js")))cls.css = stylesheet_source()cls.app_js = (web / "app.js").read_text(encoding="utf-8")+ # 光晕的预设表与色板单独拎出来:断言要按色相角遍历那两张表,得先切到它们所在的+ # 那一份源码。它们现在住在 `web/js/home-glow.js`,不再由 app.js 定义。+ cls.glow_js = (web / "js" / "home-glow.js").read_text(encoding="utf-8")cls.page = chr(10).join(path.read_text(encoding="utf-8") for path in sources)@@ -594,7 +597,9 @@ class WebUiSourceTests(unittest.TestCase):def test_the_drawer_scrolls_in_an_inner_layer_so_the_track_can_stay_put(self):"""抽屉自己不滚,滚的是里面那层:跟着内容一起滚的轨道等于没有轨道。"""+ # 光晕那一层是抽屉的第一个子元素,滚的仍然只有 .drawerscroll 那一层。self.assertPageContains('<aside class="drawer" id="drawer">'+ '<div class="glowlayer" aria-hidden="true"></div>''<div class="drawerscroll" id="drawerScroll"></div></aside>')self.assertPageContains("$('#drawerScroll').innerHTML=")self.assertPageContains(".drawerscroll{height:100%;box-sizing:border-box;"@@ -5967,49 +5972,64 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains(".card.pending-delete .poster")self.assertPageContains('<b>回收站</b>')- def test_home_glow_is_three_spots_over_the_page_colour(self):- """光晕只有三枚光斑,底下就是页面本身:不铺底色带,也不压遮罩带。+ def test_sidebar_glow_lives_inside_the_drawer_and_drifts_like_its_glass(self):+ """光晕是侧栏玻璃面自带的那两团慢漂反光换成的三枚,长在 `.drawer` 里面。- 那两层是照着一张参考位图配出来的,它们一在,首页顶部就是另一张面——顶栏与卡片- 之间多出一条谁也说不清归属的色带。去掉之后光斑各自向 transparent 收边,落在 --page 上。+ 铺在页面身后的那一版是背景不是光晕——正文和卡片压在它上面,字读不出来。所以这一层+ `position:absolute;inset:0` 待在抽屉内部,溢出连圆角一起被抽屉的 overflow 裁掉。+ 位置由 drift 那两条动画推着走,和 board.css 给其余玻璃面的是同一套算法;抽屉自己+ 那两团因此必须置为 none,否则两套光斑叠着漂。"""- css = stylesheet_source()- self.assertPageContains("--glow-h:49vh")- self.assertPageContains("animation:ambient-in .8s ease .5s both")+ css = stylesheet_source() + (Path(__file__).resolve().parents[1]+ / "web/board.css").read_text(encoding="utf-8")+ self.assertIn('<aside class="drawer" id="drawer"><div class="glowlayer" aria-hidden="true">'+ '</div>', self.page, "光晕层是抽屉的第一个子元素")+ layer = css.split(".glowlayer{", 1)[1].split("}", 1)[0]+ self.assertIn("position:absolute;inset:0;z-index:-2", layer,+ "-1 已经归了 .navglide,光晕要在它下面、玻璃填充之上")+ self.assertIn(".drawer.drawer{--glass-drift-a:none;--glass-drift-b:none}", css)rule = css.split(".glowlayer::before{", 1)[1].split("}", 1)[0]- self.assertEqual(rule.count("radial-gradient("), 3, "三枚光斑,不多也不少")+ self.assertEqual(rule.count("radial-gradient("), 3, "三枚光晕,不多也不少")+ self.assertIn("background-size:200% 200%", rule, "画布两倍大,drift 才推得动")+ self.assertIn("animation:glowdriftx 41s linear infinite,"+ "glowdrifty 67s linear infinite,ambient-in .8s ease .5s both", rule)+ # 两条周期互质,合起来看不出循环点;和玻璃那两条同一个数,一眼读成同一种光。+ for name in ("@keyframes glowdriftx{", "@keyframes glowdrifty{"):+ self.assertIn(name, css)self.assertNotIn("linear-gradient", rule, "底色带与遮罩带都不属于这条规则")- for gone in ("--glow-veil", "--glow-angle", "--glow-base"):+ for gone in ("--glow-veil", "--glow-angle", "--glow-base", "--glow-h:",+ "--glow-mask", "--glow-rail-fade", "--glow-spot-1-x"):self.assertPageLacks(gone, "这个变量已经没有使用者")- def test_home_glow_reads_every_colour_and_centre_from_a_variable(self):- """`.glowlayer::before` 里一个字面颜色、一个字面坐标都不许有。+ def test_home_glow_reads_every_colour_and_radius_from_a_variable(self):+ """`.glowlayer::before` 里一个字面颜色都不许有。- 它们现在是设置面板改得动的参数:写死一处,那一处就永远不跟着用户走,而症状是+ 颜色是设置面板改得动的参数:写死一处,那一处就永远不跟着用户走,而症状是「换了配色但有一层没变」——没有报错,只是画面对不上。"""css = stylesheet_source()rule = css.split(".glowlayer::before{", 1)[1].split("}", 1)[0]self.assertNotIn("#", rule, "光晕里不许再出现字面颜色")self.assertEqual(re.findall(r"rgba?\(", rule), [], "光晕里不许再出现字面颜色")- for layer in ("--glow-lerp", "--glow-spot-1-color", "--glow-spot-2-x",- "--glow-spot-3-fade", "--glow-h", "--ambient-opacity"):+ for layer in ("--glow-lerp", "--glow-spot-1-color", "--glow-spot-2-w",+ "--glow-spot-3-fade", "--ambient-opacity"):self.assertIn(f"var({layer})", rule, f"{layer} 没有被 .glowlayer::before 引用")def test_home_glow_defaults_match_the_default_preset(self):"""样式表里的默认值就是 `amber` 那一档,两处一字不差。对不上的后果只出现在第一帧:`applyHomeGlow()` 跑完之前页面按样式表画,跑完之后- 按 JS 写的值画,中间会闪一次颜色。+ 按 JS 写的值画,中间会闪一次颜色。颜色是两处都有的那部分;半轴与收边只有这里一份,+ 三枚大小各不相同——一样大就读成一团,不是三枚。"""css = stylesheet_source()for declaration in (- "--glow-spot-1-color:rgba(224,138,47,.62); --glow-spot-1-x:38%; --glow-spot-1-y:30%",- "--glow-spot-1-w:46%; --glow-spot-1-h:76%; --glow-spot-1-fade:70%",- "--glow-spot-2-color:rgba(196,84,74,.52); --glow-spot-2-x:22%; --glow-spot-2-y:10%",- "--glow-spot-2-w:34%; --glow-spot-2-h:70%; --glow-spot-2-fade:72%",- "--glow-spot-3-color:rgba(168,106,82,.52); --glow-spot-3-x:78%; --glow-spot-3-y:22%",- "--glow-spot-3-w:40%; --glow-spot-3-h:72%; --glow-spot-3-fade:72%"):+ "--glow-spot-1-color:rgba(224,138,47,.62); --glow-spot-1-w:20%; "+ "--glow-spot-1-h:20%; --glow-spot-1-fade:72%",+ "--glow-spot-2-color:rgba(196,84,74,.52); --glow-spot-2-w:26%; "+ "--glow-spot-2-h:26%; --glow-spot-2-fade:74%",+ "--glow-spot-3-color:rgba(168,106,82,.52); --glow-spot-3-w:23%; "+ "--glow-spot-3-h:23%; --glow-spot-3-fade:73%"):self.assertIn(declaration, css)# 强度是用户那一档,主题缩放是色板那一档,实际不透明度是两者相乘。self.assertIn("--glow-noise:0; --glow-strength:1; --glow-theme-scale:.6", css)@@ -6018,15 +6038,15 @@ class WebUiSourceTests(unittest.TestCase):self.assertEqual(css.count("--glow-theme-scale:1;}"), 2, "深色两块色板都要自己那一档")def test_home_glow_presets_carry_no_cyan_or_teal(self):- """预设里没有一枚光斑落在青绿那一段色相上。+ """预设里没有一枚光晕落在青绿那一段色相上。青绿是照着外部参考配出来的那一版留下的印子,用户点名要它消失。只查名字挡不住——换个十六进制写法就绕过去了,所以按色相角判:150°–210° 之间、饱和度够得上看得见的那一档,一枚都不许有。近乎无彩的灰不在此列,它读出来不是颜色。"""- block = self.app_js.split("const HOME_GLOW_PRESETS=[", 1)[1].split("\n];", 1)[0]+ block = self.glow_js.split("const HOME_GLOW_PRESETS=[", 1)[1].split("\n];", 1)[0]colours = re.findall(r"color:'#([0-9a-f]{6})'", block)- self.assertGreaterEqual(len(colours), 12, "四档预设各三枚光斑")+ self.assertGreaterEqual(len(colours), 12, "四档预设各三枚光晕")for value in colours:with self.subTest(colour=value):red, green, blue = (int(value[at:at + 2], 16) / 255 for at in (0, 2, 4))@@ -6051,24 +6071,51 @@ class WebUiSourceTests(unittest.TestCase):self.assertIn("feTurbulence", rule)def test_home_glow_settings_are_stored_bounded_and_written_to_its_own_layer(self):- """设置里存得住、读回来要夹回区间,改一下就写到光晕自己那一层上。"""+ """设置里存得住、读回来要夹回区间,改一下就写到光晕自己那一层上。++ 用户面只剩三枚颜色、强度、颗粒和档名:光晕的形状(半轴、收边)和它怎么漂全在+ 样式表里。几何一旦进了 localStorage,改形状就再也改不动那些存过的机器。+ """self.assertPageContains("sidebarOrder:DEFAULT_SIDEBAR_ORDER,homeGlow:DEFAULT_HOME_GLOW}")self.assertPageContains("const DEFAULT_HOME_GLOW={on:true,preset:'amber',strength:100,noise:0,""...glowPalette('amber')}")self.assertPageContains("appSettings.homeGlow=normalizeHomeGlow(appSettings.homeGlow)")self.assertCode("function normalizeHomeGlow(raw){")- self.assertCode("strength:boundedPreference(+stored.strength,0,100,100),")- self.assertCode("noise:boundedPreference(+stored.noise,0,100,0)};")- self.assertCode("fade:boundedPreference(+spot.fade,10,100,fallback.fade)};")+ self.assertCode("strength:glowNumber(+stored.strength,0,100,100),")+ self.assertCode("noise:glowNumber(+stored.noise,0,100,0)};")+ self.assertPageLacks("fade:glowNumber(+spot.fade", "收边是形状,不是偏好")self.assertPageContains("const glowColor=(value,fallback)=>/^#[0-9a-f]{6}$/i.test(String(value))")- self.assertCode("function paintHomeGlow(){")+ self.assertCode("function paintHomeGlow(el,glow){")self.assertCode("write('--glow-strength',String(live?glow.strength/100:0));")- self.assertCode("write(`--glow-spot-${slot}-color`,glowRgba(spot.color,spot.alpha));")+ self.assertCode("write(`--glow-spot-${index+1}-color`,glowRgba(spot.color,spot.alpha));")self.assertPageContains("applyHomeGlow();")# 预设给中文名,含当前默认那一档。self.assertPageContains("['amber','钨丝暖阁',{")self.assertPageContains("['custom','自定义']")- self.assertGreaterEqual(self.app_js.count("spot1:{color:'#"), 4, "预设至少四档")+ self.assertGreaterEqual(self.glow_js.count("spot1:{color:'#"), 4, "预设至少四档")++ def test_home_glow_data_lives_in_a_module_app_js_only_imports(self):+ """预设、色板、规范化和那一次绘制都在 `web/js/home-glow.js`,app.js 只 import。++ React 壳要的就是这一份:留在 app.js 里,迁移时同一张预设表、同一套色板和同一段+ 规范化会被抄进组件再各自演化,而两份色板差一枚颜色是看不出来的。+ 所以那个模块不认识 `appSettings`、`$`、`saveSettings`,`paintHomeGlow` 只写传进来的+ 那枚元素;侧栏那枚配色钮、它的弹层和设置面板的装配仍旧留在 app.js。+ """+ self.assertIn("import { DEFAULT_HOME_GLOW, GLOW_SPOT_LABELS, GLOW_SWATCHES, "+ "GLOW_SWATCH_FAMILIES, HOME_GLOW_CHOICES, HOME_GLOW_PRESETS, "+ "HOME_GLOW_SPOTS, glowChipFill, glowColor, glowPalette, glowPresetName, "+ "normalizeHomeGlow, paintHomeGlow } from './js/home-glow.js';", self.app_js)+ for moved in ("const HOME_GLOW_PRESETS=[", "const GLOW_SWATCHES=[",+ "const GLOW_SPOT_LABELS=[", "const DEFAULT_HOME_GLOW=",+ "function normalizeHomeGlow(", "function paintHomeGlow("):+ self.assertNotIn(moved, self.app_js, f"{moved} 已经搬进 js/home-glow.js")+ self.assertIn(moved, self.glow_js)+ # 注释里说得出这几个名字(它讲的正是「这里没有它们」),代码里一次都不许出现。+ code = "\n".join(re.sub(r"/\*.*?\*/", "", self.glow_js, flags=re.S).splitlines())+ for forbidden in ("appSettings", "saveSettings(", "document.", "peach-ui.js"):+ self.assertNotIn(forbidden, code, "这一份不认识页面,只认参数")+ self.assertIn("paintHomeGlow(glowField,appSettings.homeGlow)", self.app_js)def test_home_glow_normalisation_replaces_a_retired_preset_wholesale(self):"""存着的档名已经不在清单里时,连它那三枚颜色一起换成默认那一档。@@ -6082,25 +6129,30 @@ class WebUiSourceTests(unittest.TestCase):self.assertCode("const seed=glowPalette(preset==='custom'?'amber':preset);")self.assertCode("const spot=known&&stored[key]&&typeof stored[key]==='object'""?stored[key]:{},fallback=seed[key];")- self.assertPageLacks("angle:boundedPreference", "角度已经不在模型里")+ self.assertPageLacks("angle:glowNumber", "角度已经不在模型里")self.assertPageLacks("base:seed.base.map", "底色已经不在模型里")- def test_home_glow_panel_is_two_named_groups_of_fields(self):- """参数区分成「场」和「颜色」两组:场是强度与颗粒两条拉条,颜色是三枚光斑。+ def test_home_glow_panel_leads_with_the_preset_then_names_one_group(self):+ """强度与颗粒直接跟在当前配色后面,只有「颜色」自己占一个带名字的分组。- 分组不是装饰:六个控件平铺时,改「颗粒」和改「光斑二」读起来是同一类操作,- 而前者动的是整层的质地、后者动的是其中一枚的颜色。+ 强度和颗粒不归任何分组:两条拉条一条调整层的亮度、一条调它的颗粒,都是这一片光+ 自己的事,套一个名字上去只会多出一个读不懂的词。三枚光晕要分组,是因为下面挂着+ 三行各自能展开色板的行。"""- self.assertPageContains('<b>首页光晕</b>')+ self.assertPageContains('<b>侧栏光晕</b>')self.assertPageContains('id="homeGlowSetting" class="ptoggle" role="switch"')self.assertPageContains('<section class="glowsetting" id="homeGlowControls"')self.assertCode("function renderHomeGlowSetting(){")self.assertPageContains("renderHomeGlowSetting();")- self.assertPageContains('<section class="glowgroup"><h4>场</h4>')+ self.assertPageLacks('<h4>场</h4>', "「场」不是这套界面的词")self.assertPageContains('<section class="glowgroup"><h4>颜色</h4>')self.assertPageContains("glowFieldRowHtml('strength','强度',100)")self.assertPageContains("glowFieldRowHtml('noise','颗粒',60)")- self.assertPageContains("const GLOW_SPOT_LABELS=['光斑一','光斑二','光斑三'];")+ # 「光斑」留给 board.css 里玻璃面自带那两团反光,它是另一件东西;用户在这里配的+ # 三枚一律叫光晕,界面文案和注释都不再混用。+ self.assertPageContains("const GLOW_SPOT_LABELS=['光晕一','光晕二','光晕三'];")+ for stale in ("光斑一", "光斑二", "光斑三", "光斑色"):+ self.assertPageLacks(stale)self.assertPageContains('<button type="button" class="geist-button" data-glow-reset>恢复默认</button>')# 即时生效,不配「保存」键。self.assertPageLacks('data-glow-save')@@ -6128,7 +6180,7 @@ class WebUiSourceTests(unittest.TestCase):self.assertCode("glow().preset='custom';")# 弹层与页面其它浮层同一套开合,不自己写一份定位。self.assertCode("wireAnchoredMenu(row,toggle,pop);")- block = self.app_js.split("const GLOW_SWATCHES=[", 1)[1].split("\n];", 1)[0]+ block = self.glow_js.split("const GLOW_SWATCHES=[", 1)[1].split("\n];", 1)[0]colours = re.findall(r"'#([0-9a-f]{6})'", block)self.assertGreaterEqual(len(colours), 36, "七个色系各六档")for value in colours:@@ -6146,8 +6198,9 @@ class WebUiSourceTests(unittest.TestCase):"""self.assertCode("onInput:value=>{glow()[field]=value;applyHomeGlow()},")self.assertCode("onChange:()=>saveSettings()}));")- self.assertCode("glowFrame=requestAnimationFrame(()=>{glowFrame=0;paintHomeGlow()});")- self.assertCode("if(glowWritten.get(name)===value)return;")+ self.assertCode("glowFrame=requestAnimationFrame(()=>{glowFrame=0;"+ "paintHomeGlow(glowField,appSettings.homeGlow)});")+ self.assertCode("if(written.get(name)===value)return;")# 面板 DOM 只建一次:重建会把正开着的颜色弹层、焦点和拖动状态一起扔掉。self.assertCode("if(mount.dataset.glowWired!=='true'){")@@ -6161,9 +6214,8 @@ class WebUiSourceTests(unittest.TestCase):css = stylesheet_source()self.assertPageContains('<div class="glowlayer" aria-hidden="true"></div>')self.assertCode("const glowField=document.querySelector('.glowlayer');")- self.assertCode("const glow=appSettings.homeGlow,style=glowField.style,live=glow.on;")+ self.assertCode("el.style.setProperty(name,value);")self.assertIn(".glowlayer{--ambient-opacity:calc(var(--glow-strength) * var(--glow-theme-scale));", css)- self.assertIn("position:absolute;top:0;left:0;right:0;height:0;z-index:0;pointer-events:none}", css)self.assertNotIn("body::before{", css, "光晕不再挂在 body 的伪元素上")self.assertNotIn("body::after{", css, "光晕不再挂在 body 的伪元素上")@@ -6193,14 +6245,18 @@ class WebUiSourceTests(unittest.TestCase):self.assertIn("const rect=trackBox||track.getBoundingClientRect();", components)def test_sidebar_carries_the_glow_preset_button_next_to_the_theme_toggle(self):- """侧栏底部那枚圆钮就是换配色的入口,收起时和主题键叠成一列。+ """侧栏底部那枚配色钮就是换配色的入口,收起时和主题键叠成一列。配色是随手换的东西,设置面板是调细节的地方:把它留在面板里,换一次要开面板、- 找分区、再找下拉。圆钮右下那枚点说的是现在这一档的第一枚光斑。+ 找分区、再找下拉。钮右下那枚点说的是现在这一档的第一枚光晕。+ 它和旁边的设置钮长得一模一样:36px、8px 圆角、透明底、20px 图标。加一圈边和一层+ 阴影的那一版是 BoardUI 给浮在内容上的按钮画的,这里它站在侧栏面上,紧挨着一枚+ 没有任何框的设置钮——两枚并排却一枚带框,读起来是两种控件。"""self.assertPageContains('class="board-glow-toggle" id="boardGlowBtn" aria-label="光晕配色"')self.assertPageContains('aria-haspopup="dialog" aria-expanded="false" aria-controls="boardGlowMenu"')- self.assertPageContains("${icon('swatch-book')}<span class=\"board-glow-dot\" aria-hidden=\"true\"></span>")+ self.assertPageContains('<svg viewBox="0 0 24 24" aria-hidden="true"><use href="#ri-palette-line"/>'+ '</svg><span class="board-glow-dot" aria-hidden="true"></span>')self.assertPageContains('<header class="board-glow-head"><span>配色</span>')self.assertPageContains('class="board-glow-reset" data-glow-preset-reset>重置</button>')self.assertPageContains('<footer><button type="button" class="geist-button" data-glow-detail>详细设置</button></footer>')@@ -6209,8 +6265,15 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains('aria-pressed="${key===current}"')css = stylesheet_source() + (Path(__file__).resolve().parents[1]/ "web/board.css").read_text(encoding="utf-8")- self.assertIn(".board-glow-toggle{", css)- self.assertIn("border-radius:50%", css)+ self.assertIn(".board-glow-toggle{position:relative;display:grid;place-items:center;"+ "width:36px;height:36px;flex:none;\n padding:0;border:0;border-radius:8px;"+ "background:transparent;color:var(--muted);cursor:pointer}", css)+ self.assertIn(".board-glow-toggle:hover{background:var(--hover);color:var(--ink)}", css)+ # 和设置钮对齐到一个数:两枚 36px 的方块在 60px 的收起态里才排得直。+ self.assertIn(".board-foot-actions>#settingsBtn{width:36px;height:36px;", css)+ self.assertIn(".board-glow-toggle svg{width:20px;height:20px;fill:currentColor;stroke:none}", css)+ # 右下那枚点还留着,它是唯一说得出「现在哪一档」的东西。+ self.assertIn(".board-glow-dot{", css)# 收起时侧栏只有 60px,两枚键排成一列。self.assertIn(".drawer:not(.open) .board-foot-actions{flex-direction:column}", css)@@ -9127,11 +9190,12 @@ class WebUiSourceTests(unittest.TestCase):# 名下带人的事务所在同一个开关的另一半,走公文包。self.assertPageContains("['studios','厂牌','clapperboard'],")self.assertPageContains('<symbol id="i-clapperboard" viewBox="0 0 24 24">')- # 侧栏底部那枚圆钮换的是首页光晕的配色,所以是一叠翻开的色卡:挑的是具体哪一枚- # 颜色。设置分区那一枚 `ri-palette-line` 说的是「界面」这一整组偏好,两者不兼任。- self.assertPageContains("${icon('swatch-book')}")- self.assertPageContains('<symbol id="i-swatch-book" viewBox="0 0 24 24">')+ # `ri-palette-line` 有两个消费者,说的是同一件事:外观。侧栏底部那枚钮换的是光晕+ # 配色,设置里的「界面」那一格是这组偏好的整体入口——弹层上的「详细设置」点开的+ # 正是那一格,同一个意思给两个字形反而是在说它们不是一件事。+ self.assertPageContains('<use href="#ri-palette-line"/></svg><span class="board-glow-dot"')self.assertPageContains("const SETTINGS_TAB_ICONS={'界面':'ri-palette-line'")+ self.assertPageLacks("swatch-book", "换下来的这一枚没有别的使用者,雪碧图里也不留")for gone in ("i-monitor-cog", "i-volume-2", "i-sun-moon", "i-building","i-sliders-horizontal", "i-computer"):self.assertPageLacks(f'<symbol id="{gone}"')diff --git a/web/app.js b/web/app.jsindex 51fd23914..5e4d3a554 100644--- a/web/app.js+++ b/web/app.js@@ -11,6 +11,7 @@ import { javDisplayName, javTitleHtml } from './js/jav-title.js';import { matchRoute, routeLabel } from './js/routes.js';import { initMiddleTruncate } from './js/middle-truncate.js';import { tagLabel } from './js/tags.js';+import { DEFAULT_HOME_GLOW, GLOW_SPOT_LABELS, GLOW_SWATCHES, GLOW_SWATCH_FAMILIES, HOME_GLOW_CHOICES, HOME_GLOW_PRESETS, HOME_GLOW_SPOTS, glowChipFill, glowColor, glowPalette, glowPresetName, normalizeHomeGlow, paintHomeGlow } from './js/home-glow.js';import { mountIsland, unmountIsland, islandMounted, createReviewSelection, wireReviewSelection, updateReviewSticky, groupReviewRows, paginationHtml, pageCount, clampPage, identityEvidenceHtml, reviewImageHtml, wireReviewPictures, preferredDirection } from './dist/peach-ui.js';import { catalogSuggestions, catalogEmptyHtml, emptyCatalogLayout, syncSidebarSurface, sidebarTagCounts, sidebarHasCatalogContent, cleanupSkeletonHtml, cloudLocations, cloudPreferenceLocations } from './dist/peach-ui.js';import { javImageKind, normalizeJavImage, normalizeJavLayout, normalizeJavPreferences, panelFrame, syncJavImages, nativeImageFit, matchesFaceSource, entitySkeletonHtml } from './dist/peach-ui.js';@@ -491,63 +492,6 @@ const PHOTO_SIZES=[['big','大图','maximize'],['small','小图','layout-grid']]const PHOTO_LAYOUTS=[['fixed','固定比例','layout-grid'],['masonry','瀑布流','columns-2']];/* 显示器用于跟随系统主题和详情页的画面分辨率。 */const THEME_OPTIONS=[['system','跟随系统','monitor'],['light','浅色','sun'],['dark','深色','moon']];-/* 首页光晕的参数模型。一档配色就是三枚光斑:颜色、不透明度、圆心、椭圆半轴、收边位置;- 开关、强度和颗粒不属于配色,换档时不动。- 这个形状借自 feralui.dev/gradients 的 JSON 导出(登记在 docs/HANDOFF.md),只借参数模型,- 渲染仍是 web/css/01-base.css 里那三层纯 CSS 径向渐变,不引入 Canvas。- 三枚光斑各自向 transparent 收边,落在页面底色上,所以每一枚都得自己亮得起来:- 压暗的那种颜色在深色页上等于没有,在浅色页上是一团脏。- `amber` 是默认那一档,和 :root 上的默认值一字不差。 */-const HOME_GLOW_SPOTS=['spot1','spot2','spot3'];-const HOME_GLOW_PRESETS=[- ['amber','钨丝暖阁',{- spot1:{color:'#e08a2f',alpha:62,x:38,y:30,w:46,h:76,fade:70},- spot2:{color:'#c4544a',alpha:52,x:22,y:10,w:34,h:70,fade:72},- spot3:{color:'#a86a52',alpha:52,x:78,y:22,w:40,h:72,fade:72}}],- ['plum','夜樱',{- spot1:{color:'#b455a0',alpha:64,x:46,y:28,w:44,h:76,fade:70},- spot2:{color:'#6a4fd0',alpha:54,x:24,y:8,w:36,h:72,fade:74},- spot3:{color:'#7a4f96',alpha:56,x:80,y:20,w:38,h:70,fade:72}}],- ['pine','深林',{- spot1:{color:'#3f9e57',alpha:66,x:40,y:32,w:44,h:78,fade:68},- spot2:{color:'#7fae4a',alpha:48,x:26,y:8,w:34,h:70,fade:74},- spot3:{color:'#4f9463',alpha:56,x:78,y:20,w:40,h:70,fade:72}}],- ['ash','灰雾',{- spot1:{color:'#8f98a4',alpha:52,x:44,y:32,w:46,h:78,fade:70},- spot2:{color:'#b6bcc4',alpha:38,x:28,y:8,w:36,h:72,fade:74},- spot3:{color:'#6f7783',alpha:50,x:76,y:20,w:38,h:70,fade:72}}],-];-/* 手调过颜色之后当前档就不再是任何一个预设,侧栏那一格和面板顶上的标识要如实说这件事,- 不能继续顶着上一档的名字。 */-const HOME_GLOW_CHOICES=[...HOME_GLOW_PRESETS.map(([key,label])=>[key,label]),['custom','自定义']];-const glowPresetName=key=>(HOME_GLOW_CHOICES.find(([name])=>name===key)||HOME_GLOW_CHOICES[0])[1];-const glowPalette=key=>structuredClone((HOME_GLOW_PRESETS.find(([name])=>name===key)||HOME_GLOW_PRESETS[0])[2]);-/* 挑颜色的那张色板。七个色系各六档明度,名字按颜色本身取,不按它被用在哪儿——同一枚- 颜色换到另一枚光斑上还是同一个名字。十二枚预设色全部落在这张表里,所以从侧栏选完- 预设再打开颜色弹层,选中环指得出当前那一格;表里缺哪一枚,那一枚就永远是「没选中」。- 青绿整段不收:它在深色页上发冷、在浅色页上发脏,首页那片光用不上。 */-const GLOW_SWATCH_FAMILIES=[['all','全部'],['gray','灰'],['red','红'],['yellow','黄'],- ['green','绿'],['blue','蓝'],['purple','紫'],['brown','棕']];-const GLOW_SWATCHES=[- ['gray','云灰','#d8dade'],['gray','雾灰','#b6bcc4'],['gray','石灰','#8f98a4'],- ['gray','铁灰','#6f7783'],['gray','墨灰','#4a4e56'],['gray','深灰','#2e3138'],- ['red','樱红','#f08a8a'],['red','珊瑚','#e26a62'],['red','砖红','#c4544a'],- ['red','朱红','#b5322f'],['red','酒红','#8e2a2c'],['red','暗红','#6b2224'],- ['yellow','麦黄','#f2d48a'],['yellow','琥珀','#e8b451'],['yellow','钨丝','#e08a2f'],- ['yellow','金黄','#cf8a20'],['yellow','姜黄','#a9701c'],['yellow','栗黄','#7d5216'],- ['green','嫩芽','#a9cf7e'],['green','叶绿','#7fae4a'],['green','草绿','#5da34f'],- ['green','森绿','#3f9e57'],['green','苔绿','#4f9463'],['green','墨绿','#27563a'],- ['blue','天蓝','#9fc2e8'],['blue','湖蓝','#6a9fd8'],['blue','靛蓝','#4478c0'],- ['blue','宝蓝','#2f5ba3'],['blue','深蓝','#27467c'],['blue','夜蓝','#1c3358'],- ['purple','丁香','#c3a7e0'],['purple','品红','#b455a0'],['purple','薰衣草','#a67fd2'],- ['purple','葡萄','#6a4fd0'],['purple','茄紫','#7a4f96'],['purple','深紫','#432c6d'],- ['brown','沙棕','#d6b492'],['brown','陶棕','#bd8f68'],['brown','赭棕','#a86a52'],- ['brown','栗棕','#8c5340'],['brown','褐棕','#6d3f31'],['brown','深褐','#4e2d23'],-];-const GLOW_SPOT_LABELS=['光斑一','光斑二','光斑三'];-const glowColor=(value,fallback)=>/^#[0-9a-f]{6}$/i.test(String(value))?String(value).toLowerCase():fallback;-const glowRgba=(hex,alpha)=>`rgba(${[1,3,5].map(at=>parseInt(hex.slice(at,at+2),16)).join(',')},${(alpha/100).toFixed(2)})`;-const DEFAULT_HOME_GLOW={on:true,preset:'amber',strength:100,noise:0,...glowPalette('amber')};const DEFAULT_SETTINGS={batchSize:60,defaultSort:'seed',sortDefaultsVersion:3,hoverDelaySeconds:5,seekSeconds:10,searchHistoryLimit:10,relatedLimit:20,javLayout:'big',javImage:'cover',followLayout:'default',peopleLayout:'big',photoSize:'small',ambientMode:true,miniplayer:true,theaterMode:false,theme:'system',groupCollapse:true,sidebarOrder:DEFAULT_SIDEBAR_ORDER,homeGlow:DEFAULT_HOME_GLOW};let appSettings={...DEFAULT_SETTINGS};try{appSettings={...DEFAULT_SETTINGS,...JSON.parse(localStorage.getItem(SETTINGS_KEY)||'{}')}}catch(_e){}@@ -607,68 +551,21 @@ function applyTheme(choice=appSettings.theme){}applyTheme();prefersDark.addEventListener('change',()=>{if(appSettings.theme==='system')applyTheme()});-/* 光晕参数整份来自 localStorage,形态和范围都不可信:颜色写成任意字符串会让那一层- 渐变整条失效,百分比越界会把光斑糊成一整片或者缩没。逐项夹回区间、认不出就退回- 默认那一档,而不是整份丢掉——一个坏掉的数不该把用户调好的其余几档一起清空。- 只有一种情形要连颜色一起换掉:存着的档名已经不在清单里。那说明这一档被清退了,- 留在旁边的三枚光斑颜色正是被清退的那一版,按坏值逐项夹回去只会把它原样留在页面上。- 自定义不在此列——那三枚颜色是用户自己挑的,档名认得出来,照样留着。- 已经不存在的键(旧版本的底色与角度)不必单独清理:这里只按当前模型逐项取值。 */-function normalizeHomeGlow(raw){- const stored=raw&&typeof raw==='object'?raw:{};- const known=HOME_GLOW_CHOICES.some(([key])=>key===stored.preset);- const preset=known?stored.preset:'amber';- const seed=glowPalette(preset==='custom'?'amber':preset);- const glow={on:stored.on!==false,preset,- strength:boundedPreference(+stored.strength,0,100,100),- noise:boundedPreference(+stored.noise,0,100,0)};- for(const key of HOME_GLOW_SPOTS){- const spot=known&&stored[key]&&typeof stored[key]==='object'?stored[key]:{},fallback=seed[key];- glow[key]={color:glowColor(spot.color,fallback.color),- alpha:boundedPreference(+spot.alpha,0,100,fallback.alpha),- x:boundedPreference(+spot.x,-50,150,fallback.x),y:boundedPreference(+spot.y,-50,150,fallback.y),- w:boundedPreference(+spot.w,5,200,fallback.w),h:boundedPreference(+spot.h,5,200,fallback.h),- fade:boundedPreference(+spot.fade,10,100,fallback.fade)};- }- return glow;-}-/* 只写值,光晕怎么画留在 web/css/01-base.css 一份。关掉时强度和颗粒一起归零,- `.glowlayer::before` 的不透明度按那句乘法算成 0,不另设一个「关」的分支——否则- 「关着」和「强度 0」会是两条各自演化的路径。-- 写的对象是 `.glowlayer` 那枚空 div,不是 <html>。自定义属性是继承的,写在根上整棵树- 都要重算样式,实测每帧 15ms 上下,拖动时帧预算当场就超;写到一枚没有子节点的元素上- 是 0.09ms。量法和数字记在 web/css/01-base.css 那条规则上面。-- 写之前先和上一次写进去的值比一遍。整份参数有 20 个变量,拖强度那条拉条时变的只有- 一个;不比就是每一步把 20 个都重设一遍。实测拖 60 步是 1320 次 setProperty,去掉- 重复之后只剩真正变了的那几次。 */-const glowWritten=new Map();-const glowField=document.querySelector('.glowlayer');-function paintHomeGlow(){- const glow=appSettings.homeGlow,style=glowField.style,live=glow.on;- const write=(name,value)=>{- if(glowWritten.get(name)===value)return;- glowWritten.set(name,value);style.setProperty(name,value);- };- write('--glow-strength',String(live?glow.strength/100:0));- write('--glow-noise',String(live?glow.noise/100:0));- HOME_GLOW_SPOTS.forEach((key,index)=>{- const spot=glow[key],slot=index+1;- write(`--glow-spot-${slot}-color`,glowRgba(spot.color,spot.alpha));- for(const [name,value] of [['x',spot.x],['y',spot.y],['w',spot.w],['h',spot.h],['fade',spot.fade]])- write(`--glow-spot-${slot}-${name}`,`${value}%`);- });-}-/* 一帧只写一次。指针拖动一秒能发上百个 pointermove,每一个都同步写变量的话,写进去的+/* 光晕怎么算、怎么写都在 `./js/home-glow.js`:那一份不认识 appSettings,React 壳直接+ import 同一个文件。这里只负责把当前设置和 `.glowlayer` 那枚空 div 递进去。+ 写的对象是那枚 div 而不是 <html>:自定义属性是继承的,写在根上整棵树都要重算样式,+ 实测每帧 15ms 上下,拖动时帧预算当场就超;量法和数字记在 web/css/01-base.css 那条规则+ 上面。+ 一帧只写一次。指针拖动一秒能发上百个 pointermove,每一个都同步写变量的话,写进去的中间那几十份没有任何一帧画得出来,代价却照付。排进 requestAnimationFrame 之后,写的就是这一帧真正要画的那一份。 */+const glowField=document.querySelector('.glowlayer');let glowFrame=0;function applyHomeGlow(){if(glowFrame)return;- glowFrame=requestAnimationFrame(()=>{glowFrame=0;paintHomeGlow()});+ glowFrame=requestAnimationFrame(()=>{glowFrame=0;paintHomeGlow(glowField,appSettings.homeGlow)});}-paintHomeGlow();+paintHomeGlow(glowField,appSettings.homeGlow);/* 三档互斥视图是 Geist Switch(一组共享 name 的 radio),与卡片版式切换共用同一份模板;形状按 vercel.com 的主题选择器单独给,见 web/css/16-settings.css。 */function renderJavImageSetting(){@@ -686,11 +583,13 @@ function renderJavImageSetting(){JAV_LAYOUTS,javLayout(),{attr:'data-jav-layout',className:'javimageswitch',text:true});wireJavLayoutButtons(size);}-/* 首页光晕的详细设置照 feralui.dev/gradients 的工作台面板来:分组标题是一行小号灰字,- 参数行是「84px 标签 + 自绘拉条 + 右侧等宽读数」,颜色行点开在自己下方弹一张色板。+/* 侧栏光晕的详细设置照 feralui.dev/gradients 的工作台面板来:参数行是「84px 标签 ++ 自绘拉条 + 右侧等宽读数」,颜色行点开在自己下方弹一张色板。取证见 docs/reference-snapshots/feralui-studio-boardui-accent-measured.md。- 预设不在这一屏选——它在侧栏底部那枚圆钮上,这里只留一行只读的当前档名,否则同一件- 事有两个入口,用户得先弄清哪一个说了算。 */+ 预设不在这一屏选——它在侧栏底部那枚配色钮上,这里只留一行只读的当前档名,否则同一件+ 事有两个入口,用户得先弄清哪一个说了算。+ 强度和颗粒不再套一层分组标题:这一块总共五行,上面还顶着「当前配色」,两行拉条前面+ 再加一行小灰字,读起来是又进了一层,而它们和下面三枚颜色本来就都属于这一项。 */const glowSwatchesHtml=()=>GLOW_SWATCHES.map(([family,name,hex])=>`<button type="button" class="glowswatch" role="radio" aria-checked="false" data-glow-swatch="${hex}"data-glow-family="${family}" style="--glow-swatch:${hex}" title="${esc(name)}" aria-label="${esc(name)}"></button>`).join('');@@ -711,8 +610,8 @@ const glowStopRowHtml=(key,index)=>{const glowFieldRowHtml=(field,label,max)=>`<div class="glowfield"><span class="glowfieldlabel">${esc(label)}</span>${dialSliderHtml({value:appSettings.homeGlow[field],min:0,max,step:1,label,attr:`data-glow-dial="${field}"`})}</div>`;const homeGlowControlsHtml=()=>`<p class="glowcurrent">当前配色<b data-glow-preset-name></b></p>- <section class="glowgroup"><h4>场</h4><div class="glowfields">- ${glowFieldRowHtml('strength','强度',100)}${glowFieldRowHtml('noise','颗粒',60)}</div></section>+ <div class="glowfields">+ ${glowFieldRowHtml('strength','强度',100)}${glowFieldRowHtml('noise','颗粒',60)}</div><section class="glowgroup"><h4>颜色</h4><div class="glowstops">${HOME_GLOW_SPOTS.map(glowStopRowHtml).join('')}</div><div class="glowactions"><button type="button" class="geist-button" data-glow-reset>恢复默认</button></div></section>`;@@ -11192,20 +11091,21 @@ const boardFoot=document.createElement('div');boardFoot.className='board-sidebarboardFoot.innerHTML=`<div class="board-theme-toggle" role="group" aria-label="明暗主题"><span class="board-theme-thumb" aria-hidden="true"></span><button type="button" data-board-theme="light" aria-label="浅色主题">${icon('sun')}</button><button type="button" data-board-theme="dark" aria-label="深色主题">${icon('moon')}</button></div>`;/* 光晕配色钮和设置钮归一组,明暗键单独一组:侧栏收窄到 60px 时这一列竖着排,明暗键落在最下面(boardui.com 右下角那一对就是配色在上、明暗在下)。展开态横排:明暗在左、- 这一组在右。 */-boardFoot.insertAdjacentHTML('beforeend',`<div class="board-foot-actions"><button type="button" class="board-glow-toggle" id="boardGlowBtn" aria-label="光晕配色" aria-haspopup="dialog" aria-expanded="false" aria-controls="boardGlowMenu">${icon('swatch-book')}<span class="board-glow-dot" aria-hidden="true"></span></button></div>`);+ 这一组在右。+ 字形直接引 `#ri-palette-line`,不走 `icon()`:那一枚是 Remix 的实心路径,`icon()` 拼的是+ `#i-` 前缀的线条件。它和设置分区「界面」那一枚是同一个意思——这枚钮的弹层底部「详细+ 设置」开的正是那一页,两处说的都是外观,同一个意思本来就只该有一枚字形。 */+boardFoot.insertAdjacentHTML('beforeend',`<div class="board-foot-actions"><button type="button" class="board-glow-toggle" id="boardGlowBtn" aria-label="光晕配色" aria-haspopup="dialog" aria-expanded="false" aria-controls="boardGlowMenu"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="#ri-palette-line"/></svg><span class="board-glow-dot" aria-hidden="true"></span></button></div>`);boardFoot.querySelector('.board-foot-actions').append(document.querySelector('#settingsBtn'));document.querySelector('#drawer').append(boardFoot);boardFoot.querySelectorAll('[data-board-theme]').forEach(button=>button.onclick=()=>{if(button.getAttribute('aria-pressed')==='true')return;transitionTheme(button,()=>{appSettings.theme=button.dataset.boardTheme;saveSettings();applyTheme();renderThemeSetting()})});applyTheme();-/* 侧栏的光晕配色弹层照 boardui.com 右下角那枚「Accent color」:一枚带右下角色点的圆钮,+/* 侧栏的光晕配色弹层照 boardui.com 右下角那枚「Accent color」:一枚带右下角色点的按钮,点开是一张 248px 的卡,头部一行标题加「重置」文字键,主体是 6 列圆球,底部一枚- 全宽次级按钮通到详细设置。圆球本身按 feralui 的预设 chip 做:三枚光斑色等分一圈+ 全宽次级按钮通到详细设置。圆球本身按 feralui 的预设 chip 做:三枚光晕色等分一圈conic-gradient,再叠 BoardUI 那三层白色高光。实测见 docs/reference-snapshots/feralui-studio-boardui-accent-measured.md。 */const glowSpotColors=glow=>HOME_GLOW_SPOTS.map(key=>glow[key].color);-const glowChipFill=colors=>`conic-gradient(from -90deg,${colors.map((color,index)=>- `${color} ${(index*100/colors.length).toFixed(3)}% ${((index+1)*100/colors.length).toFixed(3)}%`).join(',')})`;const glowChipHtml=(key,label,colors,current)=>`<button type="button" class="board-glow-chip" data-glow-preset="${key}"aria-pressed="${key===current}" title="${esc(label)}" aria-label="${esc(label)}"><span class="board-glow-ball"aria-hidden="true" style="--glow-chip:${glowChipFill(colors)}"></span></button>`;diff --git a/web/board.css b/web/board.cssindex eafc7e41b..ac497e5b6 100644--- a/web/board.css+++ b/web/board.css@@ -154,6 +154,11 @@backdrop-filter:var(--glass-optic,blur(22px)) saturate(160%) var(--glass-lume);-webkit-backdrop-filter:var(--glass-optic,blur(22px)) saturate(160%) var(--glass-lume);border:0;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);}+/* 侧栏这一块玻璃上的反光归 `.glowlayer`:用户配得了色的三枚光晕按同一套 drift 在这里+ 漂。自带那两团白光留着就是两套光斑叠着走,亮的那一档会把配好的颜色冲淡成灰。+ 只对抽屉置空——其余玻璃面(搜索框、筛选浮层、顶栏图标钮)仍走自己那两团,那一点正是+ 「顶多折射到」的意思。填充、sheen、内缘亮线和 backdrop-filter 全部不动。 */+.drawer.drawer{--glass-drift-a:none;--glass-drift-b:none}/* 搜索框使用浏览器原生模糊,尺寸变化不依赖异步 SVG 位移贴图。 */.top .search.search.search{--glass-optic:blur(22px)}/* 快照里的玻璃使用实底承接光晕;实时页面恢复后再采样背景。 */@@ -542,7 +547,7 @@ body :is(#manageTitle,#manageCrumb,#manageLede){max-width:var(--board-content);w@media(prefers-reduced-motion:reduce){.board-segments-ready>.board-segment-thumb{transition:none}}.reviewitem,.followtask{border-color:var(--line);border-radius:16px}:root[data-theme="dark"]{--page:#111;--ground:#1c1c1c;--surface:#232323;--sunk:#171717;--ink:#fafafa;--ink-2:#d4d4d4;--muted:#a3a3a3;--line:#383838;--line-soft:#303030;--inset:#303030;--picked:#303030;--hover:rgba(255,255,255,.07);--tungsten:#60a5fa}-/* 首页光晕由设置里的「首页光晕」一项决定开关:关掉时 --glow-strength 是 0,+/* 侧栏光晕由设置里的「侧栏光晕」一项决定开关:关掉时 --glow-strength 是 0,`.glowlayer::before` 的不透明度跟着算成 0。这里不能再压一条 display:none——那会让设置面板上的开关、强度、配色和颗粒四个控件全部调不出任何变化,而界面上没有任何东西说得出为什么。 */.tiers{background:transparent}@@ -909,17 +914,20 @@ html.board-high-contrast .settingscard.settingscard>.board-local-nav{background:.board-foot-actions{display:flex;align-items:center;gap:6px}.board-foot-actions>#settingsBtn{width:36px;height:36px;padding:0;display:grid;place-items:center;border-radius:8px;background:transparent;flex:none}.board-foot-actions>#settingsBtn svg{width:20px;height:20px;margin:0}-/* 「光晕配色」照 boardui.com 右下角那枚 Accent color:40×40 圆形、面色底加 1px 边和一层- dropdown 薄影,右下角一颗 10px 色点报当前预设的第一枚光斑色,色点外面那圈环取侧栏+/* 「光晕配色」和它旁边的设置钮是同一排里的两枚图标键,所以穿同一身盒子:36×36、8px+ 圆角、透明底、20px 字形、同一条悬停。boardui.com 那枚 Accent color 自带边框、面色底和+ 一层 dropdown 薄影,是因为它浮在页面内容上、身后什么都没有;这一枚坐在侧栏自己的面+ 上,挨着的设置钮什么都不穿——描一圈框只会让这一对读成两种控件。+ 右下角那颗 10px 色点照上游留着,报的是当前预设的第一枚光晕色;色点外面那圈环取侧栏自己的面色,所以它读起来是浮在钮上的一颗,不是钮身上的一块。+ 字形是 Remix 的实心路径(`#ri-palette-line`),按它自己那套用 fill 画。实测见 docs/reference-snapshots/feralui-studio-boardui-accent-measured.md。 */-.board-glow-toggle{position:relative;display:grid;place-items:center;width:40px;height:40px;flex:none;- padding:0;border:1px solid var(--line);border-radius:50%;background:var(--ground);color:var(--muted);- box-shadow:0 1px 1px rgba(0,0,0,.04),0 4px 4px rgba(0,0,0,.02);cursor:pointer}+.board-glow-toggle{position:relative;display:grid;place-items:center;width:36px;height:36px;flex:none;+ padding:0;border:0;border-radius:8px;background:transparent;color:var(--muted);cursor:pointer}.board-glow-toggle:hover{background:var(--hover);color:var(--ink)}.board-glow-toggle:focus-visible{outline:2px solid var(--tungsten);outline-offset:2px}-.board-glow-toggle svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2}-.board-glow-dot{position:absolute;right:2px;bottom:2px;width:10px;height:10px;border-radius:50%;+.board-glow-toggle svg{width:20px;height:20px;fill:currentColor;stroke:none}+.board-glow-dot{position:absolute;right:0;bottom:0;width:10px;height:10px;border-radius:50%;background:var(--glow-swatch,var(--ink));box-shadow:0 0 0 2px var(--ground)}.board-glow-menu{box-sizing:border-box;width:248px;max-width:calc(100vw - 32px);padding:10px;gap:0;border:1px solid var(--line);border-radius:24px;background:var(--ground);box-shadow:0 1px 1px rgba(0,0,0,.04),0 4px 4px rgba(0,0,0,.02)}@@ -953,8 +961,8 @@ html.board-high-contrast .settingscard.settingscard>.board-local-nav{background:.board-theme-toggle.is-dark .board-theme-thumb{transform:translateX(36px)}/* 侧栏收到 60px 时这一列竖着排。`column-reverse` 而不是 `column`:DOM 里明暗键在前,是为了展开态那一横排仍是「明暗在左、配色与设置在右」;竖排时要的顺序正好相反,- boardui.com 那一对就是配色在上、明暗在下。40px 的配色钮加上下各 10px 内边距正好- 占满 60px 侧栏的可用宽度,再宽一点就会挤到边框上。 */+ boardui.com 那一对就是配色在上、明暗在下。配色钮与设置钮都是 36px,左右各留 10px+ 内边距后在 60px 的侧栏里居中,两枚圆心落在同一条竖线上。 */@media(min-width:761px){.drawer:not(.open) .board-sidebar-foot{flex-direction:column-reverse;padding:12px 10px}.drawer:not(.open) .board-foot-actions{flex-direction:column}.drawer:not(.open) .board-theme-toggle{padding:2px;background:transparent}.drawer:not(.open) .board-theme-toggle button[aria-pressed=true],.drawer:not(.open) .board-theme-thumb{display:none}}@media(prefers-reduced-motion:reduce){.board-theme-thumb{transition:none}}.drawer .sec[data-sidebar-group]{border:0;padding:0;margin:4px 0 0}diff --git a/web/css/01-base.css b/web/css/01-base.cssindex 7ca1e7a32..1ff9d7743 100644--- a/web/css/01-base.css+++ b/web/css/01-base.css@@ -42,29 +42,29 @@字重同理只有 400/500/600 三档:vercel.com/design.md 明说不要自造数字字重,650、700 全部收到 600。 */--pill-radius:999px; --tag-radius:var(--pill-radius);--control-radius:6px; --badge-radius:4px; --floating-radius:12px; --surface-radius:8px; --tag-pad-y:4px; --tag-pad-x:10px; --hover-delay:5s;- /* 首页光晕的参数层。三枚光斑的颜色、圆心、椭圆尺寸和收边位置全部落在这里;+ /* 侧栏光晕的参数层。三枚光晕的颜色、椭圆尺寸和收边位置全部落在这里;`.glowlayer::before` 只引用变量,一个字面颜色都不写。这组默认值就是预设「钨丝暖阁」,- 和 app.js 里那一档一字不差,页面第一帧和 applyHomeGlow() 写完之后画面相同。- 这里给的是默认值,设置面板改的那一份由 app.js 写到 `.glowlayer` 自己的行内样式上,- 写在这一层而不是 <html> 上的理由记在下面那条规则里。+ 颜色与 js/home-glow.js 里那一档一字不差,页面第一帧和 applyHomeGlow() 写完之后画面相同。+ 只有颜色那三个由设置面板写到 `.glowlayer` 自己的行内样式上,写在这一层而不是 <html>+ 上的理由记在下面那条规则里;半轴和收边只有这一份,用户不调、也不进 localStorage。+ 圆心根本不在参数里:三枚光晕是侧栏玻璃面上那两团反光换成的,位置由 glowdrift 那两条+ 动画一直推着走,写死一个圆心等于把会动的光钉成一张贴图。存几何还有第二重代价——+ 旧版本那套横躺在页面顶部的坐标会原样跟着老用户留下来。+ 半轴的参照是一张两倍于侧栏的画布(和 board.css 里 --glass-drift-a/b 同一套算法),+ 20% 落到侧栏上就是 40%,跟着侧栏自己的长宽各向异性地拉成椭圆。--glow-lerp 是插值空间:默认空串等于按 sRGB 插,认得 `in oklab` 的引擎在下面那条@supports 里把它换成 `in oklab`。写成变量而不是把整段 background 抄第二遍,是因为两份三层渐变里任何一层改歪一个百分点都看不出来,而它们本该永远相同。 */- --glow-lerp: ; --glow-h:49vh;- --glow-spot-1-color:rgba(224,138,47,.62); --glow-spot-1-x:38%; --glow-spot-1-y:30%;- --glow-spot-1-w:46%; --glow-spot-1-h:76%; --glow-spot-1-fade:70%;- --glow-spot-2-color:rgba(196,84,74,.52); --glow-spot-2-x:22%; --glow-spot-2-y:10%;- --glow-spot-2-w:34%; --glow-spot-2-h:70%; --glow-spot-2-fade:72%;- --glow-spot-3-color:rgba(168,106,82,.52); --glow-spot-3-x:78%; --glow-spot-3-y:22%;- --glow-spot-3-w:40%; --glow-spot-3-h:72%; --glow-spot-3-fade:72%;+ --glow-lerp: ;+ --glow-spot-1-color:rgba(224,138,47,.62); --glow-spot-1-w:20%; --glow-spot-1-h:20%; --glow-spot-1-fade:72%;+ --glow-spot-2-color:rgba(196,84,74,.52); --glow-spot-2-w:26%; --glow-spot-2-h:26%; --glow-spot-2-fade:74%;+ --glow-spot-3-color:rgba(168,106,82,.52); --glow-spot-3-w:23%; --glow-spot-3-h:23%; --glow-spot-3-fade:73%;/* 强度是用户那一档,主题缩放是色板那一档,实际不透明度是两者相乘。- 三枚光斑直接落在页面底色上,深色底吃光、浅色那张白底反光,同一组颜色照搬到浅色会- 浓得压住顶栏文字,所以浅色把整层按同一个比例收下来,而不是另存一套颜色:用户挑的- 是同一片光,两个主题不该是两种东西。- 浅色这一档的 .6 是在浏览器里按首页截图逐档量出来的,判据是玻璃底下露出来的那块底- 色偏暖多少(红减蓝):.34 只有 4 级,一眼看过去和白页没区别;.6 是 7 级,光斑读得- 出来是三种颜色;再往上到 1 是 11 级,顶栏、侧栏和筛选条整片跟着泛米色,那时候有- 颜色的就不是光晕而是界面本身了。 */+ 深色侧栏那块玻璃吃光、浅色那块反光,同一组颜色照搬到浅色会浓得压住导航文字,所以+ 浅色把整层按同一个比例收下来,而不是另存一套颜色:用户挑的是同一片光,两个主题不该+ 是两种东西。这一档的 .6 是在浏览器里逐档量出来的,判据是玻璃面上那块底色偏暖多少+ (红减蓝):.34 只有 4 级,一眼看过去和没开一样;.6 是 7 级,三枚光晕读得出来是三种+ 颜色;到 1 是 11 级,整条侧栏跟着泛米色,那时候有颜色的就不是光而是侧栏本身了。 */--glow-noise:0; --glow-strength:1; --glow-theme-scale:.6;/* 一颗标签的脸只有这一张:--tag-radius 的圆角、一圈 --line、这块比面再沉一档的填充、--ink-2 的字。同一个词出现在卡片上、详情面板里、筛选条上和交集条里,读的人认的是@@ -162,36 +162,80 @@ body{background:var(--page);color:var(--ink);font-family:Roboto,"Segoe UI Variable Text","Segoe UI","Microsoft YaHei UI","PingFang SC",sans-serif;font-size:var(--fs-md);line-height:1.45;-webkit-font-smoothing:antialiased;font-variant-numeric:tabular-nums}-/* 光晕住在自己那枚空 div 上,而不是 `body` 的伪元素上,为的是把自定义属性的失效范围- 关在这一层里。自定义属性是继承的:往 <html> 或 <body> 上写一次 --glow-strength,整棵- 树都要重算样式。2026-09-16 在首页量过,判据是「写一次变量再强制 layout 的耗时」,取+/* 光晕住在侧栏里自己那枚空 div 上,而不是 `body` 的伪元素上,为的是把自定义属性的失效+ 范围关在这一层里。自定义属性是继承的:往 <html> 或 <body> 上写一次 --glow-strength,+ 整棵树都要重算样式。2026-09-16 在首页量过,判据是「写一次变量再强制 layout 的耗时」,取三轮每帧平均:写在 <html> 上 12.7–16.6ms(页面约 5800–6000 个节点),写一个根本没人引用的 --zzz-unused 同样是 15.0–16.2ms——这笔钱买的全是继承失效,和光晕怎么画无关;同一份代码写到一枚没有子节点的元素上是 0.09–0.10ms。拖拉条时每帧都要写一次,16.7ms 的帧预算里先扣掉 15ms,掉帧就是必然。`will-change:opacity` 也试过并量过:同样三轮 60 步合成拖动,提层后每帧间隔取最好一轮18.86ms、不提层 19.49ms,轮内波动本身就有 2ms 上下,这 0.6ms 读不出是效果,代价却是- 一整条 100vw × 49vh 的合成层常驻显存,所以不提。- 这一层本身不占位:高度为 0,两枚伪元素按 --topH 自己定位,页面其余部分的布局不受影响。- 三层都只引用 --glow-* 变量,这里一个颜色和一个坐标都不写死:用户在设置面板里换配色时,- 改的就是那组变量,规则本身不动。插值空间走 --glow-lerp。 */+ 一整块合成层常驻显存,所以不提。+ 三层都只引用 --glow-* 变量,这里一个颜色都不写死:用户在设置面板里换配色时,改的就是+ 那组变量,规则本身不动。插值空间走 --glow-lerp。++ 这一层画的就是侧栏玻璃面自带的那两团慢漂反光,换成用户配得了色的三枚。board.css 那条+ 玻璃规则把 --glass-drift-a/b 铺在每一块玻璃上,抽屉这一块交给这里来铺(那条规则里+ .drawer 的两个变量因此置为 none,两套光斑叠着漂会糊成一团);搜索框、筛选浮层、图标钮+ 那些玻璃面保持自己原来的漂移不动——它们身上那一点正是从侧栏折射过去的光。+ 正文身后什么都不铺:整条页面宽的光带是背景不是光晕,字压在上面读不出来。++ 位置不是参数,由 glowdriftx/glowdrifty 一直推着走,算法照搬 board.css 那两条:画布是+ 元素的两倍大,background-position 从 0% 到 100% 正好把光斑中心从右下角推到左上角,+ -10% 与 110% 那两档让它探出框外一点。三枚各走一条相位不同的李萨如轨迹,横竖两条动画+ 41s 与 67s 互质,合起来四十多分钟不重样。+ z-index 取 -2:.drawer 自己带 backdrop-filter,是一个层叠上下文,负层只压在它那块玻璃+ 填充之上、被导航内容全部盖住;-1 已经归了选中项那条 .navglide,光晕要在它下面。+ 溢出由 .drawer 的 overflow:hidden 连圆角一起裁掉,这一层不必自己再写一遍圆角。+ 首屏 ambient-in 那一下淡入留着:这一层一直在动,开页时从 0 亮起来读成「灯亮了」,+ 直接带着满强度出现反而像一张贴图突然贴上去。 */.glowlayer{--ambient-opacity:calc(var(--glow-strength) * var(--glow-theme-scale));- position:absolute;top:0;left:0;right:0;height:0;z-index:0;pointer-events:none}-.glowlayer::before{content:"";position:absolute;z-index:0;pointer-events:none;top:var(--topH);left:0;right:0;- height:var(--glow-h);opacity:var(--ambient-opacity);background:- radial-gradient(var(--glow-lerp) ellipse var(--glow-spot-1-w) var(--glow-spot-1-h) at var(--glow-spot-1-x) var(--glow-spot-1-y),var(--glow-spot-1-color),transparent var(--glow-spot-1-fade)),- radial-gradient(var(--glow-lerp) ellipse var(--glow-spot-2-w) var(--glow-spot-2-h) at var(--glow-spot-2-x) var(--glow-spot-2-y),var(--glow-spot-2-color),transparent var(--glow-spot-2-fade)),- radial-gradient(var(--glow-lerp) ellipse var(--glow-spot-3-w) var(--glow-spot-3-h) at var(--glow-spot-3-x) var(--glow-spot-3-y),var(--glow-spot-3-color),transparent var(--glow-spot-3-fade));- animation:ambient-in .8s ease .5s both}+ position:absolute;inset:0;z-index:-2;pointer-events:none}+.glowlayer::before{content:"";position:absolute;z-index:0;pointer-events:none;inset:0;+ opacity:var(--ambient-opacity);background:+ radial-gradient(var(--glow-lerp) var(--glow-spot-1-w) var(--glow-spot-1-h) at 50% 50%,var(--glow-spot-1-color),transparent var(--glow-spot-1-fade)),+ radial-gradient(var(--glow-lerp) var(--glow-spot-2-w) var(--glow-spot-2-h) at 50% 50%,var(--glow-spot-2-color),transparent var(--glow-spot-2-fade)),+ radial-gradient(var(--glow-lerp) var(--glow-spot-3-w) var(--glow-spot-3-h) at 50% 50%,var(--glow-spot-3-color),transparent var(--glow-spot-3-fade));+ background-size:200% 200%;background-repeat:no-repeat;+ background-position:50% 20%,80% 70%,20% 80%;+ animation:glowdriftx 41s linear infinite,glowdrifty 67s linear infinite,ambient-in .8s ease .5s both}+/* 三条轨迹是同一条李萨如曲线的三个相位:第一枚与 board.css 的 --glass-drift-a 同相,+ 第二枚是它的镜像,第三枚横向错四分之一周期、纵向错八分之一,三枚因此从不在同一处会合。 */+@keyframes glowdriftx{+ 0%{background-position-x:50%,50%,110%}+ 12.5%{background-position-x:7.6%,92.4%,92.4%}+ 25%{background-position-x:-10%,110%,50%}+ 37.5%{background-position-x:7.6%,92.4%,7.6%}+ 50%{background-position-x:50%,50%,-10%}+ 62.5%{background-position-x:92.4%,7.6%,7.6%}+ 75%{background-position-x:110%,-10%,50%}+ 87.5%{background-position-x:92.4%,7.6%,92.4%}+ 100%{background-position-x:50%,50%,110%}+}+@keyframes glowdrifty{+ 0%{background-position-y:-10%,50%,7.6%}+ 12.5%{background-position-y:7.6%,7.6%,50%}+ 25%{background-position-y:50%,-10%,92.4%}+ 37.5%{background-position-y:92.4%,7.6%,110%}+ 50%{background-position-y:110%,50%,92.4%}+ 62.5%{background-position-y:92.4%,92.4%,50%}+ 75%{background-position-y:50%,110%,7.6%}+ 87.5%{background-position-y:7.6%,92.4%,-10%}+ 100%{background-position-y:-10%,50%,7.6%}+}/* 认得 oklab 插值的引擎在这里才拿到它。反过来写——默认 `in oklab`、老引擎再关掉——的后果是老引擎把整条 background 判成无效,首页顶上一片光都没有,而不是退回 sRGB。 */@supports (background:linear-gradient(in oklab,red,blue)){:root{--glow-lerp:in oklab}}/* 颗粒感是可选的一层,默认强度 0 就是关。瓦片由 feTurbulence 当场生成,仓库里不落- 位图;overlay 只压在光晕上,正文和卡片都在它之后绘制,不受影响。 */-.glowlayer::after{content:"";position:absolute;z-index:0;pointer-events:none;top:var(--topH);left:0;right:0;- height:var(--glow-h);opacity:var(--glow-noise);mix-blend-mode:overlay;+ 位图;overlay 只压在光晕上,导航内容在它之后绘制,不受影响。 */+.glowlayer::after{content:"";position:absolute;z-index:0;pointer-events:none;inset:0;+ opacity:var(--glow-noise);mix-blend-mode:overlay;background:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='peachglowgrain'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23peachglowgrain)'/%3E%3C/svg%3E") 0 0/120px 120px repeat}@keyframes ambient-in{from{opacity:0}to{opacity:var(--ambient-opacity)}}+/* 跟着动效偏好走:一屋子的光一直在挪是这块玻璃读成实物的理由,但 prefers-reduced-motion+ 的人要的正是「别再动了」。停在当前那一帧,光还在,只是不动——整层关掉等于换了个配色。 */+@media (prefers-reduced-motion:reduce){.glowlayer::before{animation:ambient-in .8s ease .5s both}}.disp{font-family:Bahnschrift,"Segoe UI Variable Display","Microsoft YaHei UI",sans-serif;font-weight:600;letter-spacing:.02em}.mono{font-family:"Cascadia Mono",Consolas,ui-monospace,"Microsoft YaHei UI","PingFang SC",monospace;diff --git a/web/css/16-settings.css b/web/css/16-settings.cssindex 7497fd79b..8f7fb2f6f 100644--- a/web/css/16-settings.css+++ b/web/css/16-settings.css@@ -76,7 +76,7 @@ body.settings-open{overflow:hidden}.iconswitch.themeswitch svg{width:16px;height:16px}/* 手机上三枚圆各自撑到 44px 命中区,圆心间距跟着长,指头点得中。 */@media (max-width:760px){.iconswitch.themeswitch label{width:44px;height:44px}}-/* 首页光晕的参数区。它跟着上面那一行开关走,关掉就整块收起来——一组调不出任何效果的+/* 侧栏光晕的参数区。它跟着上面那一行开关走,关掉就整块收起来——一组调不出任何效果的拉条和色块留在原地,读的人只会以为是坏了。右边那 16px 外边距加 10px 内边距是这一块唯一的定位修正,不是留白偏好。Board 那一层@@ -90,17 +90,27 @@ body.settings-open{overflow:hidden}版式照 feralui.dev/gradients 的工作台面板:分组标题是一行小号灰字,参数行是「84px 标签 + 自绘拉条 + 等宽读数」,颜色行点开在自己下方弹一张色板。- 取证见 docs/reference-snapshots/feralui-studio-boardui-accent-measured.md。 */-.glowsetting{display:grid;gap:16px;margin-right:16px;padding:0 10px 14px 0;min-width:0}+ 取证见 docs/reference-snapshots/feralui-studio-boardui-accent-measured.md。++ 竖向节奏跟同一张卡里的设置行走同一份数:`board.css` 的+ `.settingscard .settingsscroll .settingrow` 是最小高 52px、上下各 10px 内边距。+ `--glowrow-min` / `--glowrow-pad` 就是那两个值,本块每一行都读它。这一块此前是三层+ gap(16 + 12 + 12)叠出来的间距,同一屏里「当前配色」到「强度」的落差和上面几行设置+ 之间的落差对不上,读起来像是中间漏了一条线。 */+.glowsetting{--glowrow-min:52px;--glowrow-pad:10px;+ display:grid;gap:0;margin-right:16px;padding:0 10px 14px 0;min-width:0}.glowsetting[hidden]{display:none}-.glowcurrent{display:flex;align-items:baseline;gap:8px;margin:0;color:var(--muted);font-size:var(--fs-sm)}+.glowcurrent{display:flex;align-items:center;gap:8px;margin:0;min-height:var(--glowrow-min);+ padding-block:var(--glowrow-pad);color:var(--muted);font-size:var(--fs-sm)}.glowcurrent b{color:var(--ink);font-weight:500}-.glowgroup{display:grid;gap:12px;min-width:0}+.glowgroup{display:grid;gap:0;min-width:0}/* 上游那一行是大写加宽字距的英文小标题,中文不大写:中文没有大小写,`text-transform`在这里什么也不做,字距倒是会把两个字拉散。 */-.glowgroup>h4{margin:0;color:var(--muted);font-size:var(--fs-xs);font-weight:600}-.glowfields{display:flex;flex-direction:column;gap:12px;min-width:0}-.glowfield{display:flex;align-items:center;gap:10px;min-width:0}+.glowgroup>h4{display:flex;align-items:center;min-height:var(--glowrow-min);+ padding-block:var(--glowrow-pad);margin:0;color:var(--muted);font-size:var(--fs-xs);font-weight:600}+.glowfields{display:flex;flex-direction:column;gap:0;min-width:0}+.glowfield{display:flex;align-items:center;gap:10px;min-height:var(--glowrow-min);+ padding-block:var(--glowrow-pad);min-width:0}.glowfieldlabel{flex:none;width:84px;color:var(--muted);font-size:var(--fs-xs);font-weight:600;white-space:nowrap}.glowfield .dial{flex:1;min-width:0}/* 颜色行:34px 圆点 + 名称与十六进制两行 + 行尾折角。相邻两行之间那条分隔线从圆点@@ -109,8 +119,9 @@ body.settings-open{overflow:hidden}.glowstop{position:relative;min-width:0}.glowstop+.glowstop::before{content:'';position:absolute;left:54px;right:6px;top:0;height:1px;background:linear-gradient(to right,var(--line-soft),transparent)}-.glowstopmain{display:flex;align-items:center;gap:10px;width:100%;min-height:54px;min-width:0;- padding:7px 7px 7px 8px;border:0;border-radius:var(--floating-radius);background:transparent;+.glowstopmain{display:flex;align-items:center;gap:10px;width:100%;min-width:0;+ min-height:var(--glowrow-min);padding:var(--glowrow-pad) 7px var(--glowrow-pad) 8px;+ border:0;border-radius:var(--floating-radius);background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer}.glowstopmain:hover{background:color-mix(in srgb,var(--ink) 3.2%,transparent)}.glowstopmain[aria-expanded="true"]{background:color-mix(in srgb,var(--ink) 4.6%,transparent)}@@ -146,7 +157,7 @@ body.settings-open{overflow:hidden}box-shadow:inset 0 1px 1px var(--frost-light),0 0 0 1.5px var(--ground),0 0 0 2.5px color-mix(in srgb,var(--ink) 30%,transparent)}.glowswatch:focus-visible{outline:2px solid var(--tungsten);outline-offset:2px}-.glowactions{display:flex;justify-content:flex-end}+.glowactions{display:flex;justify-content:flex-end;padding-top:var(--glowrow-pad)}/* 同一组里排在设置行后面的分区自带分隔线。线属于整块卡片,所以和 .settingrow 一样用负边距铺到框边,不在正文宽度里断一截。 */.settinggroup :is(.settingrow,.glowsetting)+.sidebarsetting{margin:0;padding:14px 0 0;diff --git a/web/index.html b/web/index.htmlindex ff785188a..6fc160bee 100644--- a/web/index.html+++ b/web/index.html@@ -33,10 +33,6 @@</script></head><body>-<!-- 首页光晕自己占一层。这一层存在的理由是失效范围:光晕参数是自定义属性,写在 <html>- 上等于让整棵树重算样式,拖一次强度拉条每帧要赔十几毫秒;写在这枚没有子节点的空 div- 上,失效范围就只剩它和它那两枚伪元素。怎么画仍然只在 web/css/01-base.css 一份。 -->-<div class="glowlayer" aria-hidden="true"></div><a class="skiplink" href="#main">跳到正文</a><!-- Lucide static 1.44.0, ISC. Local pinned subset; no CDN/runtime dependency.Climax uses Health Icons 2.0.0 sperm outline-24px, CC0/public domain.@@ -105,7 +101,6 @@<symbol id="i-monitor" viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2" /><line x1="8" x2="16" y1="21" y2="21" /><line x1="12" x2="12" y1="17" y2="21" /></symbol><symbol id="i-wrench" viewBox="0 0 24 24"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z" /></symbol><symbol id="i-folder-search" viewBox="0 0 24 24"><path d="M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1" /><path d="m21 21-1.9-1.9" /><circle cx="17" cy="17" r="3" /></symbol><symbol id="i-folder" viewBox="0 0 24 24"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" /></symbol><symbol id="i-folder-cog" viewBox="0 0 24 24"><path d="M10.3 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.98a2 2 0 0 1 1.69.9l.66 1.2A2 2 0 0 0 12 6h8a2 2 0 0 1 2 2v3.3" /><path d="m14.305 19.53.923-.382" /><path d="m15.228 16.852-.923-.383" /><path d="m16.852 15.228-.383-.923" /><path d="m16.852 20.772-.383.924" /><path d="m19.148 15.228.383-.923" /><path d="m19.53 21.696-.382-.924" /><path d="m20.772 16.852.924-.383" /><path d="m20.772 19.148.924.383" /><circle cx="18" cy="18" r="3" /></symbol><symbol id="i-sun" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4" /><path d="M12 2v2" /><path d="M12 20v2" /><path d="m4.93 4.93 1.41 1.41" /><path d="m17.66 17.66 1.41 1.41" /><path d="M2 12h2" /><path d="M20 12h2" /><path d="m6.34 17.66-1.41 1.41" /><path d="m19.07 4.93-1.41 1.41" /></symbol><symbol id="i-moon" viewBox="0 0 24 24"><path d="M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401" /></symbol>- <symbol id="i-swatch-book" viewBox="0 0 24 24"><path d="M11 17a4 4 0 0 1-8 0V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2Z" /><path d="M16.7 13H19a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H7" /><path d="M 7 17h.01" /><path d="m11 8 2.3-2.3a2.4 2.4 0 0 1 3.404.004L18.6 7.6a2.4 2.4 0 0 1 .026 3.434L9.9 19.8" /></symbol><symbol id="i-gauge" viewBox="0 0 24 24"><path d="m12 14 4-4" /><path d="M3.34 19a10 10 0 1 1 17.32 0" /></symbol><symbol id="i-theater-enter" viewBox="0 0 24 24"><rect x="2" y="3" width="20" height="18" rx="1.5"/><path d="M2 16h20M8.5 7 5.5 10l3 3M15.5 7l3 3-3 3"/></symbol><symbol id="i-theater-exit" viewBox="0 0 24 24"><rect x="2" y="3" width="20" height="18" rx="1.5"/><path d="M2 16h20M5.5 7l3 3-3 3M18.5 7l-3 3 3 3"/></symbol>@@ -239,7 +234,12 @@</main><div class="scrim" id="scrim"></div>-<aside class="drawer" id="drawer"><div class="drawerscroll" id="drawerScroll"></div></aside>+<!-- 光晕就是侧栏玻璃面上那两团慢慢漂的光换成用户自己配的三枚,所以它长在 .drawer 里面、+ 跟着抽屉的圆角一起被裁,正文身后一点都没有。单独占一层是因为失效范围:光晕参数是+ 自定义属性,写在 <html> 上等于让整棵树重算样式,拖一次强度拉条每帧要赔十几毫秒;+ 写在这枚没有子节点的空 div 上,失效范围就只剩它和它那两枚伪元素。+ 怎么画仍然只在 web/css/01-base.css 一份。 -->+<aside class="drawer" id="drawer"><div class="glowlayer" aria-hidden="true"></div><div class="drawerscroll" id="drawerScroll"></div></aside><div class="batchbar selectiondock" id="batchbar" role="group" aria-label="所选项目操作" hidden><span class="selectiondockcount" id="batchCount">已选 0 项</span><button data-batch="like"><svg viewBox="0 0 24 24"><use href="#i-thumbs-up"/></svg>喜欢</button><button data-batch="seen"><svg viewBox="0 0 24 24"><use href="#i-eye"/></svg>看过</button><button data-batch="later"><svg viewBox="0 0 24 24"><use href="#i-bookmark-plus"/></svg>稍后看</button><button data-batch-region><svg viewBox="0 0 24 24"><use href="#i-globe"/></svg>判定产地</button><button class="danger" data-batch="dispose"><svg viewBox="0 0 24 24"><use href="#i-trash"/></svg>移入回收站</button><button data-trash-only data-batch="restore"><svg viewBox="0 0 24 24"><use href="#i-rotate-ccw"/></svg>还原</button><button class="danger" data-trash-only data-batch="delete"><svg viewBox="0 0 24 24"><use href="#i-trash"/></svg>彻底删除</button>@@ -290,8 +290,8 @@<section class="settinggroup"><h3>界面</h3><div class="settingrow"><span><b>主题</b><small>跟随系统,或固定用浅色、深色。</small></span><div id="themeSetting"></div></div>- <label class="settingrow"><span><b>首页光晕</b><small id="homeGlowDescription">首页顶部那片彩色光。配色在左栏底部那枚圆钮上挑,这里调强度、颗粒和每一枚光斑。浅色主题按同一组颜色淡一档显示。</small></span><input type="checkbox" id="homeGlowSetting" class="ptoggle" role="switch" aria-describedby="homeGlowDescription"></label>- <section class="glowsetting" id="homeGlowControls" aria-label="首页光晕参数"></section>+ <label class="settingrow"><span><b>侧栏光晕</b><small id="homeGlowDescription">左栏玻璃面上那几团慢慢漂动的光。配色在左栏底部那枚配色钮上挑,这里调强度、颗粒和每一枚光晕的颜色。浅色主题按同一组颜色淡一档显示。</small></span><input type="checkbox" id="homeGlowSetting" class="ptoggle" role="switch" aria-describedby="homeGlowDescription"></label>+ <section class="glowsetting" id="homeGlowControls" aria-label="侧栏光晕参数"></section><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>diff --git a/web/js/home-glow.js b/web/js/home-glow.jsnew file mode 100644index 000000000..819c52e1f--- /dev/null+++ b/web/js/home-glow.js@@ -0,0 +1,120 @@+/* 侧栏光晕的纯数据层:参数模型、预设、命名色板、读回存量的规范化,以及把颜色写到+ 指定元素上的那一次绘制。没有页面装配,也不认识 `appSettings`、`$`、`saveSettings`+ 这些 app.js 的全局——侧栏那枚配色钮、它的弹层和设置面板的参数区仍旧留在 app.js。++ 拆出来是为了迁移时只搬一次:React 壳直接 import 这一份,不用把同一张预设表、同一+ 套色板和同一段规范化再抄进组件里。同一个道理,这里不从 `../dist/peach-ui.js` 借东西+ ——那是 React 的构建产物,它自己要 import 本文件,反向引用就闭成了一个环。+ `glowNumber` 与它的 `boundedPreference`(`frontend/src/number-setting.ts`)判据相同:+ 整数且落在区间里才算数,否则退回默认那一档。++ `paintHomeGlow` 只写传进来的那枚元素。写在 <html> 上整棵树都要重算样式,实测每帧+ 15ms 上下,拖拉条时帧预算当场就超;量法记在 web/css/01-base.css 那条规则上面。 */++/* 一档配色就是三枚光晕的颜色与不透明度;开关、强度和颗粒不属于配色,换档时不动。+ 椭圆半轴和收边位置不在这里,只有 web/css/01-base.css 一份,用户不调、也不存;圆心+ 根本不存在——三枚光晕由 glowdrift 那两条动画一直推着走,那是侧栏玻璃自带的漂移。+ 这个形状借自 feralui.dev/gradients 的 JSON 导出(登记在 docs/HANDOFF.md),只借参数+ 模型,渲染仍是那三层纯 CSS 径向渐变,不引入 Canvas。+ 三枚光晕各自向 transparent 收边,落在侧栏那块玻璃上,所以每一枚都得自己亮得起来:+ 压暗的那种颜色在深色侧栏上等于没有,在浅色侧栏上是一团脏。+ `amber` 是默认那一档,和 :root 上的默认值一字不差。 */+const HOME_GLOW_SPOTS=['spot1','spot2','spot3'];+const GLOW_SPOT_LABELS=['光晕一','光晕二','光晕三'];+const HOME_GLOW_PRESETS=[+ ['amber','钨丝暖阁',{+ spot1:{color:'#e08a2f',alpha:62},spot2:{color:'#c4544a',alpha:52},spot3:{color:'#a86a52',alpha:52}}],+ ['plum','夜樱',{+ spot1:{color:'#b455a0',alpha:64},spot2:{color:'#6a4fd0',alpha:54},spot3:{color:'#7a4f96',alpha:56}}],+ ['pine','深林',{+ spot1:{color:'#3f9e57',alpha:66},spot2:{color:'#7fae4a',alpha:48},spot3:{color:'#4f9463',alpha:56}}],+ ['ash','灰雾',{+ spot1:{color:'#8f98a4',alpha:52},spot2:{color:'#b6bcc4',alpha:38},spot3:{color:'#6f7783',alpha:50}}],+];+/* 手调过颜色之后当前档就不再是任何一个预设,侧栏那一格和面板顶上的标识要如实说这件事,+ 不能继续顶着上一档的名字。 */+const HOME_GLOW_CHOICES=[...HOME_GLOW_PRESETS.map(([key,label])=>[key,label]),['custom','自定义']];+const glowPresetName=key=>(HOME_GLOW_CHOICES.find(([name])=>name===key)||HOME_GLOW_CHOICES[0])[1];+const glowPalette=key=>structuredClone((HOME_GLOW_PRESETS.find(([name])=>name===key)||HOME_GLOW_PRESETS[0])[2]);+/* 挑颜色的那张色板。七个色系各六档明度,名字按颜色本身取,不按它被用在哪儿——同一枚+ 颜色换到另一枚光晕上还是同一个名字。十二枚预设色全部落在这张表里,所以从侧栏选完+ 预设再打开颜色弹层,选中环指得出当前那一格;表里缺哪一枚,那一枚就永远是「没选中」。+ 青绿整段不收:它在深色侧栏上发冷、在浅色侧栏上发脏,这块玻璃用不上。 */+const GLOW_SWATCH_FAMILIES=[['all','全部'],['gray','灰'],['red','红'],['yellow','黄'],+ ['green','绿'],['blue','蓝'],['purple','紫'],['brown','棕']];+const GLOW_SWATCHES=[+ ['gray','云灰','#d8dade'],['gray','雾灰','#b6bcc4'],['gray','石灰','#8f98a4'],+ ['gray','铁灰','#6f7783'],['gray','墨灰','#4a4e56'],['gray','深灰','#2e3138'],+ ['red','樱红','#f08a8a'],['red','珊瑚','#e26a62'],['red','砖红','#c4544a'],+ ['red','朱红','#b5322f'],['red','酒红','#8e2a2c'],['red','暗红','#6b2224'],+ ['yellow','麦黄','#f2d48a'],['yellow','琥珀','#e8b451'],['yellow','钨丝','#e08a2f'],+ ['yellow','金黄','#cf8a20'],['yellow','姜黄','#a9701c'],['yellow','栗黄','#7d5216'],+ ['green','嫩芽','#a9cf7e'],['green','叶绿','#7fae4a'],['green','草绿','#5da34f'],+ ['green','森绿','#3f9e57'],['green','苔绿','#4f9463'],['green','墨绿','#27563a'],+ ['blue','天蓝','#9fc2e8'],['blue','湖蓝','#6a9fd8'],['blue','靛蓝','#4478c0'],+ ['blue','宝蓝','#2f5ba3'],['blue','深蓝','#27467c'],['blue','夜蓝','#1c3358'],+ ['purple','丁香','#c3a7e0'],['purple','品红','#b455a0'],['purple','薰衣草','#a67fd2'],+ ['purple','葡萄','#6a4fd0'],['purple','茄紫','#7a4f96'],['purple','深紫','#432c6d'],+ ['brown','沙棕','#d6b492'],['brown','陶棕','#bd8f68'],['brown','赭棕','#a86a52'],+ ['brown','栗棕','#8c5340'],['brown','褐棕','#6d3f31'],['brown','深褐','#4e2d23'],+];+const glowNumber=(value,min,max,fallback)=>Number.isInteger(value)&&value>=min&&value<=max?value:fallback;+const glowColor=(value,fallback)=>/^#[0-9a-f]{6}$/i.test(String(value))?String(value).toLowerCase():fallback;+const glowRgba=(hex,alpha)=>`rgba(${[1,3,5].map(at=>parseInt(hex.slice(at,at+2),16)).join(',')},${(alpha/100).toFixed(2)})`;+const DEFAULT_HOME_GLOW={on:true,preset:'amber',strength:100,noise:0,...glowPalette('amber')};+/* 光晕参数整份来自 localStorage,形态和范围都不可信:颜色写成任意字符串会让那一层+ 渐变整条失效,百分比越界会把光晕糊成一整片或者缩没。逐项夹回区间、认不出就退回+ 默认那一档,而不是整份丢掉——一个坏掉的数不该把用户调好的其余几档一起清空。+ 只有一种情形要连颜色一起换掉:存着的档名已经不在清单里。那说明这一档被清退了,+ 留在旁边的三枚颜色正是被清退的那一版,按坏值逐项夹回去只会把它原样留在页面上。+ 自定义不在此列——那三枚颜色是用户自己挑的,档名认得出来,照样留着。+ 已经不存在的键不必单独清理:这里只按当前模型逐项取值,重建出来的对象里没有它们。+ 旧版本那套横躺在首页顶部的圆心与半轴就是这么掉的——几何现在只由 CSS 给,存过的那份+ 要是跟着夹回来,老用户看到的还是半截光。 */+function normalizeHomeGlow(raw){+ const stored=raw&&typeof raw==='object'?raw:{};+ const known=HOME_GLOW_CHOICES.some(([key])=>key===stored.preset);+ const preset=known?stored.preset:'amber';+ const seed=glowPalette(preset==='custom'?'amber':preset);+ const glow={on:stored.on!==false,preset,+ strength:glowNumber(+stored.strength,0,100,100),+ noise:glowNumber(+stored.noise,0,100,0)};+ for(const key of HOME_GLOW_SPOTS){+ const spot=known&&stored[key]&&typeof stored[key]==='object'?stored[key]:{},fallback=seed[key];+ glow[key]={color:glowColor(spot.color,fallback.color),+ alpha:glowNumber(+spot.alpha,0,100,fallback.alpha)};+ }+ return glow;+}+/* 预设圆球那一圈:几枚颜色就等分成几段。写成函数是因为自定义档的颜色数和预设一样多,+ 却要在弹层里现算一遍。 */+const glowChipFill=colors=>`conic-gradient(from -90deg,${colors.map((color,index)=>+ `${color} ${(index*100/colors.length).toFixed(3)}% ${((index+1)*100/colors.length).toFixed(3)}%`).join(',')})`;+/* 只写值,光晕怎么画留在 web/css/01-base.css 一份。关掉时强度和颗粒一起归零,+ `.glowlayer::before` 的不透明度按那句乘法算成 0,不另设一个「关」的分支——否则+ 「关着」和「强度 0」会是两条各自演化的路径。++ 写之前先和上一次写进这枚元素的值比一遍。这里有五个变量(强度、颗粒、三枚颜色),+ 拖强度那条拉条时变的只有一个;不比就是每一步把五个都重设一遍,中间那四次全是白写。+ 记账按元素分开存,多个壳各画各的那一层时不会互相把对方的值判成「已经写过」。 */+const glowWritten=new WeakMap();+function paintHomeGlow(el,glow){+ if(!el)return;+ let written=glowWritten.get(el);+ if(!written){written=new Map();glowWritten.set(el,written)}+ const live=glow.on;+ const write=(name,value)=>{+ if(written.get(name)===value)return;+ written.set(name,value);el.style.setProperty(name,value);+ };+ write('--glow-strength',String(live?glow.strength/100:0));+ write('--glow-noise',String(live?glow.noise/100:0));+ HOME_GLOW_SPOTS.forEach((key,index)=>{+ const spot=glow[key];+ write(`--glow-spot-${index+1}-color`,glowRgba(spot.color,spot.alpha));+ });+}++export {DEFAULT_HOME_GLOW, GLOW_SPOT_LABELS, GLOW_SWATCHES, GLOW_SWATCH_FAMILIES,+ HOME_GLOW_CHOICES, HOME_GLOW_PRESETS, HOME_GLOW_SPOTS,+ glowChipFill, glowColor, glowPalette, glowPresetName, normalizeHomeGlow, paintHomeGlow};diff --git a/web/vendor/remixicon-ORIGIN.md b/web/vendor/remixicon-ORIGIN.mdindex c78348934..fca48d10d 100644--- a/web/vendor/remixicon-ORIGIN.md+++ b/web/vendor/remixicon-ORIGIN.md@@ -3,4 +3,4 @@- npm 包:`[email protected]`- npm lock integrity:`sha512-36gLSoujkabnCFZFDyP17VNh9piuBA/rsXUb4auSJWLGsHVXtmxLj/EM5FjaEAGnk8oIAj1Azob/DZ2N+90lAQ==`- 许可证:Remix Icon License v1.0,见 `remixicon-LICENSE.txt`。-- 消费者:设置导航六枚内联 symbol。完整候选由本地 HTML 审查。+- 消费者:设置导航六枚内联 symbol,其中 `palette-line` 同时给侧栏底部那枚配色钮。完整候选由本地 HTML 审查。