mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-10 07:19:02 +08:00
refactor(ui): remove unused UI elements and commented code
clean up UI by removing unused text spans and commented out code remove unused timer functionality from AgentModal
This commit is contained in:
parent
ec82eb2881
commit
2fc1df8793
@ -20,8 +20,6 @@ import { loggerService } from '@logger'
|
|||||||
import ClaudeIcon from '@renderer/assets/images/models/claude.png'
|
import ClaudeIcon from '@renderer/assets/images/models/claude.png'
|
||||||
import { useAddAgent } from '@renderer/hooks/agents/useAddAgent'
|
import { useAddAgent } from '@renderer/hooks/agents/useAddAgent'
|
||||||
import { useUpdateAgent } from '@renderer/hooks/agents/useUpdateAgent'
|
import { useUpdateAgent } from '@renderer/hooks/agents/useUpdateAgent'
|
||||||
import { useTimer } from '@renderer/hooks/useTimer'
|
|
||||||
import { EVENT_NAMES, EventEmitter } from '@renderer/services/EventService'
|
|
||||||
import { AddAgentForm, AgentEntity, AgentType, BaseAgentForm, isAgentType, UpdateAgentForm } from '@renderer/types'
|
import { AddAgentForm, AgentEntity, AgentType, BaseAgentForm, isAgentType, UpdateAgentForm } from '@renderer/types'
|
||||||
import { ChangeEvent, FormEvent, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
import { ChangeEvent, FormEvent, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
@ -85,7 +83,7 @@ export const AgentModal: React.FC<Props> = ({ agent, trigger, isOpen: _isOpen, o
|
|||||||
const { isOpen, onClose, onOpen } = useDisclosure({ isOpen: _isOpen, onClose: _onClose })
|
const { isOpen, onClose, onOpen } = useDisclosure({ isOpen: _isOpen, onClose: _onClose })
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const loadingRef = useRef(false)
|
const loadingRef = useRef(false)
|
||||||
const { setTimeoutTimer } = useTimer()
|
// const { setTimeoutTimer } = useTimer()
|
||||||
const { addAgent } = useAddAgent()
|
const { addAgent } = useAddAgent()
|
||||||
const { updateAgent } = useUpdateAgent()
|
const { updateAgent } = useUpdateAgent()
|
||||||
const isEditing = (agent?: AgentEntity) => agent !== undefined
|
const isEditing = (agent?: AgentEntity) => agent !== undefined
|
||||||
@ -245,7 +243,6 @@ export const AgentModal: React.FC<Props> = ({ agent, trigger, isOpen: _isOpen, o
|
|||||||
|
|
||||||
updateAgent(updatePayload)
|
updateAgent(updatePayload)
|
||||||
logger.debug('Updated agent', updatePayload)
|
logger.debug('Updated agent', updatePayload)
|
||||||
window.toast.success(t('common.update_success'))
|
|
||||||
} else {
|
} else {
|
||||||
const newAgent = {
|
const newAgent = {
|
||||||
type: form.type,
|
type: form.type,
|
||||||
@ -257,12 +254,11 @@ export const AgentModal: React.FC<Props> = ({ agent, trigger, isOpen: _isOpen, o
|
|||||||
} satisfies AddAgentForm
|
} satisfies AddAgentForm
|
||||||
addAgent(newAgent)
|
addAgent(newAgent)
|
||||||
logger.debug('Added agent', newAgent)
|
logger.debug('Added agent', newAgent)
|
||||||
window.toast.success(t('common.add_success'))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadingRef.current = false
|
loadingRef.current = false
|
||||||
|
|
||||||
setTimeoutTimer('onCreateAgent', () => EventEmitter.emit(EVENT_NAMES.SHOW_ASSISTANTS), 0)
|
// setTimeoutTimer('onCreateAgent', () => EventEmitter.emit(EVENT_NAMES.SHOW_ASSISTANTS), 0)
|
||||||
onClose()
|
onClose()
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
@ -273,7 +269,6 @@ export const AgentModal: React.FC<Props> = ({ agent, trigger, isOpen: _isOpen, o
|
|||||||
form.instructions,
|
form.instructions,
|
||||||
form.accessible_paths,
|
form.accessible_paths,
|
||||||
agent,
|
agent,
|
||||||
setTimeoutTimer,
|
|
||||||
onClose,
|
onClose,
|
||||||
t,
|
t,
|
||||||
updateAgent,
|
updateAgent,
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
import { AddAgentForm } from '@renderer/types'
|
import { AddAgentForm } from '@renderer/types'
|
||||||
|
|
||||||
export const useAddAgent = () => {
|
export const useAddAgent = () => {
|
||||||
|
// const { t } = useTranslation()
|
||||||
return {
|
return {
|
||||||
// oxlint-disable-next-line no-unused-vars
|
// oxlint-disable-next-line no-unused-vars
|
||||||
addAgent: (payload: AddAgentForm) => {
|
addAgent: (payload: AddAgentForm) => {
|
||||||
window.toast.info('Not implemented')
|
window.toast.info('Not implemented')
|
||||||
|
// window.toast.success(t('common.add_success'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ export const useUpdateAgent = () => {
|
|||||||
// oxlint-disable-next-line no-unused-vars
|
// oxlint-disable-next-line no-unused-vars
|
||||||
updateAgent: (payload: UpdateAgentForm) => {
|
updateAgent: (payload: UpdateAgentForm) => {
|
||||||
window.toast.info('Not implemented')
|
window.toast.info('Not implemented')
|
||||||
|
// window.toast.success(t('common.update_success'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,8 +29,7 @@ export const AgentsTab: FC<AssistantsTabProps> = () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="agents-tab h-full w-full">
|
<div className="agents-tab h-full w-full p-2">
|
||||||
<span className="mb-2 text-foreground-400 text-xs">{t('common.agent_other')}</span>
|
|
||||||
{agents.map((agent) => (
|
{agents.map((agent) => (
|
||||||
<AgentItem
|
<AgentItem
|
||||||
key={agent.id}
|
key={agent.id}
|
||||||
|
|||||||
@ -135,7 +135,6 @@ const Assistants: FC<AssistantsTabProps> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Container className="assistants-tab" ref={containerRef}>
|
<Container className="assistants-tab" ref={containerRef}>
|
||||||
<span className="mb-2 text-foreground-400 text-xs">{t('common.assistant_other')}</span>
|
|
||||||
<DraggableList
|
<DraggableList
|
||||||
list={assistants}
|
list={assistants}
|
||||||
onUpdate={updateAssistants}
|
onUpdate={updateAssistants}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user