mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-28 21:42:27 +08:00
refactor(agent): rename getAgentDefaultAvatar to getAgentTypeAvatar for clarity
Simplify avatar handling by removing default avatar logic and always using emoji icons
This commit is contained in:
parent
ff705d99b3
commit
7bd6c92f43
@ -11,7 +11,7 @@ export const DEFAULT_CLAUDE_CODE_CONFIG: Omit<AgentBase, 'model'> = {
|
||||
...DEFAULT_AGENT_CONFIG
|
||||
} as const
|
||||
|
||||
export const getAgentDefaultAvatar = (type: AgentType): string => {
|
||||
export const getAgentTypeAvatar = (type: AgentType): string => {
|
||||
switch (type) {
|
||||
case 'claude-code':
|
||||
return ClaudeAvatar
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Avatar } from '@heroui/react'
|
||||
import { getAgentDefaultAvatar } from '@renderer/config/agent'
|
||||
import { getAgentTypeAvatar } from '@renderer/config/agent'
|
||||
import { useUpdateAgent } from '@renderer/hooks/agents/useUpdateAgent'
|
||||
import { getAgentTypeLabel } from '@renderer/i18n/label'
|
||||
import { GetAgentResponse } from '@renderer/types'
|
||||
@ -30,7 +30,7 @@ const AgentEssentialSettings: FC<AgentEssentialSettingsProps> = ({ agent, update
|
||||
<SettingsItem inline>
|
||||
<SettingsTitle>{t('agent.type.label')}</SettingsTitle>
|
||||
<div className="flex items-center gap-2">
|
||||
<Avatar src={getAgentDefaultAvatar(agent.type)} className="h-6 w-6 text-lg" />
|
||||
<Avatar src={getAgentTypeAvatar(agent.type)} className="h-6 w-6 text-lg" />
|
||||
<span>{(agent?.name ?? agent?.type) ? getAgentTypeLabel(agent.type) : ''}</span>
|
||||
</div>
|
||||
</SettingsItem>
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { Avatar, AvatarProps, cn } from '@heroui/react'
|
||||
import { cn } from '@heroui/react'
|
||||
import Ellipsis from '@renderer/components/Ellipsis'
|
||||
import EmojiIcon from '@renderer/components/EmojiIcon'
|
||||
import { getAgentDefaultAvatar } from '@renderer/config/agent'
|
||||
import { getAgentTypeLabel } from '@renderer/i18n/label'
|
||||
import { AgentEntity, AgentSessionEntity, isAgentType } from '@renderer/types'
|
||||
import { AgentEntity, AgentSessionEntity } from '@renderer/types'
|
||||
import { Menu, Modal } from 'antd'
|
||||
import React, { ReactNode } from 'react'
|
||||
import styled from 'styled-components'
|
||||
@ -30,18 +29,14 @@ export type AgentLabelProps = {
|
||||
avatar?: string
|
||||
name?: string
|
||||
}
|
||||
avatarProps?: AvatarProps
|
||||
}
|
||||
|
||||
export const AgentLabel: React.FC<AgentLabelProps> = ({ agent, classNames, avatarProps }) => {
|
||||
const isDefault = isAgentType(agent?.configuration?.avatar)
|
||||
const src = isDefault ? getAgentDefaultAvatar(agent.type) : undefined
|
||||
const emoji = isDefault ? undefined : agent?.configuration?.avatar
|
||||
export const AgentLabel: React.FC<AgentLabelProps> = ({ agent, classNames }) => {
|
||||
const emoji = agent?.configuration?.avatar
|
||||
|
||||
return (
|
||||
<div className={cn('flex w-full items-center gap-2', classNames?.container)}>
|
||||
{isDefault && <Avatar src={src} {...avatarProps} className={cn('h-6 w-6 text-lg', classNames?.avatar)} />}
|
||||
{!isDefault && <EmojiIcon emoji={emoji || '⭐️'} className={classNames?.avatar} />}
|
||||
<EmojiIcon emoji={emoji || '⭐️'} className={classNames?.avatar} />
|
||||
<Ellipsis className={classNames?.name}>
|
||||
{agent?.name ?? (agent?.type ? getAgentTypeLabel(agent.type) : '')}
|
||||
</Ellipsis>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user