11<template >
2- <tr-container v-if =" robotVisible" v-model:fullscreen =" fullscreen" v-model:show =" robotVisible" class =" tiny-container" >
2+ <tr-container
3+ v-if =" robotVisible"
4+ v-model:fullscreen =" fullscreen"
5+ v-model:show =" robotVisible"
6+ title =" "
7+ class =" tiny-container"
8+ >
39 <template #operations >
410 <slot name =" operations" ></slot >
511 <tr-icon-button :icon =" IconNewSession" size =" 28" svgSize =" 20" @click =" createConversation()" />
612 <span style =" display : inline-flex ; line-height : 0 ; position : relative " >
713 <tr-icon-button :icon =" IconHistory" size =" 28" svgSize =" 20" @click =" showHistory = true" />
814 <div v-show =" showHistory" class =" tr-history-container" >
9- <div ><h3 style =" padding : 0 px 12px 10 px " >历史对话</h3 ></div >
15+ <div ><h3 style =" padding-left : 12px " >历史对话</h3 ></div >
1016 <tr-icon-button
1117 :icon =" IconClose"
1218 size =" 28"
5561 :showWordLimit =" true"
5662 :maxLength =" 4000"
5763 @submit =" handleSendMessage"
58- @cancel =" abortRequest "
64+ @cancel =" handleAbortRequest "
5965 :allowFiles =" singleAttachmentItems.length < 1 && allowFiles"
6066 uploadTooltip =" 支持上传1张图片"
6167 @files-selected =" handleSingleFilesSelected"
@@ -103,14 +109,18 @@ import LoadingRenderer from '../mcp/LoadingRenderer.vue'
103109import MarkdownRenderer from ' ../mcp/MarkdownRenderer.vue'
104110import { serializeError } from ' ../utils/common-utils'
105111
106- const { promptItems, allowFiles } = defineProps ({
112+ const { promptItems, allowFiles, bubbleRenderers } = defineProps ({
107113 promptItems: {
108114 type: Array as PropType <PromptProps []>,
109115 default : () => []
110116 },
111117 allowFiles: {
112118 type: Boolean ,
113119 default: false
120+ },
121+ bubbleRenderers: {
122+ type: Object as PropType <Record <string , Component >>,
123+ default : () => ({})
114124 }
115125})
116126
@@ -202,12 +212,12 @@ const getSvgIcon = (name: string, style?: CSSProperties) => {
202212 return h (resolveComponent (' svg-icon' ), { name , style: { fontSize: ' 32px' , ... style } })
203213}
204214const aiAvatar = getSvgIcon (' AI' )
205- const userAvatar = getSvgIcon (' user-head' , { color: ' #dfe1e6' })
206215const welcomeIcon = getSvgIcon (' AI' , { fontSize: ' 48px' })
207216
208217const contentRenderers: Record <string , Component > = {
209218 markdown: MarkdownRenderer ,
210- loading: LoadingRenderer
219+ loading: LoadingRenderer ,
220+ ... bubbleRenderers
211221}
212222
213223const roles: Record <string , BubbleRoleConfig > = {
@@ -219,7 +229,7 @@ const roles: Record<string, BubbleRoleConfig> = {
219229 },
220230 user: {
221231 placement: ' end' ,
222- avatar: userAvatar ,
232+ // avatar: userAvatar,
223233 contentRenderer: MarkdownRenderer
224234 },
225235 system: {
@@ -285,6 +295,11 @@ const handleSendMessage = async (content: string) => {
285295 }
286296}
287297
298+ const handleAbortRequest = () => {
299+ abortRequest ()
300+ messages .value .at (- 1 )! .renderContent .push ({ type: ' text' , content: ' 对话已取消' })
301+ }
302+
288303const handlePromptItemClick = (ev : unknown , item : { description? : string }) => {
289304 handleSendMessage (item .description )
290305}
@@ -319,17 +334,36 @@ defineExpose({
319334 background-color : white ;
320335 padding : 16px ;
321336 border-radius : 16px ;
337+ --tr-history-group-space-y : 0px ;
338+ :deep(.tr-history ) {
339+ height : calc (100% - 36px );
340+ overflow-y : auto ;
341+ }
342+ }
343+
344+ @container tiny- container (max-width : 640px ) {
345+ .tr-bubble-list {
346+ --tr-bubble-max-width : 100% ;
347+ :deep(.tr-bubble__avatar ) {
348+ display : none ;
349+ }
350+ }
322351}
323352
324353.tiny-container {
325354 top : 0px ;
355+ container- name: tiny- container;
326356 container- type: inline- size;
357+ --tv-size-scrollbar-width : 4px ;
358+ & .fullscreen {
359+ --tv-size-scrollbar-width : 0px ;
360+ --tv-size-scrollbar-height : 0px ;
361+ }
327362 :deep(.tr-welcome__title-wrapper ) {
328363 display : flex ;
329364 align-items : center ;
330365 justify-content : center ;
331366 }
332- container- type: inline- size;
333367
334368 & .tr-container.tr-container {
335369 --tr-container-width : 400px ;
@@ -386,6 +420,18 @@ defineExpose({
386420 background-color : #e6f7ff ;
387421 }
388422 }
423+ :deep([data- role= ' user' ]) {
424+ --tr-bubble-content-bg : var (--tr-color-primary-light );
425+ }
426+ }
427+
428+ & .fullscreen {
429+ :deep([data- role= ' assistant' ]) {
430+ --tr-bubble-content-bg : transparent ;
431+ .tr-bubble__content {
432+ padding : 8px 0 0 ;
433+ }
434+ }
389435 }
390436
391437 .robot-welcome > div {
0 commit comments