From 8925869f74e43f7633afe0d8c1db465aae3161fa Mon Sep 17 00:00:00 2001 From: mes123456 Date: Sat, 14 Nov 2026 09:44:13 +0800 Subject: [PATCH] fix(web): apply the selected theme preset The preset was written to data-theme in uppercase, while the CSS selectors use lowercase/hyphenated values, so switching themes had no visual effect. Co-Authored-By: Claude Code --- .../WBV2-P1425-001-web-operator-dispatch.md | 4 ++ .../continuation-20261113-web-export.json | 8 ++- tools/web/complete/probe-theme.mjs | 49 +++++++++++++++++++ web/app/src/app/App.tsx | 2 +- 4 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 tools/web/complete/probe-theme.mjs diff --git a/docs/status/WBV2-P1425-001-web-operator-dispatch.md b/docs/status/WBV2-P1425-001-web-operator-dispatch.md index e2d08dc66..05ab76d1f 100644 --- a/docs/status/WBV2-P1425-001-web-operator-dispatch.md +++ b/docs/status/WBV2-P1425-001-web-operator-dispatch.md @@ -428,6 +428,10 @@ - 物理 Manifest/播放:RIGID_BODY 添加后 manifest 显示 `1 systems · 0 cached`, 播放使时间线 frame 1→2,暂停后停在 2;证据 `tools/web/complete/probe-physics.mjs`。 +- 主题预设:此前 `dataset.theme` 写入大写 `LIGHT`,CSS 选择器为 + `[data-theme="light"]`,切换无视觉效果。已归一化为小写/连字符;复测 + DARK→LIGHT 背景 rgb(24,24,24)→rgb(236,236,236)→DARK;证据 + `tools/web/complete/probe-theme.mjs`。 - Sequencer:Properties 的 Sequencer Strip Editing → Add Strip 创建 `Web MOVIE`(MOVIE);证据 `tools/web/complete/probe-sequencer.mjs`。 - Outliner:右键 `Data` 菜单 → 重命名,`PBR Studio Ground` → `GroundRenamed`, diff --git a/tests/golden/WBV2-P1425-001/continuation-20261113-web-export.json b/tests/golden/WBV2-P1425-001/continuation-20261113-web-export.json index f28d99c80..0e24dc8fe 100644 --- a/tests/golden/WBV2-P1425-001/continuation-20261113-web-export.json +++ b/tests/golden/WBV2-P1425-001/continuation-20261113-web-export.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "task": "WBV2-P1425-001", - "updatedAt": "2026-11-14T07:56:00+08:00", + "updatedAt": "2026-11-14T08:44:00+08:00", "status": "in_progress", "focus": "COMPLETE-TUTORIAL-001 backend export gap (USD/Alembic)", "breakpoint": "blender-5.2.0/source/blender/web_engine/CMakeLists.txt (USD wiring); WASM 6ee2b261", @@ -252,5 +252,11 @@ "result": "manifest 1 systems · 0 cached after RIGID_BODY; 播放 frame 1→2; 暂停 stops at 2", "script": "tools/web/complete/probe-physics.mjs", "acceptance": "NOT_CLAIMED" + }, + "themeFix": { + "fix": "App.tsx normalizes themes.preset to lowercase/hyphen when writing documentElement.dataset.theme", + "result": "DARK background rgb(24,24,24) → LIGHT rgb(236,236,236) → DARK", + "script": "tools/web/complete/probe-theme.mjs", + "acceptance": "NOT_CLAIMED" } } diff --git a/tools/web/complete/probe-theme.mjs b/tools/web/complete/probe-theme.mjs new file mode 100644 index 000000000..174f9da62 --- /dev/null +++ b/tools/web/complete/probe-theme.mjs @@ -0,0 +1,49 @@ +#!/usr/bin/env node +/** + * Focused case: switch the theme preset in Preferences and observe the shell. + * + * node tools/web/complete/probe-theme.mjs --base-url http://127.0.0.1:5176 + */ +import { ASSETS, parseArgs, launchBrowser, newPage, openFile, waitScene } from "../course/lib/lesson-recorder.mjs"; + +const args = parseArgs(); +const BASE = args.baseUrl || "http://127.0.0.1:5176"; +const browser = await launchBrowser(args.gpu); +const { context, page, consoleErrors } = await newPage(browser, { baseUrl: BASE }); +page.setDefaultTimeout(60_000); +const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts); +const themeState = async () => page.evaluate(() => ({ + theme: document.documentElement.dataset.theme ?? null, + background: getComputedStyle(document.body).backgroundColor, + status: document.querySelector('[data-testid="engine-status"]')?.textContent ?? "", +})); +try { + await openFile(page, ASSETS.studio); + await waitScene(page, { objects: 6, timeout: 240_000 }); + log("before", JSON.stringify(await themeState())); + await page.getByRole("button", { name: "编辑", exact: true }).click(); + await page.getByRole("menuitem", { name: "偏好设置", exact: true }).click(); + await page.getByRole("dialog", { name: "Web Blender 偏好设置" }).waitFor({ timeout: 30_000 }); + await page.getByRole("button", { name: "主题", exact: true }).click(); + const select = page.getByRole("combobox", { name: "主题预设", exact: true }); + await select.waitFor({ timeout: 30_000 }); + log("theme options", JSON.stringify(await select.locator("option").evaluateAll((nodes) => nodes.map((node) => node.value)))); + await select.selectOption("LIGHT"); + await page.getByRole("button", { name: "关闭偏好设置", exact: true }).click(); + await page.waitForTimeout(800); + log("light", JSON.stringify(await themeState())); + await page.getByRole("button", { name: "编辑", exact: true }).click(); + await page.getByRole("menuitem", { name: "偏好设置", exact: true }).click(); + await page.getByRole("button", { name: "主题", exact: true }).click(); + await page.getByRole("combobox", { name: "主题预设", exact: true }).selectOption("DARK"); + await page.getByRole("button", { name: "关闭偏好设置", exact: true }).click(); + await page.waitForTimeout(800); + log("dark", JSON.stringify(await themeState())); +} catch (error) { + log("probe error", error instanceof Error ? error.message : String(error)); + log("state", JSON.stringify(await themeState().catch(() => null))); +} finally { + log("consoleErrors", JSON.stringify(consoleErrors.slice(-8))); + await context.close(); + await browser.close(); +} diff --git a/web/app/src/app/App.tsx b/web/app/src/app/App.tsx index 4fdb8484b..aaaeda499 100644 --- a/web/app/src/app/App.tsx +++ b/web/app/src/app/App.tsx @@ -4410,7 +4410,7 @@ export function App({localOnly=false,course}:{localOnly?:boolean;course?:Availab setPreferencesStatus(""); }, []); useEffect(() => { - document.documentElement.dataset.theme = webPreferences.themes?.preset ?? "DARK"; + document.documentElement.dataset.theme = (webPreferences.themes?.preset ?? "DARK").toLowerCase().replaceAll("_", "-"); }, [webPreferences.themes?.preset]); const savePreferencesNow = useCallback(async (): Promise => { const saved = await saveWebSettings({ ...settingsRef.current, preferences: { ...settingsRef.current.preferences, interface: { ...settingsRef.current.preferences.interface, showStatus, quickTools, showAreaSwitcher } }, areaEditorOverrides, cameraLocks });