refactor(projects): 消息提示增加等级区分
This commit is contained in:
@@ -28,6 +28,15 @@ function normalizeColorType(raw: unknown): string | null {
|
||||
return HEX_COLOR_PATTERN.test(trimmed) ? trimmed : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析字典项最终展示色(hex)。
|
||||
* 精确色 cssClass 优先(覆盖 colorType 落到语义色无法区分黄/橙等场景),其次 colorType;
|
||||
* 两者都不是合法 hex 时回落 null(默认渲染)。
|
||||
*/
|
||||
function resolveDisplayColor(colorType: unknown, cssClass: unknown): string | null {
|
||||
return normalizeColorType(cssClass) ?? normalizeColorType(colorType);
|
||||
}
|
||||
|
||||
function normalizeFrontendDictData(
|
||||
dictType: string,
|
||||
list: Api.Dict.FrontendDictData[],
|
||||
@@ -40,7 +49,7 @@ function normalizeFrontendDictData(
|
||||
dictType: item.dictType || dictType,
|
||||
sort: item.sort,
|
||||
status: item.status ?? 0,
|
||||
colorType: normalizeColorType(item.colorType),
|
||||
colorType: resolveDisplayColor(item.colorType, item.cssClass),
|
||||
remark: item.remark ?? null,
|
||||
createTime: 0
|
||||
}));
|
||||
@@ -54,7 +63,7 @@ function normalizeDictDataItem(item: Api.Dict.DictData, dictType: string): Api.D
|
||||
value: String(item.value),
|
||||
dictType: item.dictType || dictType,
|
||||
status: item.status ?? 0,
|
||||
colorType: normalizeColorType(item.colorType),
|
||||
colorType: resolveDisplayColor(item.colorType, item.cssClass),
|
||||
remark: item.remark ?? null
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user