fix: 添加默认助手会添加两个 #238
This commit is contained in:
parent
077a66c675
commit
5347f63aa8
@ -6,6 +6,7 @@ import { useAssistants, useDefaultAssistant } from '@renderer/hooks/useAssistant
|
||||
import { createAssistantFromAgent } from '@renderer/services/assistant'
|
||||
import { EVENT_NAMES, EventEmitter } from '@renderer/services/event'
|
||||
import { Agent, Assistant } from '@renderer/types'
|
||||
import { uuid } from '@renderer/utils'
|
||||
import { Divider, Input, InputRef, Modal, Tag } from 'antd'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
@ -36,7 +37,7 @@ const PopupContainer: React.FC<Props> = ({ resolve }) => {
|
||||
|
||||
const onCreateAssistant = async (agent: Agent) => {
|
||||
if (agent.id === 'default') {
|
||||
addAssistant(agent)
|
||||
addAssistant({ ...agent, id: uuid() })
|
||||
return
|
||||
}
|
||||
|
||||
@ -66,8 +67,7 @@ const PopupContainer: React.FC<Props> = ({ resolve }) => {
|
||||
open={open}
|
||||
onCancel={onCancel}
|
||||
afterClose={onClose}
|
||||
transitionName="ant-move-down"
|
||||
maskTransitionName="ant-fade"
|
||||
transitionName="ant-move-up"
|
||||
styles={{ content: { borderRadius: 20, padding: 0, overflow: 'hidden', paddingBottom: 20 } }}
|
||||
closeIcon={null}
|
||||
footer={null}>
|
||||
|
||||
@ -12,6 +12,7 @@ import { useTranslation } from 'react-i18next'
|
||||
import styled from 'styled-components'
|
||||
|
||||
import { HStack } from '../Layout'
|
||||
import { Scrollbar } from '../Scrollbar'
|
||||
|
||||
type MenuItem = Required<MenuProps>['items'][number]
|
||||
|
||||
@ -102,28 +103,28 @@ const PopupContainer: React.FC<PopupContainerProps> = ({ model, resolve }) => {
|
||||
/>
|
||||
</HStack>
|
||||
<Divider style={{ margin: 0, borderBlockStartWidth: 0.5 }} />
|
||||
<Container>
|
||||
{filteredItems.length > 0 ? (
|
||||
<StyledMenu
|
||||
items={filteredItems}
|
||||
selectedKeys={model ? [getModelUniqId(model)] : []}
|
||||
mode="inline"
|
||||
inlineIndent={6}
|
||||
/>
|
||||
) : (
|
||||
<EmptyState>
|
||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
|
||||
</EmptyState>
|
||||
)}
|
||||
</Container>
|
||||
<Scrollbar style={{ height: '50vh' }}>
|
||||
<Container>
|
||||
{filteredItems.length > 0 ? (
|
||||
<StyledMenu
|
||||
items={filteredItems}
|
||||
selectedKeys={model ? [getModelUniqId(model)] : []}
|
||||
mode="inline"
|
||||
inlineIndent={6}
|
||||
/>
|
||||
) : (
|
||||
<EmptyState>
|
||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
|
||||
</EmptyState>
|
||||
)}
|
||||
</Container>
|
||||
</Scrollbar>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
const Container = styled.div`
|
||||
height: 50vh;
|
||||
margin-top: 10px;
|
||||
overflow-y: auto;
|
||||
`
|
||||
|
||||
const StyledMenu = styled(Menu)`
|
||||
|
||||
@ -55,7 +55,6 @@ const PopupContainer: React.FC<Props> = ({ text, textareaProps, modalProps, reso
|
||||
width="60vw"
|
||||
style={{ maxHeight: '70vh' }}
|
||||
transitionName="ant-move-down"
|
||||
maskTransitionName="ant-fade"
|
||||
okText={t('common.save')}
|
||||
{...modalProps}
|
||||
open={open}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user