fix(web): prompt editor

This commit is contained in:
zhaoying
2026-04-15 14:38:40 +08:00
parent 47c242e513
commit 71e5b6586a
4 changed files with 165 additions and 82 deletions

View File

@@ -0,0 +1,39 @@
import { forwardRef, useImperativeHandle, useState } from 'react'
import ChatContent from './ChatContent'
import type { ChatItem } from './types'
import type { ReactNode } from 'react'
export interface PromptChatPanelRef {
append: (item: ChatItem) => void
clear: () => void
}
interface PromptChatPanelProps {
classNames?: string
contentClassNames?: string
empty: ReactNode
labelFormat: (item: ChatItem) => any
}
const PromptChatPanel = forwardRef<PromptChatPanelRef, PromptChatPanelProps>((props, ref) => {
const [chatList, setChatList] = useState<ChatItem[]>([])
useImperativeHandle(ref, () => ({
append: (item) => setChatList(prev => [...prev, item]),
clear: () => setChatList([]),
}))
return (
<ChatContent
classNames={props.classNames}
contentClassNames={props.contentClassNames}
empty={props.empty}
data={chatList}
streamLoading={false}
labelPosition="top"
labelFormat={props.labelFormat}
/>
)
})
export default PromptChatPanel