feat: bubble 组件调整

This commit is contained in:
rd
2025-08-21 16:26:57 +08:00
parent df01af0656
commit cb9b0715b1
10 changed files with 302 additions and 38 deletions

View File

@ -24,7 +24,7 @@ export default defineComponent({
name: 'BubbleList',
inheritAttrs: false,
props: {} as any,
setup(_, { attrs, slots }) {
setup(_, { attrs, slots, expose }) {
const props = attrs as unknown as BubbleListProps & { class?: any; style?: any };
const passThroughAttrs = useAttrs();
@ -48,7 +48,7 @@ export default defineComponent({
const listRef = ref<HTMLDivElement | null>(null);
const bubbleRefs = ref<Record<string | number, BubbleRef>>({});
const listPrefixCls = 'xt-bubble-list'
const listPrefixCls = 'xt-bubble-list';
const [initialized, setInitialized] = useState(false);
watchPostEffect(() => {
@ -102,6 +102,19 @@ export default defineComponent({
});
const context = computed(() => ({ onUpdate: onBubbleUpdate }));
// 暴露控制方法
const abortTypingByKey = (key: string | number) => {
bubbleRefs.value[key]?.abortTyping?.();
};
// 对外暴露能力
expose({
nativeElement: listRef as any,
abortTypingByKey,
scrollTo: (info: any) => {
unref(listRef)?.scrollTo?.(info);
},
});
return () => (
<BubbleContextProvider value={context.value}>
<div