feat: M5 外观特效选择+持久化(appearance:load/save IPC+config.json,鼠效 6 选格接 EffectEngine,重开恢复并接线)
This commit is contained in:
@@ -5,16 +5,25 @@ import { useAppearance } from '../appearance/appearance-store';
|
||||
export function EffectLayer() {
|
||||
const ref = useRef<HTMLCanvasElement>(null);
|
||||
const engineRef = useRef<EffectEngine | null>(null);
|
||||
const appearance = useAppearance();
|
||||
// M6 骨架:默认关闭,外观面板后续接入选择
|
||||
const effect = useAppearance(s => s.effect);
|
||||
const accent = useAppearance(s => s.draft.accent);
|
||||
|
||||
// 建引擎一次
|
||||
useEffect(() => {
|
||||
if (!ref.current) return;
|
||||
const eng = new EffectEngine();
|
||||
eng.attach(ref.current);
|
||||
eng.setColor(appearance.draft.accent);
|
||||
eng.setType('off'); // 默认关闭,待外观面板接入开启
|
||||
engineRef.current = eng;
|
||||
return () => eng.detach();
|
||||
}, []);
|
||||
return <canvas ref={ref} style={{ position: 'fixed', inset: 0, pointerEvents: 'none', zIndex: 9999 }} />;
|
||||
|
||||
// effect/accent 变化时同步引擎(FR-A11 接线)
|
||||
useEffect(() => {
|
||||
const eng = engineRef.current;
|
||||
if (!eng) return;
|
||||
eng.setColor(accent);
|
||||
eng.setType(effect);
|
||||
}, [effect, accent]);
|
||||
|
||||
return <canvas ref={ref} data-effect={effect} style={{ position: 'fixed', inset: 0, pointerEvents: 'none', zIndex: 9999 }} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user