diff --git a/src/api/agent.ts b/src/api/agent.ts index 535248d..85043af 100644 --- a/src/api/agent.ts +++ b/src/api/agent.ts @@ -12,68 +12,8 @@ export interface AgentParamsType { export const fetchAgentReply = (data: AgentParamsType): Promise => { 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() - } -} diff --git a/src/stores/index.ts b/src/stores/index.ts index 92b3821..b5d3fe1 100644 --- a/src/stores/index.ts +++ b/src/stores/index.ts @@ -7,3 +7,4 @@ store.use(createPersistedState()) export default store export * from './global' export * from './userInfo' +export * from './projectData' diff --git a/src/stores/projectData.ts b/src/stores/projectData.ts new file mode 100644 index 0000000..80d8184 --- /dev/null +++ b/src/stores/projectData.ts @@ -0,0 +1,20 @@ +import { defineStore } from 'pinia' +import { ref, computed } from 'vue' +export const useProjectStore = defineStore('project', () => { + const state = ref({// 项目参数 + id: '', + }) + + const setProject = (obj: any) => { + for (const key in obj) { + if(state.value[key]){ + state.value[key] = obj[key] + } + } + } + + return { + state, + setProject, + } +}) diff --git a/src/views/home/agent/components/Agent.vue b/src/views/home/agent/components/Agent.vue index f79ea91..3b39c0c 100644 --- a/src/views/home/agent/components/Agent.vue +++ b/src/views/home/agent/components/Agent.vue @@ -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({ diff --git a/src/views/home/agent/components/Preview.vue b/src/views/home/agent/components/Preview.vue index fb95e88..5a60cd7 100644 --- a/src/views/home/agent/components/Preview.vue +++ b/src/views/home/agent/components/Preview.vue @@ -19,9 +19,6 @@
-
- -
@@ -32,6 +29,81 @@
# 一级标题 +
+ # 一级标题 +
+ # 一级标题 +
+ # 一级标题 +
+ # 一级标题 +
+ # 一级标题 +
+ # 一级标题 +
+ # 一级标题 +
+ # 一级标题 +
+ # 一级标题 +
+ # 一级标题
+ # 一级标题 +
+ # 一级标题
+ # 一级标题 +
+ # 一级标题
+ # 一级标题 +
+ # 一级标题
+ # 一级标题 +
+ # 一级标题
+ # 一级标题 +
+ # 一级标题
+ # 一级标题 +
+ # 一级标题
+ # 一级标题 +
+ # 一级标题
+ # 一级标题 +
+ # 一级标题
+ # 一级标题 +
+ # 一级标题
+ # 一级标题
+ # 一级标题 +
+ # 一级标题
+ # 一级标题 +
+ # 一级标题
+ # 一级标题 +
+ # 一级标题
+ # 一级标题 +
+ # 一级标题
+ # 一级标题 +
+ # 一级标题
+ # 一级标题 +
+ # 一级标题
+ # 一级标题 +
+ # 一级标题
+ # 一级标题 +
+ # 一级标题
+ # 一级标题 +
+ # 一级标题
@@ -113,6 +185,8 @@ justify-content: center; --border-width: 3px; flex: 1; + overflow: hidden; + height: 100%; &::before { content: ''; position: absolute; @@ -141,6 +215,7 @@ flex: 1; display: flex; flex-direction: column; + overflow: hidden; .downBtnBox{ padding: 2.2rem 5.2rem 0; .downBtn{ @@ -165,6 +240,8 @@ .content{ word-break: break-word; white-space: pre-wrap; + overflow-y: auto; + margin: 2rem; } } } diff --git a/src/views/home/agent/components/versionTree/index.vue b/src/views/home/agent/components/versionTree/index.vue index 26c6a3b..3e2b9ff 100644 --- a/src/views/home/agent/components/versionTree/index.vue +++ b/src/views/home/agent/components/versionTree/index.vue @@ -1,9 +1,11 @@