feat: 模组全维度独立,消除全局 DOM/Portal/存储污染
- jieya-ibp/welltrust-qap ThemeContext 改为作用域容器承载 CSS 变量与背景色,不再写 document - 删除 order-cost CostCockpit 对 documentElement 的死变量写入 - bomx Drawer createPortal 挂载点内移到 .bomx-app,移除 document.body 兜底 - knowledge-graph 拖拽 cursor 改为根容器 ref - 新增 check-module-independence 门禁并接入 build - SOP 与融合技能文档补充「模组完全独立互不影响」章节 Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6 noreply@anthropic.com>
parent
9c45aedbe8
commit
8699798ea5
@@ -1,5 +1,5 @@
|
||||
import { createContext, useContext, useState, useEffect, useCallback } from 'react';
|
||||
import type { ReactNode } from 'react';
|
||||
import { createContext, useContext, useState, useCallback } from 'react';
|
||||
import type { ReactNode, CSSProperties } from 'react';
|
||||
|
||||
export type Theme = 'dark' | 'light';
|
||||
|
||||
@@ -193,19 +193,20 @@ export function ThemeProvider({ children }: { children: ReactNode }) {
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const root = document.documentElement;
|
||||
root.style.setProperty('--body-bg', tokens.bodyBg);
|
||||
root.style.setProperty('--scroll-thumb', tokens.scrollThumb);
|
||||
root.style.setProperty('--glow-color', tokens.accentGlow);
|
||||
root.style.setProperty('--hover-bg', tokens.tableRowHover);
|
||||
document.body.style.background = tokens.bodyBgImage;
|
||||
document.body.style.color = tokens.text;
|
||||
}, [tokens]);
|
||||
|
||||
return (
|
||||
<ThemeContext.Provider value={{ theme, tokens, toggleTheme }}>
|
||||
{children}
|
||||
<div style={{
|
||||
'--body-bg': tokens.bodyBg,
|
||||
'--scroll-thumb': tokens.scrollThumb,
|
||||
'--glow-color': tokens.accentGlow,
|
||||
'--hover-bg': tokens.tableRowHover,
|
||||
background: tokens.bodyBgImage,
|
||||
color: tokens.text,
|
||||
width: '100%',
|
||||
minHeight: '100vh',
|
||||
} as CSSProperties}>
|
||||
{children}
|
||||
</div>
|
||||
</ThemeContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user