Skip to content

Commit 7c4a1c9

Browse files
committed
fix: update ui
1 parent 5eb53e9 commit 7c4a1c9

File tree

2 files changed

+65
-12
lines changed

2 files changed

+65
-12
lines changed

packages/plugins/robot/src/Home.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,23 @@ onMounted(async () => {
221221
.operations-setting {
222222
font-size: 20px;
223223
}
224-
@media (min-width: 1280px) {
224+
&::-webkit-scrollbar {
225+
width: 0;
226+
height: 0;
227+
}
228+
@media (min-width: 1080px) {
225229
:deep(.robot-chat-container-content) {
226-
width: 1280px;
230+
width: 1080px;
227231
margin: 0 auto;
228232
}
229-
:deep(.footer-sender) {
230-
width: 1280px;
233+
:deep(.tiny-sender) {
234+
width: 1080px;
231235
margin: 0 auto;
232236
padding: 20px 15px;
233237
}
238+
:deep(.tr-prompts) {
239+
padding: 0px 136px;
240+
}
234241
}
235242
}
236243
</style>

packages/plugins/robot/src/components/RobotChat.vue

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
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: 0px 12px 10px">历史对话</h3></div>
15+
<div><h3 style="padding-left: 12px">历史对话</h3></div>
1016
<tr-icon-button
1117
:icon="IconClose"
1218
size="28"
@@ -55,7 +61,7 @@
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'
103109
import MarkdownRenderer from '../mcp/MarkdownRenderer.vue'
104110
import { 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
}
204214
const aiAvatar = getSvgIcon('AI')
205-
const userAvatar = getSvgIcon('user-head', { color: '#dfe1e6' })
206215
const welcomeIcon = getSvgIcon('AI', { fontSize: '48px' })
207216
208217
const contentRenderers: Record<string, Component> = {
209218
markdown: MarkdownRenderer,
210-
loading: LoadingRenderer
219+
loading: LoadingRenderer,
220+
...bubbleRenderers
211221
}
212222
213223
const 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+
288303
const 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

Comments
 (0)