style: 输入框高度

This commit is contained in:
2026-02-24 11:17:01 +08:00
parent 4aecf739df
commit 8988a9b6ca
3 changed files with 4 additions and 63 deletions

View File

@@ -12,68 +12,8 @@ export interface AgentParamsType {
export const fetchAgentReply = (data: AgentParamsType): Promise<AgentResponse> => {
return request({
url: '/api/ai-design/chat',
method: 'post',
method: 'get',
data,
meta: { responseAll: true }
})
}
// 流式对话
export const fetchAgentReplyStream = async (
data: AgentParamsType,
onMessage: (chunk: string) => void,
onEnd: () => void
) => {
try {
const params = new URLSearchParams({
message: data.message,
threadId: data.threadId,
token: data.token,
configParams: JSON.stringify(data.configParams)
})
const response = await fetch(`/api/ai-design/chat?${params.toString()}`, {
method: 'GET'
})
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`)
}
const reader = response.body?.getReader()
if (!reader) {
throw new Error('Response body is not readable')
}
const decoder = new TextDecoder()
let buffer = ''
while (true) {
const { done, value } = await reader.read()
if (done) break
buffer += decoder.decode(value, { stream: true })
const lines = buffer.split('\n')
buffer = lines.pop() || '' // 保留不完整的行
for (const line of lines) {
console.log('line---', line)
const trimmedLine = line.trim()
if (trimmedLine.startsWith('data: ')) {
const chunk = trimmedLine.slice(6)
if (chunk === '[DONE]') {
onEnd()
return
} else {
onMessage(chunk)
}
}
}
}
onEnd()
} catch (error) {
console.error('Stream error:', error)
onEnd()
}
}

View File

@@ -77,8 +77,8 @@
})
messageList.value.push(aiMessage)
const threadId = '' //
console.log('token---', params.token, '参数---', params)
// const threadId = '' //
// console.log('token---', params.token, '参数---', params)
try {
const urlParams = new URLSearchParams<AgentParamsType>({

View File

@@ -512,6 +512,7 @@
}
.scroll-content {
display: flex;
flex: 1;
overflow-y: auto;
padding: 3.4rem 1.7rem 1.7rem;