From df01af06565f39544d646fef0e2e68a8c6a03f8f Mon Sep 17 00:00:00 2001 From: rd <1344903914@qq.com> Date: Thu, 21 Aug 2025 11:40:36 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E9=80=BB=E8=BE=91=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/xt-chat/xt-bubble/style.scss | 5 +- src/components/xt-chat/xt-bubble/types.ts | 13 +++-- .../xt-chat/xt-bubble/xt-bubble.vue | 12 ++--- .../components/conversation-detail/index.vue | 53 ++++++++++++++++--- .../home/components/sender-input/index.vue | 4 +- 5 files changed, 66 insertions(+), 21 deletions(-) diff --git a/src/components/xt-chat/xt-bubble/style.scss b/src/components/xt-chat/xt-bubble/style.scss index cf36a5f..e2ad047 100644 --- a/src/components/xt-chat/xt-bubble/style.scss +++ b/src/components/xt-chat/xt-bubble/style.scss @@ -32,7 +32,10 @@ .xt-bubble-content { display: flex; - align-items: center; + flex-direction: column; + align-items: flex-start; + min-width: 0; + max-width: 100%; @include cts; &-filled { background-color: #f2f3f5; diff --git a/src/components/xt-chat/xt-bubble/types.ts b/src/components/xt-chat/xt-bubble/types.ts index 4c3f96e..cd4ab45 100644 --- a/src/components/xt-chat/xt-bubble/types.ts +++ b/src/components/xt-chat/xt-bubble/types.ts @@ -70,7 +70,8 @@ export interface _AvatarProps extends AvatarProps { * 气泡组件属性接口 * 定义气泡组件的所有可配置属性 */ -export interface BubbleProps extends /* @vue-ignore */ Omit { +export interface BubbleProps + extends /* @vue-ignore */ Omit { /** 组件前缀类名 */ prefixCls?: string; /** 根元素的自定义类名 */ @@ -102,9 +103,13 @@ export interface BubbleProps ext /** 打字完成时的回调函数 */ onTypingComplete?: VoidFunction; /** 头部内容:可以是VNode、字符串或渲染函数 */ - header?: AvoidValidation VNode | string)>; + header?: AvoidValidation< + VNode | string | ((params: { content: ContentType; info: SlotInfoType; item: BubbleProps }) => VNode | string) + >; /** 底部内容:可以是VNode、字符串或渲染函数 */ - footer?: AvoidValidation VNode | string)>; + footer?: AvoidValidation< + VNode | string | ((params: { content: ContentType; info: SlotInfoType; item: BubbleProps }) => VNode | string) + >; } /** @@ -183,4 +188,4 @@ export interface BubbleListProps extends /* @vue-ignore */ HTMLAttributes { autoScroll?: boolean; /** 角色配置:定义不同角色的气泡样式 */ roles?: AvoidValidation; -} \ No newline at end of file +} diff --git a/src/components/xt-chat/xt-bubble/xt-bubble.vue b/src/components/xt-chat/xt-bubble/xt-bubble.vue index 43e08c8..4d1c640 100644 --- a/src/components/xt-chat/xt-bubble/xt-bubble.vue +++ b/src/components/xt-chat/xt-bubble/xt-bubble.vue @@ -85,16 +85,16 @@ export default defineComponent({ const renderHeader = () => { const info: SlotInfoType = { key: props._key }; - if (slots.header) return slots.header({ content: typedContent.value as any, info }) as any; - const h = props.header as any; - return typeof h === 'function' ? h(typedContent.value as any, info) : h; + if (slots.header) return slots.header({ content: typedContent.value as any, info, item: props }) as any; + const h = props.header; + return typeof h === 'function' ? h({ content: typedContent.value as any, info, item: props }) : h; }; const renderFooter = () => { const info: SlotInfoType = { key: props._key }; - if (slots.footer) return slots.footer({ content: typedContent.value as any, info }) as any; - const f = props.footer as any; - return typeof f === 'function' ? f(typedContent.value as any, info) : f; + if (slots.footer) return slots.footer({ content: typedContent.value as any, info, item: props }) as any; + const f = props.footer; + return typeof f === 'function' ? f({ content: typedContent.value as any, info, item: props }) : f; }; return () => ( diff --git a/src/views/home/components/conversation-detail/index.vue b/src/views/home/components/conversation-detail/index.vue index 290e22c..3f8aaa8 100644 --- a/src/views/home/components/conversation-detail/index.vue +++ b/src/views/home/components/conversation-detail/index.vue @@ -1,11 +1,13 @@