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: Animate lock screen transitions and preserve input https://github.com/siyuan-note/siyuan/issues/20797
Daniele378d1022294
diff --git a/app/electron/remote-auth.html b/app/electron/remote-auth.htmlindex 3c38d7b162..00053e3756 100644--- a/app/electron/remote-auth.html+++ b/app/electron/remote-auth.html@@ -87,32 +87,31 @@}}- @supports (backdrop-filter: blur(16px)) or (-webkit-backdrop-filter: blur(16px)) {+ @supports (backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px)) {body.has-wallpaper main {- --auth-text-outline: transparent;- background: rgba(255, 255, 255, .5);- color: #111;+ --auth-text-outline: #000;+ background: rgba(255, 255, 255, .08);+ color: #fff;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) saturate(110%);- backdrop-filter: blur(16px) saturate(110%);+ -webkit-backdrop-filter: blur(8px) saturate(105%);+ backdrop-filter: blur(8px) saturate(105%);}body.has-wallpaper #origin {- color: #111;+ color: #f4f6fa;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);+ text-shadow: 0 1px 3px var(--auth-text-outline);}@media (prefers-color-scheme: dark) {body.has-wallpaper main {--auth-text-outline: #000;- background: rgba(0, 0, 0, .28);+ background: rgba(0, 0, 0, .06);color: #fff;}@@ -124,12 +123,19 @@@media (prefers-reduced-transparency: reduce), (forced-colors: active) {body.has-wallpaper main {+ --auth-text-outline: transparent;background: #fff;+ color: inherit;box-shadow: none;-webkit-backdrop-filter: none;backdrop-filter: none;}+ body.has-wallpaper #origin {+ color: inherit;+ opacity: .7;+ }+@media (prefers-color-scheme: dark) {body.has-wallpaper main {background: #1e1e1e;@@ -206,6 +212,7 @@left: 0;margin: 0;padding: 32px 24px;+ pointer-events: none;position: fixed;text-align: center;text-shadow: 0 2px 8px #000, 0 0 24px #000;@@ -228,6 +235,8 @@display: flex;flex-direction: column;max-width: 100%;+ opacity: var(--auth-clock-open-opacity, 0);+ transform: translateY(var(--auth-clock-open-y, -24px)) scale(.65);}#lockScreenTime {@@ -247,10 +256,60 @@left: 16px;position: absolute;right: 16px;+ opacity: 0;+ visibility: hidden;}body.wallpaper-cover main {- visibility: hidden;+ opacity: 0;+ pointer-events: none;+ transform: translateY(20px);+ }++ body.has-wallpaper {+ --auth-motion-duration: 200ms;+ overflow: hidden;+ }++ body.wallpaper-cover #lockScreenCover {+ pointer-events: auto;+ }++ body.wallpaper-cover #lockScreenClock {+ opacity: 1;+ transform: none;+ }++ body.wallpaper-cover #lockScreenHint {+ opacity: 1;+ visibility: visible;+ }++ body.wallpaper-transition main {+ transition: opacity var(--auth-motion-duration) ease, transform var(--auth-motion-duration) ease;+ }++ body.wallpaper-transition #lockScreenClock {+ transition: opacity var(--auth-motion-duration) cubic-bezier(.16, 1, .3, 1),+ transform var(--auth-motion-duration) cubic-bezier(.16, 1, .3, 1);+ }++ body.wallpaper-transition.wallpaper-cover #lockScreenClock {+ transition-timing-function: cubic-bezier(.7, 0, .84, 0);+ }++ body.wallpaper-transition #lockScreenHint {+ transition: opacity var(--auth-motion-duration) ease, visibility 0s var(--auth-motion-duration);+ }++ body.wallpaper-transition.wallpaper-cover #lockScreenHint {+ transition-delay: 0s, 0s;+ }++ @media (prefers-reduced-motion: reduce) {+ body.has-wallpaper {+ --auth-motion-duration: 0ms;+ }}body.has-wallpaper h1 {@@ -288,14 +347,19 @@const loadLockScreenWallpaper = () => {const wallpaper = document.getElementById("lockScreenWallpaper");const cover = document.getElementById("lockScreenCover");+ const clock = document.getElementById("lockScreenClock");const panel = document.getElementById("authPanel") || document.querySelector("main");let pending = true;let interacted = false;+ let covered = false;+ let composing = false;+ let clockShown = false;+ let resumeTarget;let clockTimer;const focusInput = () => {- const input = document.getElementById("authCode");- const target = input && !input.disabled && input.getClientRects().length ? input :- Array.from(panel.querySelectorAll("button:not(:disabled), a[href]")).find(item => item.getClientRects().length);+ const candidates = [resumeTarget, document.getElementById("authCode"),+ ...panel.querySelectorAll("button:not(:disabled), a[href]")];+ const target = candidates.find(item => item && !item.disabled && item.getClientRects().length);target?.focus({preventScroll: true});return target;};@@ -303,6 +367,13 @@clearInterval(clockTimer);clockTimer = undefined;};+ const positionClock = () => {+ const height = clock.offsetHeight * .65;+ const top = panel.offsetTop - 16 - height;+ clockShown = top >= 40;+ cover.style.setProperty("--auth-clock-open-y", `${clockShown ? top + height / 2 - window.innerHeight / 2 : -24}px`);+ cover.style.setProperty("--auth-clock-open-opacity", clockShown ? "1" : "0");+ };const updateClock = () => {const now = new Date();const time = document.getElementById("lockScreenTime");@@ -310,84 +381,106 @@time.dateTime = now.toISOString();document.getElementById("lockScreenDate").textContent = now.toLocaleDateString(undefined,{weekday: "long", month: "long", day: "numeric"});+ positionClock();};const refreshClock = () => {stopClock();- if (!cover.hidden && !document.hidden) {+ if (!wallpaper.hidden && !document.hidden) {updateClock();- clockTimer = setInterval(updateClock, 1000);+ if (covered || clockShown) clockTimer = setInterval(updateClock, 1000);}};+ const setCovered = show => {+ covered = show;+ cover.inert = !show;+ cover.setAttribute("aria-hidden", String(!show));+ panel.inert = show;+ document.body.classList[show ? "add" : "remove"]("wallpaper-cover");+ refreshClock();+ };const reveal = () => {interacted = true;- if (cover.hidden) return pending ? focusInput() : undefined;- cover.hidden = true;- panel.inert = false;- document.body.classList.remove("wallpaper-cover");- stopClock();+ if (!covered) return pending ? focusInput() : undefined;+ document.body.classList.add("wallpaper-transition");+ setCovered(false);return focusInput();};+ const conceal = () => {+ if (wallpaper.hidden || covered) return false;+ const active = document.activeElement;+ resumeTarget = panel.contains(active) ? active : undefined;+ document.body.classList.add("wallpaper-transition");+ setCovered(true);+ cover.focus({preventScroll: true});+ return true;+ };cover.addEventListener("click", reveal);document.addEventListener("pointerdown", event => {if (event.target.closest("#windowBar, [data-auth-drag]")) return;- if (!cover.hidden) event.preventDefault();+ if (covered) event.preventDefault();reveal();}, true);document.addEventListener("keydown", event => {+ if (event.key === "Escape") {+ if (event.isComposing || composing || event.keyCode === 229 || event.ctrlKey || event.metaKey || event.altKey) return;+ if (conceal()) {+ event.preventDefault();+ event.stopImmediatePropagation();+ }+ return;+ }if ((event.ctrlKey || event.metaKey) && !event.altKey && event.key.toLowerCase() === "v") {reveal();return;}const altGraph = event.getModifierState?.("AltGraph");if ((event.ctrlKey || event.metaKey || event.altKey) && !altGraph) return;- const covered = !cover.hidden;+ const wasCovered = covered;const target = reveal();- if (!covered || event.isComposing || event.key === "Process" || event.key === "Dead") return;- // 唤起按键不触发登录;可直接输入的首字符只写入密码框一次。- if (target?.type === "password" && Array.from(event.key).length === 1 && event.key !== " ") {+ if (!wasCovered || event.isComposing || event.key === "Process" || event.key === "Dead") return;+ // 唤起按键不触发登录;可直接输入的首字符只写入当前输入框一次。+ if ((target?.type === "password" || target?.type === "text") && Array.from(event.key).length === 1 && event.key !== " ") {target.setRangeText(event.key, target.selectionStart, target.selectionEnd, "end");target.dispatchEvent(new Event("input", {bubbles: true}));}event.preventDefault();event.stopImmediatePropagation();}, true);- document.addEventListener("compositionstart", reveal, true);+ document.addEventListener("compositionstart", () => { composing = true; reveal(); }, true);+ document.addEventListener("compositionend", () => { composing = false; }, true);document.addEventListener("visibilitychange", refreshClock);+ window.addEventListener("resize", refreshClock);window.addEventListener("pagehide", stopClock);window.addEventListener("pageshow", refreshClock);wallpaper.onload = () => {pending = false;wallpaper.hidden = false;+ cover.hidden = false;document.body.classList.add("has-wallpaper");const background = document.getElementById("authDefaultBackground");if (background) background.hidden = true;// 慢加载不打断已经开始的输入,也不遮住密码管理器填入的内容。- if (!interacted && !document.getElementById("authCode")?.value) {- cover.hidden = false;- panel.inert = true;- document.body.classList.add("wallpaper-cover");- refreshClock();- cover.focus({preventScroll: true});- } else if (!interacted) {- focusInput();- }+ setCovered(!interacted && !document.getElementById("authCode")?.value);+ if (covered) cover.focus({preventScroll: true});+ else if (!interacted) focusInput();};wallpaper.onerror = () => {pending = false;- const covered = !cover.hidden;- const shouldFocus = !interacted;- reveal();+ const shouldFocus = !interacted || covered;wallpaper.hidden = true;- document.body.classList.remove("has-wallpaper");+ cover.hidden = true;+ setCovered(false);+ document.body.classList.remove("has-wallpaper", "wallpaper-transition");const background = document.getElementById("authDefaultBackground");if (background) background.hidden = false;- if (!covered && shouldFocus) focusInput();+ if (shouldFocus) focusInput();};wallpaper.src = "/api/system/getLockScreenWallpaper";return {focus: () => {if (pending) return;- if (cover.hidden) focusInput();- else cover.focus({preventScroll: true});+ refreshClock();+ if (covered) cover.focus({preventScroll: true});+ else focusInput();}};};const lockScreenWallpaperState = loadLockScreenWallpaper();diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201004194026-s8h2cog.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201004194026-s8h2cog.syindex bcd6251656..9c5a45b23f 100644--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201004194026-s8h2cog.sy+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201004194026-s8h2cog.sy@@ -6,7 +6,7 @@"id": "20201004194026-s8h2cog","title": "Use on browser","type": "doc",- "updated": "20261022203227"+ "updated": "20261024102323"},"Children": [{@@ -15,7 +15,7 @@"HeadingLevel": 2,"Properties": {"id": "20210104091447-8iiuxlt",- "updated": "20261016112115"+ "updated": "20261024102323"},"Children": [{@@ -277,7 +277,7 @@"HeadingLevel": 3,"Properties": {"id": "20210104091447-dluat0m",- "updated": "20261016112115"+ "updated": "20261024102323"},"Children": [{@@ -352,7 +352,7 @@"Type": "NodeParagraph","Properties": {"id": "20261022093855-9vgq1sq",- "updated": "20261022203227"+ "updated": "20261024102323"},"Children": [{@@ -393,7 +393,20 @@},{"Type": "NodeText",- "Data": ", upload one JPEG, PNG or WebP image (up to 10 MiB and 16 megapixels) to customize the authentication page shown at startup and after locking. Uploading another image replaces it; click Reset to restore the default background. With a custom wallpaper, the authentication page first shows the wallpaper and local time. Click, tap, or press a key to reveal the login panel; typing your password also keeps the first character. Without a wallpaper, or if the image fails to load, the usual login page appears directly."+ "Data": ", upload one JPEG, PNG or WebP image (up to 10 MiB and 16 megapixels) to customize the authentication page shown at startup and after locking. Uploading another image replaces it; click Reset to restore the default background. The wallpaper setting is shown when a password is configured or OIDC sign-in is enabled. With a custom wallpaper, the authentication page first shows the wallpaper and local time. Click, tap, or press a key to reveal the login panel; typing your password also keeps the first character. Without a wallpaper, or if the image fails to load, the usual login page appears directly."+ },+ {+ "Type": "NodeText",+ "Data": " Press "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Esc"+ },+ {+ "Type": "NodeText",+ "Data": " to return from the login panel to the wallpaper and clock. Your password and captcha input are kept. Both directions use a short transition; the system preference to reduce motion is respected."}]},diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201004184819-nj8ibyg.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201004184819-nj8ibyg.syindex 8cab234f63..305c818af8 100644--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201004184819-nj8ibyg.sy+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201004184819-nj8ibyg.sy@@ -6,7 +6,7 @@"id": "20201004184819-nj8ibyg","title": "在浏览器上使用","type": "doc",- "updated": "20261022203227"+ "updated": "20261024102323"},"Children": [{@@ -15,7 +15,7 @@"HeadingLevel": 2,"Properties": {"id": "20210104090909-6pyfjgx",- "updated": "20261016112115"+ "updated": "20261024102323"},"Children": [{@@ -284,7 +284,7 @@"HeadingLevel": 3,"Properties": {"id": "20210104090909-9x9sqe8",- "updated": "20261016112115"+ "updated": "20261024102323"},"Children": [{@@ -352,7 +352,7 @@"Type": "NodeParagraph","Properties": {"id": "20261022093855-t2z1xoy",- "updated": "20261022203227"+ "updated": "20261024102323"},"Children": [{@@ -393,7 +393,20 @@},{"Type": "NodeText",- "Data": " 中上传一张 JPEG、PNG 或 WebP 图片(最大 10 MiB、1600 万像素),即可自定义启动和锁屏后的认证页背景。上传新图片会替换旧图片,点击“重置”恢复默认背景。使用自定义壁纸时,认证页先显示壁纸和本机时间;点击、触摸屏幕或按键后显示登录面板。直接键入密码时,首个字符也会进入密码框。未设置壁纸或图片加载失败时,直接显示原有登录界面。"+ "Data": " 中上传一张 JPEG、PNG 或 WebP 图片(最大 10 MiB、1600 万像素),即可自定义启动和锁屏后的认证页背景。上传新图片会替换旧图片,点击“重置”恢复默认背景。设置密码或启用 OIDC 登录后显示壁纸设置项。使用自定义壁纸时,认证页先显示壁纸和本机时间;点击、触摸屏幕或按键后显示登录面板。直接键入密码时,首个字符也会进入密码框。未设置壁纸或图片加载失败时,直接显示原有登录界面。"+ },+ {+ "Type": "NodeText",+ "Data": "登录面板显示后,按 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Esc"+ },+ {+ "Type": "NodeText",+ "Data": " 返回壁纸和时间,已输入的密码与验证码会保留。进入和返回均有简短过渡动画;系统开启减少动态效果时直接切换。"}]},diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122523-rl8356a.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122523-rl8356a.syindex 7644275fb2..b6a92927c8 100644--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122523-rl8356a.sy+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122523-rl8356a.sy@@ -6,7 +6,7 @@"id": "20211226122523-rl8356a","title": "在瀏覽器上使用","type": "doc",- "updated": "20261022203227"+ "updated": "20261024102323"},"Children": [{@@ -15,7 +15,7 @@"HeadingLevel": 2,"Properties": {"id": "20211226122545-a65v8e1",- "updated": "20261016112115"+ "updated": "20261024102323"},"Children": [{@@ -273,7 +273,7 @@"HeadingLevel": 3,"Properties": {"id": "20211226122545-lsv6dhu",- "updated": "20261016112115"+ "updated": "20261024102323"},"Children": [{@@ -337,7 +337,7 @@"Type": "NodeParagraph","Properties": {"id": "20261022093855-oc11gow",- "updated": "20261022203227"+ "updated": "20261024102323"},"Children": [{@@ -378,7 +378,20 @@},{"Type": "NodeText",- "Data": " 中上傳一張 JPEG、PNG 或 WebP 圖片(最大 10 MiB、1600 萬像素),即可自訂啟動及鎖定後的驗證頁面背景。上傳新圖片會取代舊圖片,點擊「重置」恢復預設背景。使用自訂桌布時,驗證頁面先顯示桌布與本機時間;點擊、觸控畫面或按鍵後顯示登入面板。直接輸入密碼時,第一個字元也會進入密碼欄位。未設定桌布或圖片載入失敗時,直接顯示原有登入介面。"+ "Data": " 中上傳一張 JPEG、PNG 或 WebP 圖片(最大 10 MiB、1600 萬像素),即可自訂啟動及鎖定後的驗證頁面背景。上傳新圖片會取代舊圖片,點擊「重置」恢復預設背景。設定密碼或啟用 OIDC 登入後顯示桌布設定項目。使用自訂桌布時,驗證頁面先顯示桌布與本機時間;點擊、觸控畫面或按鍵後顯示登入面板。直接輸入密碼時,第一個字元也會進入密碼欄位。未設定桌布或圖片載入失敗時,直接顯示原有登入介面。"+ },+ {+ "Type": "NodeText",+ "Data": "登入面板顯示後,按 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Esc"+ },+ {+ "Type": "NodeText",+ "Data": " 返回桌布與時間,已輸入的密碼及驗證碼會保留。進入與返回均有簡短過渡動畫;系統開啟減少動態效果時直接切換。"}]},diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-40hohog.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-40hohog.syindex 761e44d2c4..295e72f02f 100644--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-40hohog.sy+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-40hohog.sy@@ -7,7 +7,7 @@"id": "20240530101000-40hohog","title": "ブラウザ","type": "doc",- "updated": "20261022203227"+ "updated": "20261024102323"},"Children": [{@@ -17,7 +17,7 @@"Properties": {"ID": "20240530101000-vn1tvf6","id": "20240530101000-yllodqo",- "updated": "20261016112115"+ "updated": "20261024102323"},"Children": [{@@ -300,7 +300,7 @@"Properties": {"ID": "20240530101000-zvy840s","id": "20240530101000-b6ssy52",- "updated": "20261016112115"+ "updated": "20261024102323"},"Children": [{@@ -369,7 +369,7 @@"Type": "NodeParagraph","Properties": {"id": "20261022093855-2gm31el",- "updated": "20261022203227"+ "updated": "20261024102323"},"Children": [{@@ -406,7 +406,20 @@},{"Type": "NodeText",- "Data": " で JPEG、PNG、WebP の画像を1枚アップロードすると(最大 10 MiB、1600万画素)、起動時やロック後の認証画面の背景を変更できます。新しい画像をアップロードすると置き換わります。「リセット」で既定の背景に戻せます。カスタム壁紙を設定すると、認証ページに壁紙と端末の時刻が先に表示されます。クリック、タップ、キー操作でログインパネルを表示します。パスワードを直接入力すると、最初の文字も入力欄に入ります。壁紙が未設定の場合や画像の読み込みに失敗した場合は、通常のログイン画面を直接表示します。"+ "Data": " で JPEG、PNG、WebP の画像を1枚アップロードすると(最大 10 MiB、1600万画素)、起動時やロック後の認証画面の背景を変更できます。新しい画像をアップロードすると置き換わります。「リセット」で既定の背景に戻せます。パスワードの設定後、または OIDC ログインを有効にすると、壁紙の設定項目が表示されます。カスタム壁紙を設定すると、認証ページに壁紙と端末の時刻が先に表示されます。クリック、タップ、キー操作でログインパネルを表示します。パスワードを直接入力すると、最初の文字も入力欄に入ります。壁紙が未設定の場合や画像の読み込みに失敗した場合は、通常のログイン画面を直接表示します。"+ },+ {+ "Type": "NodeText",+ "Data": "ログインパネルの表示中に "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Esc"+ },+ {+ "Type": "NodeText",+ "Data": " を押すと壁紙と時刻の画面に戻り、入力済みのパスワードと画像認証コードは保持されます。表示と復帰には短いアニメーションが付き、システムで視差効果を減らす設定が有効な場合は直接切り替わります。"}]},diff --git a/app/src/config/setting/mount.test.ts b/app/src/config/setting/mount.test.tsindex 1251a16587..5761dc6c9a 100644--- a/app/src/config/setting/mount.test.ts+++ b/app/src/config/setting/mount.test.ts@@ -5,6 +5,43 @@ import {test} from "node:test";import {runInNewContext} from "node:vm";import {ModuleKind, ScriptTarget, transpileModule} from "typescript";+test("mobile authentication settings refresh after focus leaves and preserve scroll", async () => {+ const code = transpileModule(readFileSync("src/config/setting/mount.ts", "utf8"), {+ compilerOptions: {module: ModuleKind.CommonJS},+ }).outputText;+ const input = {};+ const root = {innerHTML: "authentication", scrollTop: 123, scrollLeft: 0,+ contains: (target: object) => target === input, querySelector: (): Element | null => null};+ const listeners = new Map<string, () => void>();+ const timers: Array<() => void> = [];+ let mounted = 0;+ const document = {activeElement: input,+ querySelector: (selector: string) => {+ assert.equal(selector, '#modelMain > .config[data-setting-tab="access"]');+ return root;+ },+ addEventListener: (name: string, callback: () => void) => listeners.set(name, callback)};+ const exports = {} as {remountOpenSettingTab: (tab: string) => Promise<void>};+ runInNewContext(code, {exports, document, window: {siyuan: {dialogs: []}},+ setTimeout: (callback: () => void) => timers.push(callback),+ require: () => ({Constants: {DIALOG_SETTING: "settings"}, getSettingsOwnerApp: () => ({}),+ getSettingTab: (id: string) => ({mount: async (element: typeof root, _search: unknown, _app: unknown, rebuild: boolean) => {+ assert.equal(id, "access");+ assert.equal(rebuild, true);+ mounted++;+ element.scrollTop = 0;+ }})}),+ });+ await exports.remountOpenSettingTab("access");+ assert.equal(mounted, 0);+ document.activeElement = {};+ listeners.get("focusout")();+ timers.splice(0).forEach(callback => callback());+ await new Promise(resolve => setImmediate(resolve));+ assert.equal(mounted, 1);+ assert.equal(root.scrollTop, 123);+});+for (const keywords of ["", "gradient"]) {test(`remount restores scroll after asynchronous initialization and search (keywords=${keywords})`, async () => {const source = readFileSync(resolve(process.cwd(), "src/config/setting/mount.ts"), "utf8");diff --git a/app/src/config/setting/mount.ts b/app/src/config/setting/mount.tsindex 3d50e06ec7..41ebb0bd5a 100644--- a/app/src/config/setting/mount.ts+++ b/app/src/config/setting/mount.ts@@ -47,10 +47,8 @@ export const mountSettingTab = async (tabId: string, root: HTMLElement) => {/** 设置面板已打开且对应 Tab 已挂载时,重新 register 并整页替换 */export const remountOpenSettingTab = async (tabId: TSettingTab) => {const dialogElement = window.siyuan.dialogs.find((d) => d.element.getAttribute("data-key") === Constants.DIALOG_SETTING)?.element;- if (!dialogElement) {- return;- }- const root = dialogElement.querySelector(`.config__tab-container[data-name="${tabId}"]`) as HTMLElement | null;+ const root = (dialogElement?.querySelector(`.config__tab-container[data-name="${tabId}"]`) ||+ document.querySelector(`#modelMain > .config[data-setting-tab="${tabId}"]`)) as HTMLElement | null;if (!root?.innerHTML) {return;}@@ -69,7 +67,7 @@ export const remountOpenSettingTab = async (tabId: TSettingTab) => {}deferredTabs.delete(tabId);const search: Partial<SettingTabMountContext> = {};- const keywords = getSearchKeywordsLower(dialogElement);+ const keywords = dialogElement ? getSearchKeywordsLower(dialogElement) : "";const tab = getSettingTab(tabId);if (keywords) {const result = tab.scanSearch(keywords);diff --git a/app/src/config/setting/sync.test.ts b/app/src/config/setting/sync.test.tsindex 505edf0577..3a4de4b926 100644--- a/app/src/config/setting/sync.test.ts+++ b/app/src/config/setting/sync.test.ts@@ -341,7 +341,7 @@ for (const mobile of [false, true]) {assert.equal(config.oidc.clientSecret, "******");assert.equal(config.oidc.enabled, true);assert.equal(config.accessAuthCode, "******");- assert.deepEqual(remounted, mobile ? [] : ["app", "access"]);+ assert.deepEqual(remounted, mobile ? ["access"] : ["app", "access"]);remounted.length = 0;await exports.refreshSettingConfig("system");assert.deepEqual(remounted, mobile ? [] : ["app"]);@@ -349,12 +349,12 @@ for (const mobile of [false, true]) {next = {...next, system: {...next.system, encryptedNotebookFollowSystemLock: true}};await exports.refreshSettingConfig("system");assert.equal(config.system.encryptedNotebookFollowSystemLock, true);- assert.deepEqual(remounted, mobile ? [] : ["app", "access"]);+ assert.deepEqual(remounted, mobile ? ["access"] : ["app", "access"]);remounted.length = 0;next = {...next, api: {token: "latest-token"}};await exports.refreshSettingConfig();assert.equal(config.api.token, "latest-token");- assert.equal(remounted.filter(tab => tab === "access").length, mobile ? 0 : 1);+ assert.equal(remounted.filter(tab => tab === "access").length, 1);failed = true;next = {...next, api: {token: "unconfirmed-token"}};await assert.rejects(exports.refreshSettingConfig("system"), /Could not refresh settings/);diff --git a/app/src/config/setting/sync.ts b/app/src/config/setting/sync.tsindex 7676ae624e..542a1f2ef3 100644--- a/app/src/config/setting/sync.ts+++ b/app/src/config/setting/sync.ts@@ -10,9 +10,9 @@ import {syncSettingTasks} from "./taskBlocker";import {processSync} from "../../dialog/processSystem";import {notifyOCRChanged} from "../ocrRuntime";import {refreshMountedBazaar} from "../bazaarTab";+import {remountOpenSettingTab} from "./mount";/// #if !MOBILEimport {applyKeymap} from "../tabs/keymapRuntime";-import {remountOpenSettingTab} from "./mount";import {getSettingTabDefs, type TSettingTab} from "./tabs";/// #endif@@ -135,6 +135,8 @@ const applySettingConfig = async (next: Config.IConf, namespaces: Set<string>) =}if (accessChanged) remountTabs.add("access");remountTabs.forEach(tab => { void remountOpenSettingTab(tab); });+ /// #else+ if (accessChanged) void remountOpenSettingTab("access");/// #endif};diff --git a/app/src/config/tabs/accessTab.test.ts b/app/src/config/tabs/accessTab.test.tsindex 76adfac873..a08311102f 100644--- a/app/src/config/tabs/accessTab.test.ts+++ b/app/src/config/tabs/accessTab.test.ts@@ -5,6 +5,63 @@ import {runInNewContext} from "node:vm";import {ModuleKind, ScriptTarget, transpileModule} from "typescript";import {ContractFormData} from "../../util/contractFormData";+test("wallpaper settings require password or OIDC authentication on desktop, web and mobile", () => {+ const compiled = transpileModule(readFileSync("src/config/tabs/accessTab.ts", "utf8") ++ "\nexport {registerAccessAuthGroup};", {+ compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2021},+ }).outputText;+ for (const browser of [false, true]) {+ for (const mobile of [false, true]) {+ for (const readonly of [false, true]) {+ for (const password of ["", "password"]) {+ for (const oidc of [false, true]) {+ const slots: string[] = [];+ const appearance = {lockScreenWallpaper: true};+ const exports = {} as {registerAccessAuthGroup: (tab: unknown) => void};+ runInNewContext(compiled, {exports, require: () => ({+ isBrowser: () => browser, isInMobileApp: () => mobile,+ getHostCapabilities: () => ({oidcAuthentication: true}),+ }), window: {siyuan: {config: {readonly, accessAuthCode: password,+ oidc: {enabled: oidc}, api: {token: "token"}, appearance}, languages: {about14: "${token}"}}}});+ exports.registerAccessAuthGroup({group: () => ({+ button: () => {}, switch: () => {}, text: () => {},+ slot: (spec: {key: string}) => slots.push(spec.key),+ })});+ assert.equal(slots.includes("lockScreenWallpaper"), !readonly && Boolean(password || oidc),+ JSON.stringify({browser, mobile, readonly, password: Boolean(password), oidc}));+ assert.equal(appearance.lockScreenWallpaper, true, "hiding the setting preserves the wallpaper");+ }+ }+ }+ }+ }+});++test("OIDC activation refreshes the wallpaper setting without waiting for its configuration notification", () => {+ const compiled = transpileModule(readFileSync("src/config/tabs/accessTab.ts", "utf8") ++ "\nexport {registerAccessAuthGroup, applyActivatedOIDC};", {+ compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2021},+ }).outputText;+ const config = {readonly: false, accessAuthCode: "", oidc: {enabled: false}, api: {token: "token"}};+ const slots: string[] = [];+ const tab = {group: () => ({button: () => {}, switch: () => {}, text: () => {},+ slot: (spec: {key: string}) => slots.push(spec.key)})};+ const exports = {} as {registerAccessAuthGroup: (tab: unknown) => void; applyActivatedOIDC: (config: unknown) => void};+ runInNewContext(compiled, {exports, window: {siyuan: {config, languages: {about14: "${token}"}}}, require: () => ({+ isBrowser: () => false, isInMobileApp: () => false,+ getHostCapabilities: () => ({oidcAuthentication: true}),+ remountOpenSettingTab: (id: string) => {+ assert.equal(id, "access");+ exports.registerAccessAuthGroup(tab);+ },+ })});+ exports.registerAccessAuthGroup(tab);+ assert.equal(slots.includes("lockScreenWallpaper"), false);+ exports.applyActivatedOIDC({enabled: true});+ assert.equal(config.oidc.enabled, true);+ assert.equal(slots.includes("lockScreenWallpaper"), true);+});+test("encrypted notebook system lock is offered only for supported local desktop kernels", () => {const compiled = transpileModule(readFileSync("src/config/tabs/accessTab.ts", "utf8") +"\nexport {registerEncryptedNotebookGroup};", {diff --git a/app/src/config/tabs/accessTab.ts b/app/src/config/tabs/accessTab.tsindex 2f62dc9552..d379f158be 100644--- a/app/src/config/tabs/accessTab.ts+++ b/app/src/config/tabs/accessTab.ts@@ -28,6 +28,7 @@ import zxcvbn = require("zxcvbn");import {canOpenExternalURL, getHostCapabilities} from "../../util/hostCapabilities";import {openNotebookArchiveDialog, openNotebookArchiveImportDialog} from "../notebookArchive";import {genLockScreenWallpaperHtml, mountLockScreenWallpaper} from "./lockScreenWallpaper";+import {remountOpenSettingTab} from "../setting/mount";const getPasswordStrength = (password: string) => {const score = zxcvbn(password).score;@@ -80,7 +81,7 @@ const registerAccessAuthGroup = (tab: SettingTabBuilder) => {save: (value) => sendAppSetting("system.lockScreenMode", value),});}- if (!window.siyuan.config.readonly) {+ if (!window.siyuan.config.readonly && (window.siyuan.config.accessAuthCode || window.siyuan.config.oidc.enabled)) {group.slot({key: "lockScreenWallpaper",keywords: [window.siyuan.languages.lockScreenWallpaper, window.siyuan.languages.lockScreenWallpaperTip],@@ -107,6 +108,11 @@ const registerAccessAuthGroup = (tab: SettingTabBuilder) => {});};+const applyActivatedOIDC = (config: Config.IOIDC) => {+ window.siyuan.config.oidc = config;+ void remountOpenSettingTab("access");+};+const mountOIDCButton = (root: HTMLElement) => {if (!getHostCapabilities().oidcAuthentication) {return;@@ -351,7 +357,7 @@ const mountOIDCButton = (root: HTMLElement) => {}validationPollToken = "";restoreMobileCallback();- window.siyuan.config.oidc = activation.data.config;+ applyActivatedOIDC(activation.data.config);showMessage(window.siyuan.languages.oidcVerificationSuccess);dialog.destroy();} catch (error) {diff --git a/app/src/mobile/menu/settingPanel.test.ts b/app/src/mobile/menu/settingPanel.test.tsnew file mode 100644index 0000000000..42ebc203ac--- /dev/null+++ b/app/src/mobile/menu/settingPanel.test.ts@@ -0,0 +1,36 @@+import * as assert from "node:assert/strict";+import {readFileSync} from "node:fs";+import {test} from "node:test";+import {runInNewContext} from "node:vm";+import {ModuleKind, transpileModule} from "typescript";++test("mobile authentication panels rebuild conditional settings when reopened", async () => {+ const compiled = transpileModule(readFileSync("src/mobile/menu/settingPanel.ts", "utf8"), {+ compilerOptions: {module: ModuleKind.CommonJS},+ }).outputText;+ for (const id of ["access", "appearance"]) {+ let options: {html: string; bindEvent: (element: unknown) => void};+ let rebuilt: boolean;+ let watched = 0;+ const root = {isConnected: true, querySelector: (): Element | null => null, classList: {toggle: () => {}}};+ const app = {};+ const exports = {} as {openSettingTab: (app: unknown, tab: unknown) => void};+ runInNewContext(compiled, {exports, require: () => ({+ isMobile: () => true,+ openModel: (value: typeof options) => { options = value; },+ bindSettingSaveDelegation: () => {},+ watchSettingTabInteractions: () => { watched++; },+ getSettingTab: () => ({mount: async (element: unknown, _search: unknown, owner: unknown, rebuild: boolean) => {+ assert.equal(element, root);+ assert.equal(owner, app);+ rebuilt = rebuild;+ }}),+ })});+ exports.openSettingTab(app, {id, title: "Settings"});+ assert.ok(options.html.includes(`data-setting-tab="${id}"`));+ options.bindEvent({firstElementChild: root});+ await Promise.resolve();+ assert.equal(watched, 1);+ assert.equal(rebuilt, id === "access");+ }+});diff --git a/app/src/mobile/menu/settingPanel.ts b/app/src/mobile/menu/settingPanel.tsindex b2ae20fcae..e8a8ef0ff0 100644--- a/app/src/mobile/menu/settingPanel.ts+++ b/app/src/mobile/menu/settingPanel.ts@@ -10,6 +10,7 @@ import {clearAccessTabElement} from "../../config/tabs/accessRuntime";import {unmountAssetsTab} from "../../config/assets";import {unmountOCRTab} from "../../config/ocr";import {unmountWorkspaceStorage} from "../../config/tabs/workspaceStorage";+import {watchSettingTabInteractions} from "../../config/setting/mount";/** 卸载设置页中持有全局状态的模块,避免容器被替换后残留副作用 */export const unmountSettingTab = (root: HTMLElement, tabId: TSettingTab) => {@@ -36,12 +37,13 @@ export const openSettingTab = (app: App, settingTabDef: ISettingTabShell<TSettintitle: settingTabDef.title,icon: "iconLeft",hideCloseIcon: true,- html: `<div class="config${isMobile() ? " config--mobile" : ""}"></div>`,+ html: `<div class="config${isMobile() ? " config--mobile" : ""}" data-setting-tab="${settingTabDef.id}"></div>`,bindEvent(modelMainElement: HTMLElement) {root = modelMainElement.firstElementChild as HTMLElement;+ watchSettingTabInteractions();bindSettingSaveDelegation(root);const mountedRoot = root;- void getSettingTab(settingTabDef.id).mount(mountedRoot, undefined, app).then(() => {+ void getSettingTab(settingTabDef.id).mount(mountedRoot, undefined, app, settingTabDef.id === "access").then(() => {if (mountedRoot.isConnected) {mountedRoot.classList.toggle("config--mobile-items", Boolean(mountedRoot.querySelector(":scope > .config-group")));} else {diff --git a/app/stage/auth.html b/app/stage/auth.htmlindex 0edf8d3026..a6c94d840f 100644--- a/app/stage/auth.html+++ b/app/stage/auth.html@@ -222,35 +222,43 @@width: 480px;}- @supports (backdrop-filter: blur(16px)) or (-webkit-backdrop-filter: blur(16px)) {+ @supports (backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px)) {body.has-wallpaper #authPanel {- --auth-text-outline: transparent;- --b3-theme-on-background: #111;- --b3-theme-on-surface: #111;- background-color: rgba(255, 255, 255, .5);+ --auth-text-outline: #000;+ --auth-panel-text: #fff;+ --auth-panel-secondary: #f4f6fa;+ background-color: rgba(255, 255, 255, .08);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) saturate(110%);- backdrop-filter: blur(16px) saturate(110%);+ -webkit-backdrop-filter: blur(8px) saturate(105%);+ backdrop-filter: blur(8px) saturate(105%);}.dark body.has-wallpaper #authPanel {- --auth-text-outline: #000;- --b3-theme-on-background: #fff;- --b3-theme-on-surface: #f4f6fa;- background-color: rgba(0, 0, 0, .28);+ background-color: rgba(0, 0, 0, .06);+ }++ body.has-wallpaper #authPanel .ft__on-surface {+ color: var(--auth-panel-secondary);+ }++ body.has-wallpaper #authPanel .ft__on-surface a {+ color: inherit;+ text-decoration: underline;}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);+ text-shadow: 0 1px 3px var(--auth-text-outline);}}@media (prefers-reduced-transparency: reduce), (forced-colors: active) {body.has-wallpaper #authPanel,.dark body.has-wallpaper #authPanel {+ --auth-text-outline: transparent;+ --auth-panel-text: var(--b3-theme-on-background);+ --auth-panel-secondary: var(--b3-theme-on-surface);background-color: var(--b3-theme-background);box-shadow: none;-webkit-backdrop-filter: none;@@ -273,6 +281,7 @@left: 0;margin: 0;padding: 32px 24px;+ pointer-events: none;position: fixed;text-align: center;text-shadow: 0 2px 8px #000, 0 0 24px #000;@@ -295,6 +304,8 @@display: flex;flex-direction: column;max-width: 100%;+ opacity: var(--auth-clock-open-opacity, 0);+ transform: translateY(var(--auth-clock-open-y, -24px)) scale(.65);}#lockScreenTime {@@ -314,6 +325,8 @@left: 16px;position: absolute;right: 16px;+ opacity: 0;+ visibility: hidden;}#authPanel h1 {@@ -321,7 +334,55 @@}body.wallpaper-cover #authPanel {- visibility: hidden;+ opacity: 0;+ pointer-events: none;+ transform: translateY(20px);+ }++ body.has-wallpaper {+ --auth-motion-duration: 200ms;+ overflow: hidden;+ }++ body.wallpaper-cover #lockScreenCover {+ pointer-events: auto;+ }++ body.wallpaper-cover #lockScreenClock {+ opacity: 1;+ transform: none;+ }++ body.wallpaper-cover #lockScreenHint {+ opacity: 1;+ visibility: visible;+ }++ body.wallpaper-transition #authPanel {+ transition: opacity var(--auth-motion-duration) ease, transform var(--auth-motion-duration) ease;+ }++ body.wallpaper-transition #lockScreenClock {+ transition: opacity var(--auth-motion-duration) cubic-bezier(.16, 1, .3, 1),+ transform var(--auth-motion-duration) cubic-bezier(.16, 1, .3, 1);+ }++ body.wallpaper-transition.wallpaper-cover #lockScreenClock {+ transition-timing-function: cubic-bezier(.7, 0, .84, 0);+ }++ body.wallpaper-transition #lockScreenHint {+ transition: opacity var(--auth-motion-duration) ease, visibility 0s var(--auth-motion-duration);+ }++ body.wallpaper-transition.wallpaper-cover #lockScreenHint {+ transition-delay: 0s, 0s;+ }++ @media (prefers-reduced-motion: reduce) {+ body.has-wallpaper {+ --auth-motion-duration: 0ms;+ }}body.has-wallpaper #authPanel h1 {@@ -349,7 +410,7 @@</button><div data-auth-drag style="-webkit-app-region: drag;height: 32px;width: 100%;position: absolute;top: 0;z-index: 3;"></div><div id="authPanel" style="position: relative;z-index: 2;text-align: center">- <h1 style="color:var(--b3-theme-on-background)">{{.workspace}}</h1>+ <h1 style="color:var(--auth-panel-text, var(--b3-theme-on-background))">{{.workspace}}</h1><div id="authCodePanel"{{if not .accessAuthCodeEnabled}} style="display: none"{{end}}><input class="b3-text-field" id="authCode" type="password" placeholder="{{.l0}}"/><br><div style="position: relative;width: 240px;margin: 8px auto 0;display: none">@@ -362,7 +423,7 @@{{if .oidcEnabled}}<button class="b3-button" id="oidcLogin" onclick="startOIDC()">{{.l12}}</button>{{end}}<div style="width: 240px; margin: 8px auto; text-align: left; display: flex; align-items: center;"><input type="checkbox" id="rememberMe" style="margin-right: 8px;">- <label for="rememberMe" style="color: var(--b3-theme-on-surface); font-size: 14px;">{{.l10}}</label>+ <label for="rememberMe" style="color: var(--auth-panel-secondary, var(--b3-theme-on-surface)); font-size: 14px;">{{.l10}}</label></div><button class="b3-button b3-button--white" onclick="exitSiYuan()">{{.l5}}</button></div>@@ -591,14 +652,19 @@const loadLockScreenWallpaper = () => {const wallpaper = document.getElementById("lockScreenWallpaper");const cover = document.getElementById("lockScreenCover");+ const clock = document.getElementById("lockScreenClock");const panel = document.getElementById("authPanel") || document.querySelector("main");let pending = true;let interacted = false;+ let covered = false;+ let composing = false;+ let clockShown = false;+ let resumeTarget;let clockTimer;const focusInput = () => {- const input = document.getElementById("authCode");- const target = input && !input.disabled && input.getClientRects().length ? input :- Array.from(panel.querySelectorAll("button:not(:disabled), a[href]")).find(item => item.getClientRects().length);+ const candidates = [resumeTarget, document.getElementById("authCode"),+ ...panel.querySelectorAll("button:not(:disabled), a[href]")];+ const target = candidates.find(item => item && !item.disabled && item.getClientRects().length);target?.focus({preventScroll: true});return target;};@@ -606,6 +672,13 @@clearInterval(clockTimer);clockTimer = undefined;};+ const positionClock = () => {+ const height = clock.offsetHeight * .65;+ const top = panel.offsetTop - 16 - height;+ clockShown = top >= 40;+ cover.style.setProperty("--auth-clock-open-y", `${clockShown ? top + height / 2 - window.innerHeight / 2 : -24}px`);+ cover.style.setProperty("--auth-clock-open-opacity", clockShown ? "1" : "0");+ };const updateClock = () => {const now = new Date();const time = document.getElementById("lockScreenTime");@@ -613,84 +686,106 @@time.dateTime = now.toISOString();document.getElementById("lockScreenDate").textContent = now.toLocaleDateString(undefined,{weekday: "long", month: "long", day: "numeric"});+ positionClock();};const refreshClock = () => {stopClock();- if (!cover.hidden && !document.hidden) {+ if (!wallpaper.hidden && !document.hidden) {updateClock();- clockTimer = setInterval(updateClock, 1000);+ if (covered || clockShown) clockTimer = setInterval(updateClock, 1000);}};+ const setCovered = show => {+ covered = show;+ cover.inert = !show;+ cover.setAttribute("aria-hidden", String(!show));+ panel.inert = show;+ document.body.classList[show ? "add" : "remove"]("wallpaper-cover");+ refreshClock();+ };const reveal = () => {interacted = true;- if (cover.hidden) return pending ? focusInput() : undefined;- cover.hidden = true;- panel.inert = false;- document.body.classList.remove("wallpaper-cover");- stopClock();+ if (!covered) return pending ? focusInput() : undefined;+ document.body.classList.add("wallpaper-transition");+ setCovered(false);return focusInput();};+ const conceal = () => {+ if (wallpaper.hidden || covered) return false;+ const active = document.activeElement;+ resumeTarget = panel.contains(active) ? active : undefined;+ document.body.classList.add("wallpaper-transition");+ setCovered(true);+ cover.focus({preventScroll: true});+ return true;+ };cover.addEventListener("click", reveal);document.addEventListener("pointerdown", event => {if (event.target.closest("#windowBar, [data-auth-drag]")) return;- if (!cover.hidden) event.preventDefault();+ if (covered) event.preventDefault();reveal();}, true);document.addEventListener("keydown", event => {+ if (event.key === "Escape") {+ if (event.isComposing || composing || event.keyCode === 229 || event.ctrlKey || event.metaKey || event.altKey) return;+ if (conceal()) {+ event.preventDefault();+ event.stopImmediatePropagation();+ }+ return;+ }if ((event.ctrlKey || event.metaKey) && !event.altKey && event.key.toLowerCase() === "v") {reveal();return;}const altGraph = event.getModifierState?.("AltGraph");if ((event.ctrlKey || event.metaKey || event.altKey) && !altGraph) return;- const covered = !cover.hidden;+ const wasCovered = covered;const target = reveal();- if (!covered || event.isComposing || event.key === "Process" || event.key === "Dead") return;- // 唤起按键不触发登录;可直接输入的首字符只写入密码框一次。- if (target?.type === "password" && Array.from(event.key).length === 1 && event.key !== " ") {+ if (!wasCovered || event.isComposing || event.key === "Process" || event.key === "Dead") return;+ // 唤起按键不触发登录;可直接输入的首字符只写入当前输入框一次。+ if ((target?.type === "password" || target?.type === "text") && Array.from(event.key).length === 1 && event.key !== " ") {target.setRangeText(event.key, target.selectionStart, target.selectionEnd, "end");target.dispatchEvent(new Event("input", {bubbles: true}));}event.preventDefault();event.stopImmediatePropagation();}, true);- document.addEventListener("compositionstart", reveal, true);+ document.addEventListener("compositionstart", () => { composing = true; reveal(); }, true);+ document.addEventListener("compositionend", () => { composing = false; }, true);document.addEventListener("visibilitychange", refreshClock);+ window.addEventListener("resize", refreshClock);window.addEventListener("pagehide", stopClock);window.addEventListener("pageshow", refreshClock);wallpaper.onload = () => {pending = false;wallpaper.hidden = false;+ cover.hidden = false;document.body.classList.add("has-wallpaper");const background = document.getElementById("authDefaultBackground");if (background) background.hidden = true;// 慢加载不打断已经开始的输入,也不遮住密码管理器填入的内容。- if (!interacted && !document.getElementById("authCode")?.value) {- cover.hidden = false;- panel.inert = true;- document.body.classList.add("wallpaper-cover");- refreshClock();- cover.focus({preventScroll: true});- } else if (!interacted) {- focusInput();- }+ setCovered(!interacted && !document.getElementById("authCode")?.value);+ if (covered) cover.focus({preventScroll: true});+ else if (!interacted) focusInput();};wallpaper.onerror = () => {pending = false;- const covered = !cover.hidden;- const shouldFocus = !interacted;- reveal();+ const shouldFocus = !interacted || covered;wallpaper.hidden = true;- document.body.classList.remove("has-wallpaper");+ cover.hidden = true;+ setCovered(false);+ document.body.classList.remove("has-wallpaper", "wallpaper-transition");const background = document.getElementById("authDefaultBackground");if (background) background.hidden = false;- if (!covered && shouldFocus) focusInput();+ if (shouldFocus) focusInput();};wallpaper.src = "/api/system/getLockScreenWallpaper";return {focus: () => {if (pending) return;- if (cover.hidden) focusInput();- else cover.focus({preventScroll: true});+ refreshClock();+ if (covered) cover.focus({preventScroll: true});+ else focusInput();}};};const lockScreenWallpaperState = loadLockScreenWallpaper();diff --git a/app/tests/lockScreenWallpaper.test.js b/app/tests/lockScreenWallpaper.test.jsindex 7fc485554f..6910862f09 100644--- a/app/tests/lockScreenWallpaper.test.js+++ b/app/tests/lockScreenWallpaper.test.js@@ -18,22 +18,33 @@ const fixture = (source, passwordVisible = true) => {let now = Date.UTC(2026, 9, 22, 12, 59);const input = {type: "password", value: "", selectionStart: 0, selectionEnd: 0,getClientRects: () => passwordVisible ? [{}] : [],- focus: () => { focused = "password"; },+ focus: () => { focused = "password"; document.activeElement = input; },setRangeText: text => { input.value += text; }, dispatchEvent: () => {},};- const oidc = {getClientRects: () => [{}], focus: () => { focused = "oidc"; }};- const panel = {inert: false, querySelectorAll: () => [oidc]};+ const captcha = {type: "text", value: "", selectionStart: 0, selectionEnd: 0,+ getClientRects: () => [{}], focus: () => { focused = "captcha"; document.activeElement = captcha; },+ setRangeText: text => { captcha.value += text; }, dispatchEvent: () => {}};+ const oidc = {getClientRects: () => [{}], focus: () => { focused = "oidc"; document.activeElement = oidc; }};+ const panel = {inert: false, offsetTop: 0, querySelectorAll: () => [oidc],+ contains: item => [input, captcha, oidc].includes(item)};+ const properties = new Map();+ const attributes = new Map();const cover = {hidden: true, focus: () => { focused = "cover"; },+ style: {setProperty: (key, value) => properties.set(key, value)},+ setAttribute: (key, value) => attributes.set(key, value),addEventListener: (type, callback) => listeners.set("cover:" + type, callback)};+ const clock = {offsetHeight: 100};const wallpaper = {hidden: true};const background = {hidden: false};const time = {textContent: ""};const date = {textContent: ""};const elements = {lockScreenWallpaper: wallpaper, lockScreenCover: cover, authPanel: panel,- authCode: input, authDefaultBackground: background, lockScreenTime: time, lockScreenDate: date};+ authCode: input, captcha, authDefaultBackground: background, lockScreenTime: time, lockScreenDate: date,+ lockScreenClock: clock};const document = {hidden: false,- body: {classList: {add: key => classes.add(key), remove: key => classes.delete(key)}},+ activeElement: undefined,+ body: {classList: {add: key => classes.add(key), remove: (...keys) => keys.forEach(key => classes.delete(key))}},getElementById: id => elements[id],addEventListener: (type, callback) => listeners.set(type, callback),};@@ -41,7 +52,7 @@ const fixture = (source, passwordVisible = true) => {constructor() { super(now); }}const context = {document, Date: Clock, Event: class {},- window: {addEventListener: (type, callback) => windowListeners.set(type, callback)},+ window: {innerHeight: 800, addEventListener: (type, callback) => windowListeners.set(type, callback)},clearInterval: id => timers.delete(id),setInterval: callback => { timers.set(++timerID, callback); return timerID; },};@@ -52,7 +63,8 @@ const fixture = (source, passwordVisible = true) => {listeners.get("keydown")(event);return event;};- return {classes, listeners, windowListeners, timers, document, input, panel, cover, wallpaper, background, time, date,+ return {classes, listeners, windowListeners, timers, document, input, captcha, panel, cover, wallpaper, background, time, date,+ properties, attributes,controller: context.controller, key, focused: () => focused, advance: () => { now += 60_000; }};};@@ -89,7 +101,8 @@ for (const {file, source} of sources) {assert.ok(event.prevented && event.stopped);assert.equal(f.input.value, "A");assert.equal(f.focused(), "password");- assert.equal(f.cover.hidden, true);+ assert.equal(f.cover.inert, true);+ assert.equal(f.attributes.get("aria-hidden"), "true");assert.equal(f.panel.inert, false);assert.equal(f.timers.size, 0);assert.equal(f.key("b").prevented, false);@@ -102,7 +115,7 @@ for (const {file, source} of sources) {f.wallpaper.onload();const event = f.key(key);assert.ok(event.prevented && event.stopped);- assert.equal(f.cover.hidden, true);+ assert.equal(f.cover.inert, true);assert.equal(f.input.value, "");}for (const pointerType of ["mouse", "touch"]) {@@ -112,13 +125,13 @@ for (const {file, source} of sources) {f.listeners.get("pointerdown")({pointerType, target: {closest: () => false},preventDefault: () => { prevented = true; }});assert.equal(prevented, true, "native pointer focus must not override the password focus");- assert.equal(f.cover.hidden, true);+ assert.equal(f.cover.inert, true);assert.equal(f.focused(), "password");}const f = fixture(source);f.wallpaper.onload();f.listeners.get("cover:click")();- assert.equal(f.cover.hidden, true);+ assert.equal(f.cover.inert, true);});test(`${file} respects window controls, shortcuts, IME and OIDC-only sign-in`, () => {@@ -129,12 +142,12 @@ for (const {file, source} of sources) {assert.equal(f.key("w", {ctrlKey: true}).prevented, false);assert.equal(f.cover.hidden, false);assert.equal(f.key("Process", {isComposing: true}).prevented, false);- assert.equal(f.cover.hidden, true);+ assert.equal(f.cover.inert, true);assert.equal(f.input.value, "");const paste = fixture(source);paste.wallpaper.onload();assert.equal(paste.key("v", {ctrlKey: true}).prevented, false);- assert.equal(paste.cover.hidden, true);+ assert.equal(paste.cover.inert, true);assert.equal(paste.focused(), "password");assert.equal(paste.input.value, "");const oidc = fixture(source, false);@@ -150,13 +163,13 @@ for (const {file, source} of sources) {assert.equal(f.focused(), "password", "typing during image loading already targets the password input");f.input.value = "already typing";f.wallpaper.onload();- assert.equal(f.cover.hidden, true);+ assert.equal(f.cover.inert, true);assert.equal(f.panel.inert, false);assert.equal(f.timers.size, 0);const autofill = fixture(source);autofill.input.value = "filled by password manager";autofill.wallpaper.onload();- assert.equal(autofill.cover.hidden, true);+ assert.equal(autofill.cover.inert, true);});test(`${file} restores login after a missing or corrupt wallpaper`, () => {@@ -196,4 +209,67 @@ for (const {file, source} of sources) {f.listeners.get("visibilitychange")();assert.equal(f.timers.size, 0);});++ test(`${file} Escape returns to the clock without clearing password, captcha or the active field`, () => {+ const f = fixture(source);+ f.wallpaper.onload();+ f.key("p");+ f.captcha.value = "12";+ f.captcha.selectionStart = f.captcha.selectionEnd = 2;+ f.captcha.focus();+ const event = f.key("Escape");+ assert.ok(event.prevented && event.stopped);+ assert.equal(f.panel.inert, true);+ assert.equal(f.cover.inert, false);+ assert.equal(f.attributes.get("aria-hidden"), "false");+ assert.equal(f.focused(), "cover");+ assert.ok(f.classes.has("wallpaper-transition"));+ assert.ok(f.classes.has("wallpaper-cover"));+ assert.equal(f.input.value, "p");+ assert.equal(f.captcha.value, "12");+ assert.equal(f.captcha.selectionStart, 2);+ assert.equal(f.timers.size, 1);+ assert.equal(f.key("Escape").prevented, false, "Escape on the cover does not reopen the form");+ f.key("3");+ assert.equal(f.focused(), "captcha");+ assert.equal(f.captcha.value, "123");+ assert.equal(f.panel.inert, false);+ for (let i = 0; i < 3; i++) { f.key("Escape"); f.key("Enter"); }+ assert.equal(f.panel.inert, false, "rapid reversals leave the last requested state active");+ assert.equal(f.captcha.value, "123");+ });++ test(`${file} Escape respects IME, modified shortcuts and the default login page`, () => {+ const f = fixture(source);+ assert.equal(f.key("Escape").prevented, false);+ f.wallpaper.onload();+ f.key("Enter");+ for (const extra of [{isComposing: true}, {keyCode: 229}, {ctrlKey: true}, {altKey: true}, {metaKey: true}]) {+ assert.equal(f.key("Escape", extra).prevented, false);+ assert.equal(f.panel.inert, false);+ }+ f.listeners.get("compositionstart")();+ assert.equal(f.key("Escape").prevented, false);+ f.listeners.get("compositionend")();+ assert.equal(f.key("Escape").prevented, true);+ f.wallpaper.onerror();+ assert.equal(f.key("Escape").prevented, false);+ assert.equal(f.cover.hidden, true);+ });++ test(`${file} keeps the raised clock running and adapts it when the login panel has less space`, () => {+ const f = fixture(source);+ f.panel.offsetTop = 300;+ f.wallpaper.onload();+ f.key("Enter");+ assert.equal(f.properties.get("--auth-clock-open-opacity"), "1");+ assert.equal(f.properties.get("--auth-clock-open-y"), "-148.5px");+ assert.equal(f.timers.size, 1);+ f.panel.offsetTop = 40;+ f.windowListeners.get("resize")();+ assert.equal(f.properties.get("--auth-clock-open-opacity"), "0");+ assert.equal(f.timers.size, 0);+ f.key("Escape");+ assert.equal(f.timers.size, 1);+ });}diff --git a/app/tests/lockScreenWallpaperLayout.test.js b/app/tests/lockScreenWallpaperLayout.test.jsindex 2c82b38a06..531fe6395f 100644--- a/app/tests/lockScreenWallpaperLayout.test.js+++ b/app/tests/lockScreenWallpaperLayout.test.js@@ -70,13 +70,15 @@ const fixtureHTML = (file, dark, glassSupported = true) => {.replace(/{{if not \.accessAuthCodeEnabled}}[\s\S]*?{{end}}/g, "").replace(/{{(?:if \.\w+|end)}}/g, "").replace(/{{\.workspace}}/g, "Workspace")+ .replace(/{{\.l7}}/g, 'Powered by <a href="https://example.invalid/">SiYuan</a>').replace(/{{\.l\d+}}/g, "Sign in").replace(/{{\.lockScreenReveal}}/g, "Click or press a key to sign in")+ .replace('<span id="lockScreenHint"></span>', '<span id="lockScreenHint">Click or press a key to sign in</span>').replace("<main hidden>", "<main>");if (dark) source = source.replace('<html style="height: 100%">', '<html class="dark" style="height: 100%">');// 仅替换能力条件,验证不支持背景模糊时的实色回退样式。if (!glassSupported) source = source.replace(- "@supports (backdrop-filter: blur(16px)) or (-webkit-backdrop-filter: blur(16px))",+ "@supports (backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px))","@supports (siyuan-unsupported: true)");return source.replace("</body>", `<script>${loader}\nwindow.loadLockScreenWallpaper = loadLockScreenWallpaper;</script></body>`);};@@ -103,7 +105,8 @@ const checkLayout = async (wallpaperPresent, dark, remote, glass = true) => {const cover = document.getElementById("lockScreenCover");if (wallpaperPresent) {check.equal(panel.inert, true);- check.equal(getComputedStyle(panel).visibility, "hidden");+ check.equal(getComputedStyle(panel).opacity, "0");+ check.equal(getComputedStyle(panel).pointerEvents, "none");check.equal(cover.hidden, false);check.ok(document.getElementById("lockScreenTime").textContent);check.ok(document.getElementById("lockScreenDate").textContent);@@ -116,7 +119,9 @@ const checkLayout = async (wallpaperPresent, dark, remote, glass = true) => {"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");+ `time and date are centered together: ${JSON.stringify({x: group.x, y: group.y, width: group.width,+ height: group.height, viewport: [innerWidth, innerHeight], remote, classes: document.body.className,+ transform: getComputedStyle(document.getElementById("lockScreenClock")).transform})}`);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");@@ -127,8 +132,15 @@ const checkLayout = async (wallpaperPresent, dark, remote, glass = true) => {"the top window drag area remains above the cover");cover.click();check.equal(panel.inert, false);- check.equal(cover.hidden, true);+ check.equal(cover.inert, true);check.equal(getComputedStyle(panel).visibility, "visible");+ await Promise.all(document.getAnimations().map(animation => animation.finished.catch(() => {})));+ const raisedClock = document.getElementById("lockScreenClock");+ if (getComputedStyle(raisedClock).opacity === "1") {+ const raised = raisedClock.getBoundingClientRect();+ check.ok(raised.top >= 39 && raised.bottom + 15 <= panel.getBoundingClientRect().top,+ "the raised clock stays below the window bar and above the login card");+ }}const rect = panel.getBoundingClientRect();const style = getComputedStyle(panel);@@ -139,33 +151,41 @@ 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(0, 0, 0, 0.28)" : "rgba(255, 255, 255, 0.5)") :+ (dark ? "rgba(0, 0, 0, 0.06)" : "rgba(255, 255, 255, 0.08)") :(dark ? "rgb(30, 30, 30)" : "rgb(255, 255, 255)")));- check.equal(blur, glass ? "blur(16px) saturate(1.1)" : "none");+ check.equal(blur, glass ? "blur(8px) saturate(1.05)" : "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);+ if (!forcedColors) {+ const field = getComputedStyle(document.getElementById("authCode"));+ const levels = [field.color, field.backgroundColor].map(color => luminance(color.match(/[\d.]+/g).map(Number).slice(0, 3)));+ check.ok((Math.max(...levels) + .05) / (Math.min(...levels) + .05) >= 4.5,+ "glass text colors do not reduce password input contrast");+ }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"];+ const selectors = remote ? ["h1", "label", ...(glass ? ["#origin"] : [])] :+ [".ft__on-surface", "label", "h1", ...(glass ? [".ft__on-surface a"] : [])];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;+ if (glass) {+ const outline = "rgb(0, 0, 0)";+ check.equal(textStyle.textShadow, `${outline} 0px 1px 3px`);+ const outlineLight = 0;+ check.ok(luminance(foreground.slice(0, 3)) > .8,+ "transparent panels use clear light text in both application themes");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");+ check.ok(outlineContrast >= 4.5, "the text shadow color remains distinct from its fill");}for (const wallpaperColor of [0, 255]) {const background = panelColor.slice(0, 3).map(value =>@@ -209,12 +229,80 @@ const prepareKeyboardCase = async () => {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("lockScreenCover").inert, true);check.equal(document.getElementById("authCode").value, value);- check.equal(document.activeElement, document.getElementById("authCode"));+ check.equal(document.activeElement, document.getElementById("authCode"),+ `password focus after native input (value=${value}, submits=${submits})`);check.equal(window.testSubmits, submits, "native Enter events reach the revealed login form");};+const checkTransition = async (remote, reduced) => {+ const check = require("node:assert/strict");+ const panel = document.querySelector(remote ? "main" : "#authPanel");+ const cover = document.getElementById("lockScreenCover");+ const clock = document.getElementById("lockScreenClock");+ const hint = document.getElementById("lockScreenHint");+ const targets = [panel, clock, hint];+ const animations = () => targets.flatMap(target => target.getAnimations());+ const centered = clock.getBoundingClientRect();+ cover.click();+ check.equal(panel.inert, false, "login is available before the transition ends");+ check.equal(document.activeElement, document.getElementById("authCode"));+ const entering = animations();+ if (reduced) {+ check.equal(entering.length, 0, "reduced motion switches directly without transitions");+ check.equal(getComputedStyle(panel).opacity, "1");+ } else {+ check.ok(entering.length >= 3);+ for (const animation of entering) {+ check.equal(animation.effect.getTiming().duration, animation.transitionProperty === "visibility" ? 0 : 200);+ animation.pause();+ animation.currentTime = 100;+ }+ const opacity = Number(getComputedStyle(panel).opacity);+ check.ok(opacity > 0 && opacity < 1, "the card fades in while moving upward");+ const y = new DOMMatrix(getComputedStyle(panel).transform).m42;+ check.ok(y > 0 && y < 20);+ check.ok(clock.getBoundingClientRect().top < centered.top, "time and date move upward together");+ check.ok(clock.getBoundingClientRect().bottom < panel.getBoundingClientRect().top,+ "the clock moves clear before the entering card becomes prominent");+ entering.forEach(animation => animation.finish());+ }+ const input = document.getElementById("authCode");+ input.value = "retained password";+ input.dispatchEvent(new KeyboardEvent("keydown", {key: "Escape", bubbles: true, cancelable: true}));+ check.equal(panel.inert, true);+ check.equal(cover.inert, false);+ const leaving = animations();+ if (reduced) {+ check.equal(leaving.length, 0);+ } else {+ check.ok(leaving.length >= 3);+ leaving.forEach(animation => { animation.pause(); animation.currentTime = 100; });+ const opacity = Number(getComputedStyle(panel).opacity);+ check.ok(opacity > 0 && opacity < 1, "Escape fades the card out rather than hiding it immediately");+ check.equal(getComputedStyle(panel).visibility, "visible");+ check.ok(new DOMMatrix(getComputedStyle(panel).transform).m42 > 0);+ check.ok(clock.getBoundingClientRect().bottom < panel.getBoundingClientRect().top,+ "the returning clock waits for the card to fade before crossing its position");+ leaving.forEach(animation => animation.finish());+ }+ check.equal(input.value, "retained password");+ check.equal(getComputedStyle(panel).opacity, "0");+ check.equal(getComputedStyle(panel).pointerEvents, "none");+ const restored = clock.getBoundingClientRect();+ check.ok(Math.abs((restored.top + restored.bottom) / 2 - innerHeight / 2) < 1);+ // 动画尚未完成时反向切换,最终状态和输入内容仍以最后一次操作为准。+ cover.click();+ input.dispatchEvent(new KeyboardEvent("keydown", {key: "Escape", bubbles: true, cancelable: true}));+ cover.click();+ await Promise.all(animations().map(animation => animation.finished.catch(() => {})));+ check.equal(panel.inert, false);+ check.equal(cover.inert, true);+ check.equal(getComputedStyle(panel).opacity, "1");+ check.equal(input.value, "retained password");+};+if (process.versions.electron && process.type === "browser") {const {app, BrowserWindow, nativeTheme} = require("electron");app.setPath("userData", process.argv[2]);@@ -252,6 +340,16 @@ if (process.versions.electron && process.type === "browser") {}}await win.webContents.debugger.sendCommand("Emulation.setEmulatedMedia", {features: []});+ for (const reduced of [false, true]) {+ await win.webContents.debugger.sendCommand("Emulation.setEmulatedMedia", {+ features: [{name: "prefers-reduced-motion", value: reduced ? "reduce" : "no-preference"}],+ });+ win.setContentSize(1200, 900);+ await win.loadURL("data:text/html;charset=utf-8," + encodeURIComponent(fixtureHTML(file, false)));+ await win.webContents.executeJavaScript(`(${prepareKeyboardCase.toString()})()`);+ await win.webContents.executeJavaScript(`(${checkTransition.toString()})(${file.startsWith("electron")}, ${reduced})`);+ }+ await win.webContents.debugger.sendCommand("Emulation.setEmulatedMedia", {features: []});win.webContents.debugger.detach();win.setContentSize(1000, 700);const start = async () => {@@ -264,6 +362,29 @@ if (process.versions.electron && process.type === "browser") {win.webContents.sendInputEvent({type, keyCode});}await win.webContents.executeJavaScript(`(${assertKeyboardState.toString()})("ab", 0)`);+ await win.webContents.executeJavaScript(`{+ const captcha = document.getElementById("captcha");+ captcha.parentElement.style.display = "block";+ captcha.value = "42"; captcha.focus(); captcha.setSelectionRange(2, 2);+ }`);+ win.webContents.sendInputEvent({type: "keyDown", keyCode: "Escape"});+ win.webContents.sendInputEvent({type: "keyUp", keyCode: "Escape"});+ await win.webContents.executeJavaScript(`{+ const check = require("node:assert/strict");+ check.equal(document.getElementById("lockScreenCover").inert, false);+ check.equal(document.getElementById("authCode").value, "ab");+ check.equal(document.getElementById("captcha").value, "42");+ }`);+ for (const [type, keyCode] of [["keyDown", "3"], ["char", "3"], ["keyUp", "3"]]) {+ win.webContents.sendInputEvent({type, keyCode});+ }+ await win.webContents.executeJavaScript(`{+ const check = require("node:assert/strict");+ const captcha = document.getElementById("captcha");+ check.equal(document.activeElement, captcha);+ check.equal(captcha.value, "423");+ check.equal(document.getElementById("authCode").value, "ab");+ }`);await start();win.webContents.sendInputEvent({type: "keyDown", keyCode: "Enter"});win.webContents.sendInputEvent({type: "keyUp", keyCode: "Enter"});