refactor(theme): buildThemeConfig 改为对象参数,algorithm 支持紧凑模式组合

This commit is contained in:
2026-06-06 22:42:18 +08:00
parent 91ae52320b
commit eccc3f62d2
2 changed files with 57 additions and 3 deletions

View File

@@ -2,9 +2,15 @@ import { theme } from "antd";
import type { EffectiveTheme } from "../hooks/use-theme-preference";
export function buildThemeConfig(effectiveTheme: EffectiveTheme) {
interface BuildThemeConfigOptions {
compact?: boolean;
effectiveTheme: EffectiveTheme;
}
export function buildThemeConfig({ compact = false, effectiveTheme }: BuildThemeConfigOptions) {
const isDark = effectiveTheme === "dark";
const algorithm = isDark ? theme.darkAlgorithm : theme.defaultAlgorithm;
const baseAlgorithm = isDark ? theme.darkAlgorithm : theme.defaultAlgorithm;
const algorithm = compact ? [baseAlgorithm, theme.compactAlgorithm] : [baseAlgorithm];
return {
algorithm,
@@ -27,7 +33,7 @@ export function buildThemeConfig(effectiveTheme: EffectiveTheme) {
borderRadius: 10,
colorLink: isDark ? "#a3a3a3" : "#0a0a0a",
colorPrimary: isDark ? "#525252" : "#0a0a0a",
controlHeight: 36,
controlHeight: compact ? 28 : 36,
},
};
}