Peach: Local-first video metadata scraper and media manager.
perf(web): 明暗切换那圈扩散换成渐变遮罩
longmeidaoe63367751084
diff --git a/frontend/src/sidebar-groups.ts b/frontend/src/sidebar-groups.tsindex 8dedcfda2..361c6f85f 100644--- a/frontend/src/sidebar-groups.ts+++ b/frontend/src/sidebar-groups.ts@@ -32,8 +32,11 @@ export async function transitionTheme(button:HTMLElement,apply:()=>void):Promiseif(!document.startViewTransition||matchMedia('(prefers-reduced-motion: reduce)').matches){apply();return}const rect=button.getBoundingClientRect(),x=rect.left+rect.width/2,y=rect.top+rect.height/2;const size=Math.hypot(Math.max(x,innerWidth-x),Math.max(y,innerHeight-y))*2.5;- const mask=`url("data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><filter id="b" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="2"/></filter></defs><circle cx="50" cy="50" r="42" fill="white" filter="url(#b)"/></svg>')}")`;- const style=document.createElement('style');style.textContent=`::view-transition-old(root){animation:none}::view-transition-new(root){mix-blend-mode:normal;mask-image:${mask};mask-repeat:no-repeat;animation:peach-theme-reveal 820ms cubic-bezier(.16,1,.3,1) both}@keyframes peach-theme-reveal{from{mask-position:${x}px ${y}px;mask-size:0px 0px}to{mask-position:${x-size/2}px ${y-size/2}px;mask-size:${size}px ${size}px}}`;+ /* 柔边那一圈由一段 CSS 渐变画,不套 SVG:遮罩的尺寸每一帧都在变,每一帧就要照新+ 尺寸把它重新光栅化一遍,而一张带高斯模糊滤镜的 SVG 每次都要连滤镜一起重跑。+ 渐变没有这一层,边缘的过渡带靠色标位置给。 */+ const mask='radial-gradient(circle closest-side,#000 78%,#0006 88%,transparent)';+ const style=document.createElement('style');style.textContent=`::view-transition-old(root){animation:none}::view-transition-new(root){mix-blend-mode:normal;mask-image:${mask};mask-repeat:no-repeat;will-change:mask-position,mask-size;animation:peach-theme-reveal 560ms cubic-bezier(.16,1,.3,1) both}@keyframes peach-theme-reveal{from{mask-position:${x}px ${y}px;mask-size:0px 0px}to{mask-position:${x-size/2}px ${y-size/2}px;mask-size:${size}px ${size}px}}`;themeChanging=true;document.head.append(style);try{await document.startViewTransition(apply).finished}catch{apply()}finally{style.remove();themeChanging=false}}diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex ae7e0e1b9..db94b2fac 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -7681,6 +7681,21 @@ class WebUiSourceTests(unittest.TestCase):# 关掉动效时两档弹簧一起归零,剩下的是瞬时到位。self.assertIn("--board-motion:0s;--board-dialog-motion:0s;--spring-pane-ms:0;--spring-press-ms:0}", board)+ def test_the_theme_sweep_masks_with_a_gradient_instead_of_a_filtered_svg(self):+ """明暗切换那圈扩散用一段 CSS 渐变当遮罩,柔边靠色标位置给。++ 遮罩的尺寸每一帧都在变,每一帧就要照新尺寸把它重新光栅化一遍。一张挂着高斯+ 模糊滤镜的 SVG 每次都得连滤镜一起重跑,整屏那么大的一层,一次切换要跑几十遍;+ 渐变没有这一层。柔边本身要留着——一条硬边扫过整屏,读出来是一块板在推。+ """+ source = (Path(__file__).resolve().parents[1]+ / "frontend/src/sidebar-groups.ts").read_text(encoding="utf-8")+ self.assertIn("const mask='radial-gradient(circle closest-side,"+ "#000 78%,#0006 88%,transparent)';", source)+ self.assertNotIn("feGaussianBlur", source)+ self.assertIn("will-change:mask-position,mask-size;"+ "animation:peach-theme-reveal 560ms cubic-bezier(.16,1,.3,1) both}", source)+def test_the_sidebar_current_item_is_a_pane_of_glass_that_slides_down_the_rail(self):"""侧栏的当前项是压在侧栏那块玻璃上的又一块玻璃,它在这一列里滑。diff --git a/web/dist/peach-ui.js b/web/dist/peach-ui.jsindex 83658d622..7655aceb2 100644--- a/web/dist/peach-ui.js+++ b/web/dist/peach-ui.js@@ -1699,7 +1699,7 @@ async function Cn(e, t) {return;}let n = e.getBoundingClientRect(), r = n.left + n.width / 2, i = n.top + n.height / 2, a = Math.hypot(Math.max(r, innerWidth - r), Math.max(i, innerHeight - i)) * 2.5, o = document.createElement("style");- o.textContent = `::view-transition-old(root){animation:none}::view-transition-new(root){mix-blend-mode:normal;mask-image:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20100%20100%22%3E%3Cdefs%3E%3Cfilter%20id%3D%22b%22%20x%3D%22-50%25%22%20y%3D%22-50%25%22%20width%3D%22200%25%22%20height%3D%22200%25%22%3E%3CfeGaussianBlur%20stdDeviation%3D%222%22%2F%3E%3C%2Ffilter%3E%3C%2Fdefs%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2242%22%20fill%3D%22white%22%20filter%3D%22url(%23b)%22%2F%3E%3C%2Fsvg%3E");mask-repeat:no-repeat;animation:peach-theme-reveal 820ms cubic-bezier(.16,1,.3,1) both}@keyframes peach-theme-reveal{from{mask-position:${r}px ${i}px;mask-size:0px 0px}to{mask-position:${r - a / 2}px ${i - a / 2}px;mask-size:${a}px ${a}px}}`, Sn = !0, document.head.append(o);+ o.textContent = `::view-transition-old(root){animation:none}::view-transition-new(root){mix-blend-mode:normal;mask-image:radial-gradient(circle closest-side,#000 78%,#0006 88%,transparent);mask-repeat:no-repeat;will-change:mask-position,mask-size;animation:peach-theme-reveal 560ms cubic-bezier(.16,1,.3,1) both}@keyframes peach-theme-reveal{from{mask-position:${r}px ${i}px;mask-size:0px 0px}to{mask-position:${r - a / 2}px ${i - a / 2}px;mask-size:${a}px ${a}px}}`, Sn = !0, document.head.append(o);try {await document.startViewTransition(t).finished;} catch {