diff --git a/src/chat-action/action.tsx b/src/chat-action/action.tsx
index ca80f1a6..219b6230 100644
--- a/src/chat-action/action.tsx
+++ b/src/chat-action/action.tsx
@@ -145,21 +145,42 @@ export const renderActions = (
const arrayActions: TdChatActionItem[] =
Array.isArray(actionBar) && actionBar.length > 0
- ? actionBar.map((action) => presetActions().find((item) => item.name === action))
+ ? actionBar.map((action) => {
+ // 兼容preset的旧逻辑
+ if (typeof action === 'string') {
+ return presetActions().find((item) => item.name === action);
+ }
+ return action;
+ })
: presetActions();
return (
- {arrayActions.map((item, index) =>
- item.name === 'replay' && index + 1 !== arrayActions.length ? (
-
- {item.render}
-
-
- ) : (
- item.render
- ),
- )}
+ {arrayActions.map((item, index) => {
+ if (!item) return null;
+ if (item.name === 'replay' && index + 1 !== arrayActions.length) {
+ return (
+
+ {item.render}
+
+
+ );
+ }
+ // preset action
+ if (item.render) return item.render;
+ // custom action
+ if (item.name) {
+ if (item.ignoreWrapper) {
+ return
;
+ }
+ return (
+
+
+
+ );
+ }
+ return null;
+ })}
);
};
diff --git a/src/chat-action/type.ts b/src/chat-action/type.ts
index 33c8bb60..093cb01a 100644
--- a/src/chat-action/type.ts
+++ b/src/chat-action/type.ts
@@ -7,6 +7,7 @@ export type TdChatActionsName = 'copy' | 'good' | 'bad' | 'replay' | 'share';
export type TdChatActionItem = {
name: TdChatActionsName;
render: TNode;
+ ignoreWrapper?: boolean;
};
interface ChatActionProps {