Skip to content

Commit eb1b172

Browse files
committed
feat(provider): 使用 SmartProviderIcon 替换 ModelIcon 以优化图标显示
1 parent e6f822a commit eb1b172

3 files changed

Lines changed: 16 additions & 12 deletions

File tree

src/components/chat/ModelSelector.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Search, Settings, Pin, PinOff, ChevronDown, ChevronRight, ChevronsDownU
44
import { ModelIcon } from '@lobehub/icons';
55
import { useTranslation } from 'react-i18next';
66
import { useProviderStore, useConversationStore, useSettingsStore, useUIStore } from '@/stores';
7+
import { SmartProviderIcon } from '@/lib/providerIcons';
78
import { getShortcutBinding, formatShortcutForDisplay } from '@/lib/shortcuts';
89
import { useVirtualizer } from '@tanstack/react-virtual';
910
import { getVisibleModelCapabilities } from '@/lib/modelCapabilities';
@@ -593,7 +594,7 @@ export function ModelSelector({ style, onSelect, overrideCurrentModel, children,
593594
onClick={() => toggleGroupExpand(row.provider.id)}
594595
>
595596
{isExpanded ? <ChevronDown size={14} /> : <ChevronRight size={14} />}
596-
<ModelIcon model={row.provider.models[0]?.model_id ?? row.provider.name} size={20} type="avatar" />
597+
<SmartProviderIcon provider={row.provider} size={20} type="avatar" />
597598
<span style={{ fontWeight: 600, fontSize: 13 }}>{row.provider.name}</span>
598599
<Tag style={{ fontSize: 11, lineHeight: '18px', padding: '0 6px', margin: 0 }}>{row.provider.models.length}</Tag>
599600
<div style={{ flex: 1 }} />

src/components/settings/ProviderDetail.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -671,16 +671,18 @@ export function ProviderDetail({ providerId }: ProviderDetailProps) {
671671
<Title level={4} className="!mb-0">
672672
{provider.name}
673673
</Title>
674-
<Button
675-
type="text"
676-
size="small"
677-
icon={<SquarePen size={14} />}
678-
onClick={() => {
679-
setEditProviderName(provider.name);
680-
setEditProviderType(provider.provider_type);
681-
setProviderEditModalOpen(true);
682-
}}
683-
/>
674+
{!provider.builtin_id && (
675+
<Button
676+
type="text"
677+
size="small"
678+
icon={<SquarePen size={14} />}
679+
onClick={() => {
680+
setEditProviderName(provider.name);
681+
setEditProviderType(provider.provider_type);
682+
setProviderEditModalOpen(true);
683+
}}
684+
/>
685+
)}
684686
</div>
685687
</div>
686688
</div>

src/components/shared/ModelSelect.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useMemo, useCallback } from 'react';
22
import { Select, theme } from 'antd';
33
import { ModelIcon } from '@lobehub/icons';
44
import { useProviderStore } from '@/stores';
5+
import { SmartProviderIcon } from '@/lib/providerIcons';
56

67
/** Parse a combined `providerId::modelId` value. */
78
export function parseModelValue(value: string | undefined) {
@@ -20,7 +21,7 @@ export function useGroupedModelOptions() {
2021
.map((p) => ({
2122
label: (
2223
<span style={{ display: 'inline-flex', alignItems: 'center', gap: 6 }}>
23-
<ModelIcon model={p.name} size={16} type="avatar" />
24+
<SmartProviderIcon provider={p} size={16} type="avatar" />
2425
{p.name}
2526
</span>
2627
),

0 commit comments

Comments
 (0)