perf: 逻辑调整

This commit is contained in:
rd
2025-08-21 11:40:36 +08:00
parent 55166ff580
commit df01af0656
5 changed files with 66 additions and 21 deletions

View File

@ -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;

View File

@ -70,7 +70,8 @@ export interface _AvatarProps extends AvatarProps {
* 气泡组件属性接口
* 定义气泡组件的所有可配置属性
*/
export interface BubbleProps<ContentType extends BubbleContentType = string> extends /* @vue-ignore */ Omit<HTMLAttributes, 'content'> {
export interface BubbleProps<ContentType extends BubbleContentType = string>
extends /* @vue-ignore */ Omit<HTMLAttributes, 'content'> {
/** 组件前缀类名 */
prefixCls?: string;
/** 根元素的自定义类名 */
@ -102,9 +103,13 @@ export interface BubbleProps<ContentType extends BubbleContentType = string> ext
/** 打字完成时的回调函数 */
onTypingComplete?: VoidFunction;
/** 头部内容可以是VNode、字符串或渲染函数 */
header?: AvoidValidation<VNode | string | ((content: ContentType, info: SlotInfoType) => VNode | string)>;
header?: AvoidValidation<
VNode | string | ((params: { content: ContentType; info: SlotInfoType; item: BubbleProps<any> }) => VNode | string)
>;
/** 底部内容可以是VNode、字符串或渲染函数 */
footer?: AvoidValidation<VNode | string | ((content: ContentType, info: SlotInfoType) => VNode | string)>;
footer?: AvoidValidation<
VNode | string | ((params: { content: ContentType; info: SlotInfoType; item: BubbleProps<any> }) => VNode | string)
>;
}
/**
@ -183,4 +188,4 @@ export interface BubbleListProps extends /* @vue-ignore */ HTMLAttributes {
autoScroll?: boolean;
/** 角色配置:定义不同角色的气泡样式 */
roles?: AvoidValidation<RolesType>;
}
}

View File

@ -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 () => (