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