diff --git a/src/ChatItem/index.tsx b/src/ChatItem/index.tsx index f52e87f..e48e06c 100644 --- a/src/ChatItem/index.tsx +++ b/src/ChatItem/index.tsx @@ -37,6 +37,7 @@ const ChatItem = memo((props) => { text, chatItemRenderConfig, renderErrorMessages, + renderActions, markdownProps, onDoubleClick, originData, @@ -113,6 +114,8 @@ const ChatItem = memo((props) => { ]); const actionsDom = useMemo(() => { + console.log('renderActions', renderActions); + if (chatItemRenderConfig?.actionsRender === false) return null; if (error) return null; const dom = ( diff --git a/src/ChatItem/type.ts b/src/ChatItem/type.ts index e1c3531..ae44da2 100644 --- a/src/ChatItem/type.ts +++ b/src/ChatItem/type.ts @@ -1,5 +1,6 @@ import { ReactNode } from 'react'; +import { RenderAction } from '@/ChatList'; import { EditableMessageProps } from '@/EditableMessage'; import { ChatMessageError, DivProps, MetaData } from '@/types'; import { MarkdownProps } from '@ant-design/pro-editor'; @@ -59,6 +60,9 @@ export interface ChatItemProps> { */ primary?: boolean; renderMessage?: (content: ReactNode) => ReactNode; + renderActions?: { + [actionKey: string]: RenderAction; + }; /** * @description Whether to show the title of the chat item */ diff --git a/src/ChatList/ChatListItem.tsx b/src/ChatList/ChatListItem.tsx index d0280a7..ae55e12 100644 --- a/src/ChatList/ChatListItem.tsx +++ b/src/ChatList/ChatListItem.tsx @@ -195,12 +195,16 @@ const ChatListItem = (props: ChatListItemProps) => { * @returns 渲染操作按钮的组件。 */ const Actions = useRefFunction(({ data }: { data: ChatMessage }) => { + console.log('renderActions', renderActions); + if (!renderActions || !item?.role) return; let RenderFunction; if (renderActions?.[item.role]) RenderFunction = renderActions[item.role]; if (renderActions?.['default']) RenderFunction = renderActions['default']; if (!RenderFunction) RenderFunction = ActionsBar; + console.log('data', data); + const handleActionClick: ListItemProps['onActionsClick'] = (action, data) => { switch (action.key) { case 'copy': { @@ -243,6 +247,7 @@ const ChatListItem = (props: ChatListItemProps) => { className={chatItemClassName} data-id={item.id} actions={} + renderActions={renderActions} avatar={(item as any).meta} avatarAddon={groupNav} editing={editing}