mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-03-20 13:57:06 +08:00
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:
@@ -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 时才使用
|
||||
|
||||
Reference in New Issue
Block a user