Commit 10f4292f authored by Administrator's avatar Administrator

优化

parent 701e61fb
...@@ -19,6 +19,7 @@ const title = ref('元芒数字') ...@@ -19,6 +19,7 @@ const title = ref('元芒数字')
// 对话数据 // 对话数据
const chatSessionId = ref('') const chatSessionId = ref('')
const chatMessages = ref<Array<{role: string, content: string}>>([]) const chatMessages = ref<Array<{role: string, content: string}>>([])
const inputMessageRef = ref()
const inputMessage = ref('') const inputMessage = ref('')
const loading = ref(false) const loading = ref(false)
...@@ -40,7 +41,8 @@ onMounted(async () => { ...@@ -40,7 +41,8 @@ onMounted(async () => {
const scrollToBottom = () => { const scrollToBottom = () => {
nextTick(() => { // 确保在DOM更新后执行 nextTick(() => { // 确保在DOM更新后执行
if (chatContainerRef.value) { if (chatContainerRef.value) {
chatContainerRef.value.scrollTop = chatContainerRef.value.scrollHeight // 这里自动将光标聚焦到输入框
inputMessageRef.value.focus()
} }
}) })
} }
...@@ -52,7 +54,7 @@ const onInitSubmit = async () => { ...@@ -52,7 +54,7 @@ const onInitSubmit = async () => {
let param: any = {} let param: any = {}
await aiAgentService.commonApi('初始化session', 'Cooking Eating shopping buddy/init', param) await aiAgentService.commonApi('初始化session', 'Cooking Eating shopping buddy/init', param)
.then((response) => { .then((response) => {
console.log(response) // console.log(response)
// 初始化成功后清空聊天记录 // 初始化成功后清空聊天记录
chatSessionId.value = response.session_id || '' chatSessionId.value = response.session_id || ''
chatMessages.value.push({ chatMessages.value.push({
...@@ -209,6 +211,7 @@ const renderMarkdown = (content: string) => { ...@@ -209,6 +211,7 @@ const renderMarkdown = (content: string) => {
<!-- 输入区域 --> <!-- 输入区域 -->
<div class="input-container"> <div class="input-container">
<el-input <el-input
ref="inputMessageRef"
v-model="inputMessage" v-model="inputMessage"
type="textarea" type="textarea"
:autosize="{ minRows: 2, maxRows: 4 }" :autosize="{ minRows: 2, maxRows: 4 }"
...@@ -331,10 +334,6 @@ const renderMarkdown = (content: string) => { ...@@ -331,10 +334,6 @@ const renderMarkdown = (content: string) => {
max-width: 80%; max-width: 80%;
// 处理Markdown渲染后的元素样式 // 处理Markdown渲染后的元素样式
:deep(p) {
margin: 0 0 10px 0;
}
:deep(ul), :deep(ol) { :deep(ul), :deep(ol) {
padding-left: 20px; padding-left: 20px;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment