3 Commits

Author SHA1 Message Date
virtheart 1cc36cb9f7 fix: 移动端菜单只见背景不见内容 — 幕布 z-[60] 回归原版 z-30
LoadingCurtain 容器 z-[60] 高于菜单(z-40)/Header(z-50),菜单展开
时整个被幕布盖住。原版该 Canvas 即 z-30(chunk 3c6cc5b2 提取证据),
压回 z-30 恢复原版层叠:内容(≤20) < 幕布(30) < 菜单/进度条(40) < Header(50)。
2026-09-02 23:17:55 +08:00
virtheart 27ed0fbf79 fix: Dark 主题玻璃模型颜色偏差 — Hard Light 选择器对齐原版
原版按 tint 色逐通道 step(vec3(0.5), blend) 选择 multiply/screen;
移植时误写成按 base 标量 step(0.5, base)。Beer-Lambert 分支(Light)
不受影响,Dark 分支(uDark=1 Hard-Light 双色调)因选择器变量错误
导致整体色偏,尤其 tint 色 #64c3ff/#8e9dc4 各通道跨 0.5 时。
与原版逐行 diff 玻璃 fragment shader 确认无其它实质差异。
2026-09-02 23:07:57 +08:00
virtheart 15b138cdd7 feat: 默认主题改为 system 跟随设备,BGM 默认开启
- 主题默认值 light → system(首次访问自动跟随 prefers-color-scheme,
  与原版默认 light 不同,为产品决策)
- 音效默认值 off → on(localStorage 无记录即开启,显式关闭才停;
  首次真实播放仍受自动播放策略限制,由 useBgm 手势恢复逻辑兜底)
2026-09-02 22:47:41 +08:00
3 changed files with 27 additions and 14 deletions
+6 -3
View File
@@ -213,11 +213,14 @@ void main() {
float tintK_hard = clamp(uTintEnabled, 0.0, 1.0) * clamp(uTintMix, 0.0, 1.0) * tintAlpha; float tintK_hard = clamp(uTintEnabled, 0.0, 1.0) * clamp(uTintMix, 0.0, 1.0) * tintAlpha;
vec3 baseClamped = clamp(color, 0.0, 1.0); vec3 baseClamped = clamp(color, 0.0, 1.0);
vec3 blendClamped = clamp(tintColorGradient.rgb, 0.0, 1.0); vec3 blendClamped = clamp(tintColorGradient.rgb, 0.0, 1.0);
// Hard Light blend: 2*blend*base where base < 0.5, screen elsewhere // Hard Light blend(原版逐通道):blend 通道 > 0.5 → screen,否则 multiply。
// 注意选择器是 blend(tint 色)而非 base —— 暗色主题的 #64c3ff/#8e9dc4
// 各通道跨 0.5,选错变量会导致 Dark 下模型颜色整体偏差。
vec3 h = step(vec3(0.5), blendClamped);
vec3 hard = mix( vec3 hard = mix(
2.0 * blendClamped * baseClamped, 2.0 * baseClamped * blendClamped,
1.0 - 2.0 * (1.0 - blendClamped) * (1.0 - baseClamped), 1.0 - 2.0 * (1.0 - blendClamped) * (1.0 - baseClamped),
step(0.5, baseClamped) h
); );
vec3 hardColor = mix(color, hard, tintK_hard); vec3 hardColor = mix(color, hard, tintK_hard);
+5 -1
View File
@@ -423,7 +423,11 @@ export function LoadingCurtain({
// dedicated fullscreen fixed wrapper gives the container a real viewport // dedicated fullscreen fixed wrapper gives the container a real viewport
// box; pointer-events:none inherits to the whole subtree. // box; pointer-events:none inherits to the whole subtree.
return ( return (
<div className="fixed inset-0 z-[60] pointer-events-none"> // 原版这块幕布 Canvas 是 "z-30 fixed inset-0 pointer-events-none":
// 盖住页面内容(≤z-20),但必须低于移动端全屏菜单(z-40)、
// 进度条(z-40)与 Header(z-50)——曾写成 z-[60] 会把菜单整个
// 压在幕布下面,移动端打开菜单只剩一片背景色。
<div className="fixed inset-0 z-30 pointer-events-none">
<Canvas <Canvas
dpr={[1, 2]} dpr={[1, 2]}
frameloop="demand" frameloop="demand"
+16 -10
View File
@@ -8,7 +8,8 @@ import { useEffect, useSyncExternalStore } from "react";
* sound store (module 23525): * sound store (module 23525):
* *
* - theme ∈ {light, dark, system}, persisted to localStorage "theme" * - theme ∈ {light, dark, system}, persisted to localStorage "theme"
* (original key, kept verbatim for parity); default "light". * (original key, kept verbatim for parity); default "system" — follow the
* device (auto), per product decision (original defaulted to "light").
* - resolvedTheme = theme === "system" * - resolvedTheme = theme === "system"
* ? (matchMedia("(prefers-color-scheme: dark)").matches ? dark : light) * ? (matchMedia("(prefers-color-scheme: dark)").matches ? dark : light)
* : theme; * : theme;
@@ -16,7 +17,8 @@ import { useEffect, useSyncExternalStore } from "react";
* CSS tokens flip via the .dark block in globals.css. * CSS tokens flip via the .dark block in globals.css.
* - "system" follows OS changes live (original matchMedia change listener). * - "system" follows OS changes live (original matchMedia change listener).
* - soundEnabled persisted to localStorage "sound" ("on"/"off", original * - soundEnabled persisted to localStorage "sound" ("on"/"off", original
* keys). * keys); default ON — BGM starts (autoplay policies defer actual playback
* to the first user gesture, handled in useBgm's recovery effect).
* *
* Implemented as a module-singleton external store (useSyncExternalStore) * Implemented as a module-singleton external store (useSyncExternalStore)
* instead of the original context: the header and the canvas components * instead of the original context: the header and the canvas components
@@ -38,9 +40,9 @@ type ShellMediaState = {
}; };
let state: ShellMediaState = { let state: ShellMediaState = {
theme: "light", theme: "system",
resolvedTheme: "light", resolvedTheme: "light",
soundEnabled: false, soundEnabled: true,
}; };
const listeners = new Set<() => void>(); const listeners = new Set<() => void>();
@@ -90,16 +92,18 @@ function hydrate() {
if (hydrated || typeof window === "undefined") return; if (hydrated || typeof window === "undefined") return;
hydrated = true; hydrated = true;
const stored = readStored(THEME_KEY); const stored = readStored(THEME_KEY);
// 无有效存储 → 默认 system(自动跟随设备)
const theme: ThemeSetting = SETTINGS.includes(stored as ThemeSetting) const theme: ThemeSetting = SETTINGS.includes(stored as ThemeSetting)
? (stored as ThemeSetting) ? (stored as ThemeSetting)
: "light"; : "system";
mediaQuery = window.matchMedia("(prefers-color-scheme: dark)"); mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
mediaQuery.addEventListener("change", onSystemChange); mediaQuery.addEventListener("change", onSystemChange);
state = { ...state, theme, resolvedTheme: resolve(theme) }; state = { ...state, theme, resolvedTheme: resolve(theme) };
applyDocument(theme); applyDocument(theme);
state = { state = {
...state, ...state,
soundEnabled: readStored(SOUND_KEY) === "on", // 无有效存储 → 默认开启 BGM;显式 "off" 才关闭
soundEnabled: readStored(SOUND_KEY) !== "off",
}; };
} }
@@ -142,12 +146,14 @@ function subscribe(listener: () => void) {
const getSnapshot = () => state; const getSnapshot = () => state;
// Hydration-safe SSR snapshot: must equal what the server rendered // Hydration-safe SSR snapshot: must equal what the server rendered
// (light/paused defaults). React uses this for the hydration render, then // (system/light defaults per product decision; sound defaults ON — the
// re-renders with the live snapshot once the client store hydrates. // audio only starts after the first user gesture, see useBgm). React uses
// this for the hydration render, then re-renders with the live snapshot
// once the client store hydrates.
const SERVER_SNAPSHOT: ShellMediaState = { const SERVER_SNAPSHOT: ShellMediaState = {
theme: "light", theme: "system",
resolvedTheme: "light", resolvedTheme: "light",
soundEnabled: false, soundEnabled: true,
}; };
function getServerSnapshot(): ShellMediaState { function getServerSnapshot(): ShellMediaState {