An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Center the lock screen clock and refine glass panels https://github.com/siyuan-note/siyuan/issues/20797
Daniel203ce10d8133
diff --git a/app/electron/remote-auth.html b/app/electron/remote-auth.htmlindex 2c32fa0c4c..3c38d7b162 100644--- a/app/electron/remote-auth.html+++ b/app/electron/remote-auth.html@@ -89,15 +89,35 @@@supports (backdrop-filter: blur(16px)) or (-webkit-backdrop-filter: blur(16px)) {body.has-wallpaper main {- background: rgba(255, 255, 255, .9);+ --auth-text-outline: transparent;+ background: rgba(255, 255, 255, .5);+ color: #111;box-shadow: 0 8px 32px rgba(0, 0, 0, .16), inset 0 0 0 1px rgba(255, 255, 255, .4);- -webkit-backdrop-filter: blur(16px);- backdrop-filter: blur(16px);+ -webkit-backdrop-filter: blur(16px) saturate(110%);+ backdrop-filter: blur(16px) saturate(110%);+ }++ body.has-wallpaper #origin {+ color: #111;+ opacity: 1;+ }++ body.has-wallpaper main h1,+ body.has-wallpaper main label,+ body.has-wallpaper #origin {+ text-shadow: -.35px 0 0 var(--auth-text-outline), .35px 0 0 var(--auth-text-outline),+ 0 -.35px 0 var(--auth-text-outline), 0 .35px 0 var(--auth-text-outline);}@media (prefers-color-scheme: dark) {body.has-wallpaper main {- background: rgba(30, 30, 30, .9);+ --auth-text-outline: #000;+ background: rgba(0, 0, 0, .28);+ color: #fff;+ }++ body.has-wallpaper #origin {+ color: #f4f6fa;}}}@@ -113,6 +133,8 @@@media (prefers-color-scheme: dark) {body.has-wallpaper main {background: #1e1e1e;+ -webkit-backdrop-filter: none;+ backdrop-filter: none;}}}@@ -170,7 +192,7 @@}#lockScreenCover {- align-items: flex-start;+ align-items: center;background: transparent;border: 0;box-sizing: border-box;@@ -179,15 +201,15 @@display: flex;flex-direction: column;font: inherit;- height: calc(100% - 32px);- justify-content: flex-end;+ height: 100%;+ justify-content: center;left: 0;margin: 0;- padding: 24px clamp(24px, 6vw, 96px) max(40px, 12vh);+ padding: 32px 24px;position: fixed;- text-align: left;+ text-align: center;text-shadow: 0 2px 8px #000, 0 0 24px #000;- top: 32px;+ top: 0;width: 100%;z-index: 2;}@@ -201,6 +223,13 @@outline-offset: -8px;}+ #lockScreenClock {+ align-items: center;+ display: flex;+ flex-direction: column;+ max-width: 100%;+ }+#lockScreenTime {font-size: clamp(48px, 9vw, 112px);font-variant-numeric: tabular-nums;@@ -213,8 +242,11 @@}#lockScreenHint {+ bottom: clamp(16px, 6vh, 48px);font-size: 14px;- margin-top: 24px;+ left: 16px;+ position: absolute;+ right: 16px;}body.wallpaper-cover main {@@ -230,8 +262,10 @@<body><img id="lockScreenWallpaper" alt="" hidden><button id="lockScreenCover" type="button" aria-labelledby="lockScreenHint" hidden>- <time id="lockScreenTime" aria-live="off"></time>- <span id="lockScreenDate"></span>+ <span id="lockScreenClock">+ <time id="lockScreenTime" aria-live="off"></time>+ <span id="lockScreenDate"></span>+ </span><span id="lockScreenHint"></span></button><div id="windowBar"><button id="closeWindow" type="button">×</button></div>diff --git a/app/stage/auth.html b/app/stage/auth.htmlindex 82aae6843a..0edf8d3026 100644--- a/app/stage/auth.html+++ b/app/stage/auth.html@@ -224,14 +224,27 @@@supports (backdrop-filter: blur(16px)) or (-webkit-backdrop-filter: blur(16px)) {body.has-wallpaper #authPanel {- background-color: rgba(255, 255, 255, .9);+ --auth-text-outline: transparent;+ --b3-theme-on-background: #111;+ --b3-theme-on-surface: #111;+ background-color: rgba(255, 255, 255, .5);box-shadow: 0 8px 32px rgba(0, 0, 0, .16), inset 0 0 0 1px rgba(255, 255, 255, .4);- -webkit-backdrop-filter: blur(16px);- backdrop-filter: blur(16px);+ -webkit-backdrop-filter: blur(16px) saturate(110%);+ backdrop-filter: blur(16px) saturate(110%);}.dark body.has-wallpaper #authPanel {- background-color: rgba(30, 30, 30, .9);+ --auth-text-outline: #000;+ --b3-theme-on-background: #fff;+ --b3-theme-on-surface: #f4f6fa;+ background-color: rgba(0, 0, 0, .28);+ }++ body.has-wallpaper #authPanel h1,+ body.has-wallpaper #authPanel label,+ body.has-wallpaper #authPanel .ft__on-surface {+ text-shadow: -.35px 0 0 var(--auth-text-outline), .35px 0 0 var(--auth-text-outline),+ 0 -.35px 0 var(--auth-text-outline), 0 .35px 0 var(--auth-text-outline);}}@@ -246,7 +259,7 @@}#lockScreenCover {- align-items: flex-start;+ align-items: center;background: transparent;border: 0;box-sizing: border-box;@@ -255,15 +268,15 @@display: flex;flex-direction: column;font: inherit;- height: calc(100% - 32px);- justify-content: flex-end;+ height: 100%;+ justify-content: center;left: 0;margin: 0;- padding: 24px clamp(24px, 6vw, 96px) max(40px, 12vh);+ padding: 32px 24px;position: fixed;- text-align: left;+ text-align: center;text-shadow: 0 2px 8px #000, 0 0 24px #000;- top: 32px;+ top: 0;width: 100%;z-index: 2;}@@ -277,6 +290,13 @@outline-offset: -8px;}+ #lockScreenClock {+ align-items: center;+ display: flex;+ flex-direction: column;+ max-width: 100%;+ }+#lockScreenTime {font-size: clamp(48px, 9vw, 112px);font-variant-numeric: tabular-nums;@@ -289,8 +309,11 @@}#lockScreenHint {+ bottom: clamp(16px, 6vh, 48px);font-size: 14px;- margin-top: 24px;+ left: 16px;+ position: absolute;+ right: 16px;}#authPanel h1 {@@ -318,8 +341,10 @@<body><img id="lockScreenWallpaper" alt="" hidden><button id="lockScreenCover" type="button" aria-labelledby="lockScreenHint" hidden>- <time id="lockScreenTime" aria-live="off"></time>- <span id="lockScreenDate"></span>+ <span id="lockScreenClock">+ <time id="lockScreenTime" aria-live="off"></time>+ <span id="lockScreenDate"></span>+ </span><span id="lockScreenHint">{{.lockScreenReveal}}</span></button><div data-auth-drag style="-webkit-app-region: drag;height: 32px;width: 100%;position: absolute;top: 0;z-index: 3;"></div>diff --git a/app/tests/lockScreenWallpaperLayout.test.js b/app/tests/lockScreenWallpaperLayout.test.jsindex 2fd60fb5a6..2c82b38a06 100644--- a/app/tests/lockScreenWallpaperLayout.test.js+++ b/app/tests/lockScreenWallpaperLayout.test.js@@ -107,10 +107,24 @@ const checkLayout = async (wallpaperPresent, dark, remote, glass = true) => {check.equal(cover.hidden, false);check.ok(document.getElementById("lockScreenTime").textContent);check.ok(document.getElementById("lockScreenDate").textContent);+ const group = document.getElementById("lockScreenClock").getBoundingClientRect();const clock = document.getElementById("lockScreenTime").getBoundingClientRect();+ const date = document.getElementById("lockScreenDate").getBoundingClientRect();const hint = document.getElementById("lockScreenHint").getBoundingClientRect();- check.ok(clock.left >= 0 && hint.right <= innerWidth && hint.bottom <= innerHeight,+ check.ok(clock.left >= 0 && clock.right <= innerWidth && date.left >= 0 && date.right <= innerWidth &&+ hint.left >= 0 && hint.right <= innerWidth && hint.bottom <= innerHeight,"clock and reveal hint fit narrow and short screens");+ check.ok(Math.abs((group.left + group.right) / 2 - innerWidth / 2) < 1 &&+ Math.abs((group.top + group.bottom) / 2 - innerHeight / 2) < 1,+ "time and date are centered together in the viewport");+ check.ok(Math.abs((clock.left + clock.right) / 2 - innerWidth / 2) < 1 &&+ Math.abs((date.left + date.right) / 2 - innerWidth / 2) < 1,+ "time and date each align with the horizontal center");+ check.ok(hint.top > group.bottom && Math.abs((hint.left + hint.right) / 2 - innerWidth / 2) < 1,+ "reveal hint stays centered below the clock without overlapping it");+ const drag = document.querySelector(remote ? "#windowBar" : "[data-auth-drag]");+ check.ok(drag.contains(document.elementFromPoint(innerWidth / 2, 16)),+ "the top window drag area remains above the cover");cover.click();check.equal(panel.inert, false);check.equal(cover.hidden, true);@@ -125,28 +139,43 @@ const checkLayout = async (wallpaperPresent, dark, remote, glass = true) => {check.ok(rect.top >= 32 && rect.bottom <= innerHeight, "login panel fits below the drag area");check.ok(panel.scrollWidth <= panel.clientWidth, "login controls do not overflow the panel");check.equal(style.backgroundColor, forcedColors ? getComputedStyle(document.body).backgroundColor : (glass ?- (dark ? "rgba(30, 30, 30, 0.9)" : "rgba(255, 255, 255, 0.9)") :+ (dark ? "rgba(0, 0, 0, 0.28)" : "rgba(255, 255, 255, 0.5)") :(dark ? "rgb(30, 30, 30)" : "rgb(255, 255, 255)")));- check.equal(blur, glass ? "blur(16px)" : "none");+ check.equal(blur, glass ? "blur(16px) saturate(1.1)" : "none");check.equal(style.opacity, "1", "glass affects the panel background, not its text and controls");check.equal(getComputedStyle(document.getElementById("authCode")).opacity, "1");- // 将面板底色与纯黑、纯白壁纸合成,检查正文和小字号说明的最差对比度。+ // 更薄的玻璃使用反色细描边辅助阅读,同时检查壁纸合成色与描边的对比度。const luminance = rgb => rgb.map(value => value / 255).map(value =>value <= .04045 ? value / 12.92 : ((value + .055) / 1.055) ** 2.4).reduce((sum, value, index) => sum + value * [.2126, .7152, .0722][index], 0);- const text = panel.querySelector(remote ? "label" : ".ft__on-surface");- const textStyle = getComputedStyle(text);- const foreground = textStyle.color.match(/[\d.]+/g).map(Number);- const alpha = (foreground[3] ?? 1) * Number(textStyle.opacity);- for (const wallpaperColor of [0, 255]) {- if (forcedColors) break;- const base = dark ? 30 : 255;- const background = Array(3).fill(glass ? base * .9 + wallpaperColor * .1 : base);- const color = foreground.slice(0, 3).map((value, index) => value * alpha + background[index] * (1 - alpha));- const values = [luminance(background), luminance(color)];- const contrast = (Math.max(...values) + .05) / (Math.min(...values) + .05);- check.ok(contrast >= 4.5,- `small login text contrast ${contrast} over wallpaper ${wallpaperColor} (dark=${dark}, remote=${remote}, glass=${glass})`);+ const panelColor = style.backgroundColor.match(/[\d.]+/g).map(Number);+ const panelAlpha = panelColor[3] ?? 1;+ const brightness = Number(/brightness\(([\d.]+)\)/.exec(blur)?.[1] ?? 1);+ const selectors = remote ? ["h1", "label", ...(glass ? ["#origin"] : [])] : [".ft__on-surface", "label", "h1"];+ for (const selector of forcedColors ? [] : selectors) {+ const textStyle = getComputedStyle(panel.querySelector(selector));+ const foreground = textStyle.color.match(/[\d.]+/g).map(Number);+ const alpha = (foreground[3] ?? 1) * Number(textStyle.opacity);+ let outlineContrast = 0;+ if (glass && dark) {+ const outline = dark ? "rgb(0, 0, 0)" : "rgb(255, 255, 255)";+ check.equal(textStyle.textShadow, ["-0.35px 0px 0px", "0.35px 0px 0px",+ "0px -0.35px 0px", "0px 0.35px 0px"].map(offset => `${outline} ${offset}`).join(", "));+ const outlineLight = dark ? 0 : 1;+ const foregroundLight = luminance(foreground.slice(0, 3));+ outlineContrast = (Math.max(outlineLight, foregroundLight) + .05) /+ (Math.min(outlineLight, foregroundLight) + .05);+ check.ok(outlineContrast >= 4.5, "the text outline remains distinct from its fill");+ }+ for (const wallpaperColor of [0, 255]) {+ const background = panelColor.slice(0, 3).map(value =>+ value * panelAlpha + Math.min(255, wallpaperColor * brightness) * (1 - panelAlpha));+ const color = foreground.slice(0, 3).map((value, index) => value * alpha + background[index] * (1 - alpha));+ const values = [luminance(background), luminance(color)];+ const contrast = (Math.max(...values) + .05) / (Math.min(...values) + .05);+ check.ok(Math.max(contrast, outlineContrast) >= 4.5,+ `${selector} contrast ${contrast} over wallpaper ${wallpaperColor} (dark=${dark}, remote=${remote}, glass=${glass})`);+ }}panel.scrollTop = panel.scrollHeight;const last = panel.querySelector(remote ? "#submit" : ".b3-button--white").getBoundingClientRect();@@ -177,12 +206,13 @@ const prepareKeyboardCase = async () => {});};-const assertKeyboardState = (value, submits) => {+const assertKeyboardState = async (value, submits) => {+ await new Promise(resolve => requestAnimationFrame(resolve));const check = require("node:assert/strict");check.equal(document.getElementById("lockScreenCover").hidden, true);check.equal(document.getElementById("authCode").value, value);check.equal(document.activeElement, document.getElementById("authCode"));- check.equal(window.testSubmits, submits);+ check.equal(window.testSubmits, submits, "native Enter events reach the revealed login form");};if (process.versions.electron && process.type === "browser") {