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 <noreply@anthropic.com>
This commit is contained in:
@@ -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`,
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
49
tools/web/complete/probe-theme.mjs
Normal file
49
tools/web/complete/probe-theme.mjs
Normal file
@@ -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();
|
||||
}
|
||||
@@ -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<void> => {
|
||||
const saved = await saveWebSettings({ ...settingsRef.current, preferences: { ...settingsRef.current.preferences, interface: { ...settingsRef.current.preferences.interface, showStatus, quickTools, showAreaSwitcher } }, areaEditorOverrides, cameraLocks });
|
||||
|
||||
Reference in New Issue
Block a user