From bfb4d0d60846e1137304342cb85d159c640cc2e3 Mon Sep 17 00:00:00 2001 From: "gaoyizhuo.gyz" Date: Wed, 12 Jun 2024 15:11:25 +0800 Subject: [PATCH] :zap: chore: update callbacks --- src/ChatItem/type.ts | 9 +- .../__test__/__snapshots__/demo.test.tsx.snap | 583 +++++++++++++++++- src/ProChat/__test__/index.test.tsx | 25 +- src/ProChat/components/ChatList/index.tsx | 10 +- src/ProChat/demos/actionsCallBack.tsx | 4 +- src/ProChat/demos/callbacks.tsx | 12 +- src/ProChat/store/reducers/message.test.ts | 6 +- 7 files changed, 613 insertions(+), 36 deletions(-) diff --git a/src/ChatItem/type.ts b/src/ChatItem/type.ts index 865c37cc..86ca8b07 100644 --- a/src/ChatItem/type.ts +++ b/src/ChatItem/type.ts @@ -2,6 +2,7 @@ import { ReactNode } from 'react'; import { ActionsProps } from '@/ChatList/ActionsBar'; import { EditableMessageProps } from '@/EditableMessage'; +import { OpenAIChatMessage } from '@/ProChat/types/chat'; import { ChatMessageError, DivProps, MetaData } from '@/types'; import { MarkdownProps } from '@ant-design/pro-editor'; @@ -104,11 +105,11 @@ export interface ChatItemProps> { ) => ReactNode >; actionsCallbacks?: { - onEditFinished?: (id?: string, value?: string) => void; - beforeDelFinished?: (id?: string) => void; - onRegenerateFinished?: (id?: string, error?: boolean) => void; + onEdit?: (id?: string, value?: string) => Promise | void; + onDelete?: (id?: string) => Promise | void; + onRegenerate?: (id?: string, error?: boolean) => Promise | void; }; - actionsProps?: Record; + actionsProps?: Record; }; renderErrorMessages?: (data: ChatMessageError) => ReactNode; diff --git a/src/ProChat/__test__/__snapshots__/demo.test.tsx.snap b/src/ProChat/__test__/__snapshots__/demo.test.tsx.snap index afe0649d..16e6ded6 100644 --- a/src/ProChat/__test__/__snapshots__/demo.test.tsx.snap +++ b/src/ProChat/__test__/__snapshots__/demo.test.tsx.snap @@ -280,6 +280,575 @@ exports[` > renders actions.tsx correctly 1`] = ` `; +exports[` > renders actionsCallBack.tsx correctly 1`] = ` + +
+
+
+
+
+
+
+ + avatar + +
+
+
+ Ant Design + +
+
+
+
+
+
+

+ 我对三体世界说话。 +

+
+
+
+
+
+ +
+
+
+
+
+
+ + +
+ 🛸 +
+
+
+
+
+
+ 三体世界 + +
+
+
+
+
+
+

+ 保持静默,不要回答,不要回答。 +

+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+ +
+
+