@@ -21,12 +21,12 @@ import {
2121 Divider ,
2222 Flex ,
2323 Space ,
24+ Tag ,
2425 Tooltip ,
2526 Typography ,
2627} from 'antd' ;
2728import _ from 'lodash' ;
2829import {
29- ArrowBigUp ,
3030 AtSign ,
3131 Command ,
3232 CornerDownLeft ,
@@ -40,6 +40,7 @@ import {
4040
4141import type { MESSAGE } from '@/services/message/typings' ;
4242import LexicalTextarea , { LexicalTextareaRefProperty } from '@/components/markdown/lexical/lexical-textarea' ;
43+ import { BOT } from '@/services/bot/typings' ;
4344
4445const ChatInput : React . FC < {
4546 onSubmit ?: ( values : MESSAGE . GenerateCmd ) => void ;
@@ -49,10 +50,12 @@ const ChatInput: React.FC<{
4950 className ?: string | undefined ;
5051 style ?: CSSProperties | undefined ;
5152} > = ( { onSubmit, onClearMemory, onStop, loading, className, style } ) => {
52- const lexicalTextareaRef = useRef < LexicalTextareaRefProperty > ( ) ;
53+ const lexicalTextareaRef = useRef < LexicalTextareaRefProperty > ( null ) ;
5354 const [ query , setQuery ] = useState ( '' ) ;
5455
55- const [ clearLoading , setClearLoading ] = useState ( false ) ;
56+ const [ mentions , setMentions ] = useState < BOT . BotEntity > ( ) ;
57+
58+ const [ clearMemoryLoading , setClearMemoryLoading ] = useState ( false ) ;
5659 const [ stopLoading , setStopLoading ] = useState ( false ) ;
5760
5861 const [ inputExpand , setInputExpand ] = useState ( false ) ;
@@ -61,6 +64,7 @@ const ChatInput: React.FC<{
6164 const content = markdown || query ;
6265 if ( ! _ . isEmpty ( _ . trim ( content ) ) ) {
6366 onSubmit ?.( {
67+ mentions : mentions ?. uid ? [ mentions . uid ] : undefined ,
6468 query : {
6569 inputs : [
6670 {
@@ -96,9 +100,16 @@ const ChatInput: React.FC<{
96100 align = "flex-start"
97101 style = { style }
98102 className = { `flex-auto rounded-xl bg-white py-4 w-full min-h-24` }
103+ gap = { 12 }
99104 >
105+ { /* @BOT */ }
106+ { mentions && < Flex justify = "flex-start" align = "center" className = "w-full px-4" gap = { 4 } >
107+ < Tag bordered = { false } closeIcon onClose = { ( ) => setMentions ( undefined ) } > @ { mentions . name } </ Tag >
108+ </ Flex > }
109+
110+ { /* 输入框 */ }
100111 < div
101- className = { `w-full min-h-12 px-5 mb-3 overflow-y-scroll transition-all duration-500 ${ inputExpand ? 'h-96' : 'max-h-40' } ` }
112+ className = { `w-full min-h-12 px-5 overflow-y-scroll transition-all duration-500 ${ inputExpand ? 'h-96' : 'max-h-40' } ` }
102113 onKeyDown = { ( event ) => {
103114 if ( ( event . metaKey || event . ctrlKey ) && event . key === 'Enter' ) {
104115 event . preventDefault ( ) ;
@@ -117,9 +128,7 @@ const ChatInput: React.FC<{
117128 botMentionOptions = { {
118129 enable : true ,
119130 trigger : '@' ,
120- onSelect : ( botFavorite ) => {
121- console . log ( '===1===' , botFavorite ) ;
122- } ,
131+ onSelect : setMentions ,
123132 } }
124133 />
125134 </ div >
@@ -133,12 +142,12 @@ const ChatInput: React.FC<{
133142 type = "text"
134143 className = "p-1"
135144 disabled = { loading }
136- loading = { clearLoading }
145+ loading = { clearMemoryLoading }
137146 icon = { < SquareSplitVertical size = { 18 } /> }
138147 onClick = { ( ) => {
139148 if ( ! ! onClearMemory ) {
140- setClearLoading ( true ) ;
141- onClearMemory ( ) . finally ( ( ) => setClearLoading ( false ) ) ;
149+ setClearMemoryLoading ( true ) ;
150+ onClearMemory ( ) . finally ( ( ) => setClearMemoryLoading ( false ) ) ;
142151 }
143152 } }
144153 />
0 commit comments