mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-10 23:59:45 +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 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.
|
// base agent config. no default config for now.
|
||||||
const DEFAULT_AGENT_CONFIG: Omit<AgentBase, 'model'> = {
|
const DEFAULT_AGENT_CONFIG: Omit<AgentBase, 'model'> = {
|
||||||
@ -11,7 +11,7 @@ export const DEFAULT_CLAUDE_CODE_CONFIG: Omit<AgentBase, 'model'> = {
|
|||||||
...DEFAULT_AGENT_CONFIG
|
...DEFAULT_AGENT_CONFIG
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export const getAgentAvatar = (type: AgentEntity['type']): string => {
|
export const getAgentAvatar = (type: AgentType): string => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'claude-code':
|
case 'claude-code':
|
||||||
return ClaudeAvatar
|
return ClaudeAvatar
|
||||||
|
|||||||
@ -346,10 +346,11 @@ export const getBuiltinOcrProviderLabel = (key: BuiltinOcrProviderId) => {
|
|||||||
else return getLabel(builtinOcrProviderKeyMap, key)
|
else return getLabel(builtinOcrProviderKeyMap, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
const agentTypeKeyMap = {
|
|
||||||
'claude-code': 'Claude Code'
|
|
||||||
} as const satisfies Record<AgentType, string>
|
|
||||||
|
|
||||||
export const getAgentTypeLabel = (key: AgentType) => {
|
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',
|
key: 'prompt',
|
||||||
label: t('agent.settings.prompt')
|
label: t('agent.settings.prompt')
|
||||||
}
|
}
|
||||||
] satisfies { key: AgentSettingPopupTab; label: string }[]
|
] as const satisfies { key: AgentSettingPopupTab; label: string }[]
|
||||||
).filter(Boolean) as { key: string; label: string }[]
|
).filter(Boolean)
|
||||||
|
|
||||||
const ModalContent = () => {
|
const ModalContent = () => {
|
||||||
if (!agent) {
|
if (!agent) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user