mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-24 10:40:07 +08:00
refactor(agent): replace agent type label map with switch statement
Simplify agent type label handling by replacing the map with a direct switch statement. Also update related type references and array type assertions for consistency.
This commit is contained in:
parent
bd6428d473
commit
8cd40a471e
@ -1,5 +1,5 @@
|
||||
import ClaudeAvatar from '@renderer/assets/images/models/claude.png'
|
||||
import { AgentBase, AgentEntity } from '@renderer/types'
|
||||
import { AgentBase, AgentType } from '@renderer/types'
|
||||
|
||||
// base agent config. no default config for now.
|
||||
const DEFAULT_AGENT_CONFIG: Omit<AgentBase, 'model'> = {
|
||||
@ -11,7 +11,7 @@ export const DEFAULT_CLAUDE_CODE_CONFIG: Omit<AgentBase, 'model'> = {
|
||||
...DEFAULT_AGENT_CONFIG
|
||||
} as const
|
||||
|
||||
export const getAgentAvatar = (type: AgentEntity['type']): string => {
|
||||
export const getAgentAvatar = (type: AgentType): string => {
|
||||
switch (type) {
|
||||
case 'claude-code':
|
||||
return ClaudeAvatar
|
||||
|
||||
@ -346,10 +346,11 @@ export const getBuiltinOcrProviderLabel = (key: BuiltinOcrProviderId) => {
|
||||
else return getLabel(builtinOcrProviderKeyMap, key)
|
||||
}
|
||||
|
||||
const agentTypeKeyMap = {
|
||||
'claude-code': 'Claude Code'
|
||||
} as const satisfies Record<AgentType, string>
|
||||
|
||||
export const getAgentTypeLabel = (key: AgentType) => {
|
||||
return getLabel(agentTypeKeyMap, key, t('agent.type.unknown'))
|
||||
switch (key) {
|
||||
case 'claude-code':
|
||||
return 'Claude Code'
|
||||
default:
|
||||
return 'Unknown Type'
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,8 +53,8 @@ const AgentSettingPopupContainer: React.FC<AgentSettingPopupParams> = ({ tab, ag
|
||||
key: 'prompt',
|
||||
label: t('agent.settings.prompt')
|
||||
}
|
||||
] satisfies { key: AgentSettingPopupTab; label: string }[]
|
||||
).filter(Boolean) as { key: string; label: string }[]
|
||||
] as const satisfies { key: AgentSettingPopupTab; label: string }[]
|
||||
).filter(Boolean)
|
||||
|
||||
const ModalContent = () => {
|
||||
if (!agent) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user