From 15f60e8ce2865e2c578c2d7c747f8bac0931590a Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 23 Jan 2026 00:02:11 +0800 Subject: [PATCH] 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. --- src/components/ProviderIcon.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/ProviderIcon.tsx b/src/components/ProviderIcon.tsx index 0348d7f9..2628e4dd 100644 --- a/src/components/ProviderIcon.tsx +++ b/src/components/ProviderIcon.tsx @@ -39,9 +39,13 @@ export const ProviderIcon: React.FC = ({ }; }, [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 时才使用