theme.ts
621 Bytes
// REQ-USR-004: 把 Design Token --color-primary(tokens.css,SSoT)对齐到 AntD colorPrimary。
// AntD 需要具体色值以派生主题色阶,这里在运行时读取 CSS 变量计算值,回退到 token 当前值。
const FALLBACK_PRIMARY = '#1890ff'; // = tokens.css --color-primary 当前值(仅作读取失败兜底)
export function readPrimaryColor(): string {
if (typeof document !== 'undefined' && document.documentElement) {
const v = getComputedStyle(document.documentElement)
.getPropertyValue('--color-primary')
.trim();
if (v) return v;
}
return FALLBACK_PRIMARY;
}