36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
/**
|
|
* Element Plus 主题对齐映射(module 13 task 242):把 Element 默认语义色/圆角
|
|
* 对齐 admin.html 蓝白浅色皮肤。main.css 用 elCssVars() 的结果承载 --el-* 变量;
|
|
* tests 用本模块校验值正确且已落盘,防止 Element 默认红绿黄(#f56c6c/#67c23a/#e6a23c)回潮。
|
|
*/
|
|
export const EP_ALIGN = {
|
|
primary: '#4f78a5',
|
|
success: '#4e806d',
|
|
warning: '#a8793e',
|
|
danger: '#b35f6a',
|
|
borderColor: '#d8e3ee',
|
|
borderRadiusBase: '9px',
|
|
} as const
|
|
|
|
export type EpAlignKey = keyof typeof EP_ALIGN
|
|
|
|
export function elCssVarName(key: EpAlignKey): string {
|
|
if (key === 'borderColor') return '--el-border-color'
|
|
if (key === 'borderRadiusBase') return '--el-border-radius-base'
|
|
return `--el-color-${key}`
|
|
}
|
|
|
|
/** 需要落盘到 main.css 的 --el-* 变量(key -> CSS 值)。 */
|
|
export function elCssVars(): Record<string, string> {
|
|
const out: Record<string, string> = {}
|
|
for (const key of Object.keys(EP_ALIGN) as EpAlignKey[]) {
|
|
out[elCssVarName(key)] = EP_ALIGN[key]
|
|
}
|
|
// danger/success/warning 的 light 家族 Element 不会自动从 base 推导覆盖,
|
|
// 显式对齐成浅色调(供标签/提示等底色使用),避免仍偏默认色。
|
|
out['--el-color-success-light-9'] = '#eef5f0'
|
|
out['--el-color-warning-light-9'] = '#fbf4ea'
|
|
out['--el-color-danger-light-9'] = '#faf0f1'
|
|
return out
|
|
}
|