From 61b61b88c758e503e7b6e17ee1f5f3602f4cdc86 Mon Sep 17 00:00:00 2001 From: Hanserwei <2628273921@qq.com> Date: Sat, 25 Oct 2025 17:28:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AF=B9=E8=AF=9D=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=A0=B7=E5=BC=8F=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=A4=B4?= =?UTF-8?q?=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/AiChatPage.vue | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/views/AiChatPage.vue b/src/views/AiChatPage.vue index b0dc5f5..d02aff4 100644 --- a/src/views/AiChatPage.vue +++ b/src/views/AiChatPage.vue @@ -18,6 +18,8 @@ import { ShareAltOutlined, SmileOutlined, } from '@ant-design/icons-vue' +import { UserOutlined } from '@ant-design/icons-vue' +import type { CSSProperties } from 'vue' import { Badge, Button, Flex, Space, theme } from 'ant-design-vue' import { Attachments, Bubble, Conversations, Prompts, Sender, Welcome } from 'ant-design-x-vue' import markdownit from 'markdown-it' @@ -75,8 +77,14 @@ md.use(markdownItHighlightJs, { md.use(MarkdownItMathJaX3PRO, { tex: { - inlineMath: [['$', '$'], ['\\(', '\\)']], - displayMath: [['$$', '$$'], ['\\[', '\\]']], + inlineMath: [ + ['$', '$'], + ['\\(', '\\)'], + ], + displayMath: [ + ['$$', '$$'], + ['\\[', '\\]'], + ], tags: 'ams', packages: ['base', 'ams', 'newcommand', 'configmacros'], }, @@ -251,8 +259,19 @@ const senderPromptsItems: PromptsProps['items'] = [ }, ] +const fooAvatar: CSSProperties = { + color: '#f56a00', + backgroundColor: '#fde3cf', +} + +const barAvatar: CSSProperties = { + color: '#fff', + backgroundColor: '#87d068', +} + const roles: BubbleListProps['roles'] = { ai: { + avatar: { icon: h(UserOutlined), style: fooAvatar }, placement: 'start', typing: false, // 禁用打字机动画,使用后端流式显示 styles: { @@ -265,6 +284,7 @@ const roles: BubbleListProps['roles'] = { }, }, local: { + avatar: { icon: h(UserOutlined), style: barAvatar }, placement: 'end', variant: 'shadow', }, @@ -324,7 +344,7 @@ async function sendMessage(userMessage: string) { console.log('[Request] 请求体:', JSON.stringify(requestBody, null, 2)) // 调用后端接口 - POST 请求 SSE 流式响应 - const response = await fetch('http://localhost:8080/dashscope/generateStream', { + const response = await fetch('http://localhost:8080/ai/chat', { method: 'POST', headers: { 'Content-Type': 'application/json',