fix(ui): improve ProviderIcon color validation to prevent black icons

Enhance the effectiveColor logic in ProviderIcon to properly validate
the color prop before using it. Now only uses color when it's a valid
non-empty string, otherwise falls back to icon metadata defaultColor.

This fixes the issue where Gemini icons would turn black when selected
in ProviderCard due to null/undefined/empty string color values being
passed through.
This commit is contained in:
Jason
2026-01-23 00:02:11 +08:00
parent 3d733a3b80
commit 15f60e8ce2

View File

@@ -39,9 +39,13 @@ export const ProviderIcon: React.FC<ProviderIconProps> = ({
};
}, [size]);
// 获取有效颜色:优先使用传入的 color否则从元数据获取 defaultColor
// 获取有效颜色:优先使用传入的有效 color否则从元数据获取 defaultColor
const effectiveColor = useMemo(() => {
if (color) return color;
// 只有当 color 是有效的非空字符串时才使用
if (color && typeof color === 'string' && color.trim() !== '') {
return color;
}
// 否则从元数据获取 defaultColor
if (icon) {
const metadata = getIconMetadata(icon);
// 只有当 defaultColor 不是 currentColor 时才使用