feat: 🎸 在顶部的模型搜索框显示固定模型的供应商

This commit is contained in:
duanyongcheng 2025-03-07 14:56:00 +08:00 committed by Asurada
parent 8c3ce1a787
commit e8cba0ca01

View File

@ -130,19 +130,29 @@ const PopupContainer: React.FC<PopupContainerProps> = ({ model, resolve }) => {
if (pinnedModels.length > 0 && searchText.length === 0) { if (pinnedModels.length > 0 && searchText.length === 0) {
const pinnedItems = providers const pinnedItems = providers
.flatMap((p) => p.models || []) .flatMap((p) =>
.filter((m) => pinnedModels.includes(getModelUniqId(m))) p.models
.filter((m) => pinnedModels.includes(getModelUniqId(m)))
.map((m) => ({
key: getModelUniqId(m),
model: m,
provider: p
}))
)
.map((m) => ({ .map((m) => ({
key: getModelUniqId(m) + '_pinned', key: getModelUniqId(m.model) + '_pinned',
label: ( label: (
<ModelItem> <ModelItem>
<ModelNameRow> <ModelNameRow>
<span>{m?.name}</span> <ModelTags model={m} /> <span>
{m.model?.name} | {m.provider.isSystem ? t(`provider.${m.provider.id}`) : m.provider.name}
</span>{' '}
<ModelTags model={m.model} />
</ModelNameRow> </ModelNameRow>
<PinIcon <PinIcon
onClick={(e) => { onClick={(e) => {
e.stopPropagation() e.stopPropagation()
togglePin(getModelUniqId(m)) togglePin(getModelUniqId(m.model))
}} }}
isPinned={true}> isPinned={true}>
<PushpinOutlined /> <PushpinOutlined />
@ -150,12 +160,12 @@ const PopupContainer: React.FC<PopupContainerProps> = ({ model, resolve }) => {
</ModelItem> </ModelItem>
), ),
icon: ( icon: (
<Avatar src={getModelLogo(m?.id || '')} size={24}> <Avatar src={getModelLogo(m.model?.id || '')} size={24}>
{first(m?.name)} {first(m.model?.name)}
</Avatar> </Avatar>
), ),
onClick: () => { onClick: () => {
resolve(m) resolve(m.model)
setOpen(false) setOpen(false)
} }
})) }))