🐛 fix(workbench): 统一 v2 工具中心与工作区主题

- 显式传递 uiVersion 构建 overlay theme,避免设置中心和工具中心混用旧版黄蓝色
- 统一 v2 模式下 Ant Design 主色和选中态为绿色语义
- 移除工具中心详情头部重复的返回上一步按钮
- 修复侧边树对象筛选反复切换时的 rc-tree 复用漂移
- 调整 v2 左侧树横向滚动条与首页空态布局,释放工作区展示空间
- 补充工具中心、主题 token 和侧边树 remount 的回归测试
This commit is contained in:
Syngnat
2026-07-01 18:11:08 +08:00
parent 749e543e37
commit 04a61a50dc
9 changed files with 205 additions and 99 deletions

View File

@@ -23,4 +23,14 @@ describe('buildOverlayWorkbenchTheme', () => {
const darkTheme = buildOverlayWorkbenchTheme(true, { disableBackdropFilter: true });
expect(darkTheme.shellBackdropFilter).toBe('none');
});
it('builds v2 theme tokens from explicit uiVersion instead of reading body state', () => {
const darkTheme = buildOverlayWorkbenchTheme(true, { uiVersion: 'v2' });
const lightTheme = buildOverlayWorkbenchTheme(false, { uiVersion: 'v2' });
expect(darkTheme.iconColor).toBe('#22c55e');
expect(darkTheme.selectedText).toBe('#4ade80');
expect(lightTheme.iconColor).toBe('#16a34a');
expect(lightTheme.selectedText).toBe('#15803d');
});
});

View File

@@ -1,15 +1,5 @@
import { resolveTextInputSafeBackdropFilter } from './appearance';
/**
* 是否处于 v2 界面版本。
* 读取 body[data-ui-version],由 App.tsx 在切换时设置。
* 在 SSR / 测试环境(无 document时安全 fallback 为 false。
*/
const isV2 = (): boolean => {
if (typeof document === 'undefined' || !document.body) return false;
return document.body.getAttribute('data-ui-version') === 'v2';
};
type OverlayWorkbenchTheme = {
isDark: boolean;
shellBg: string;
@@ -30,15 +20,19 @@ type OverlayWorkbenchTheme = {
export const buildOverlayWorkbenchTheme = (
darkMode: boolean,
options?: { disableBackdropFilter?: boolean },
options?: {
disableBackdropFilter?: boolean;
uiVersion?: 'legacy' | 'v2';
},
): OverlayWorkbenchTheme => {
const shellBackdropFilter = resolveTextInputSafeBackdropFilter(
darkMode ? 'blur(18px)' : 'none',
options?.disableBackdropFilter ?? false,
);
const uiVersion = options?.uiVersion ?? 'legacy';
// ─── v2 palette ──────────────────────────────────────────────
if (isV2()) {
if (uiVersion === 'v2') {
if (darkMode) {
return {
isDark: true,