Merge branch 'main' of ssh://18.167.251.121:10002/aidlab/FiDA_Front
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onUnmounted, onMounted, nextTick } from 'vue'
|
||||
import { ref, reactive, computed, onUnmounted, onMounted, nextTick,watch } from 'vue'
|
||||
import List from './List.vue'
|
||||
import Input from '../../components/Input.vue'
|
||||
import { fetchAgentReply } from '@/api/agent'
|
||||
@@ -31,6 +31,8 @@
|
||||
const userStore = useUserInfoStore()
|
||||
const agentStore = useAgentStore()
|
||||
const projectStore = useProjectStore()
|
||||
|
||||
const emits = defineEmits(['update:sketchList'])
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
title: string
|
||||
@@ -41,6 +43,7 @@
|
||||
)
|
||||
|
||||
const messageList = ref([])
|
||||
|
||||
const listRef = ref()
|
||||
const isGenerating = ref(false)
|
||||
const isPaused = ref(false) // 标记是否为主动暂停
|
||||
@@ -58,6 +61,13 @@
|
||||
imageUrlList: []
|
||||
})
|
||||
|
||||
const sketchList = ref([])
|
||||
watch(sketchList, (newVal) => {
|
||||
console.log('添加图片链接--------');
|
||||
|
||||
emits('update:sketchList', newVal)
|
||||
}, { deep: true })
|
||||
|
||||
// 每次请求时创建新的 AbortController
|
||||
let abort: AbortController
|
||||
|
||||
@@ -81,9 +91,9 @@
|
||||
if (initialData) {
|
||||
// 等待页面渲染完成后自动发送初始消息
|
||||
params.configParams = {
|
||||
type: initialData.type ,
|
||||
type: initialData.type,
|
||||
region: initialData.area,
|
||||
style: initialData.style ,
|
||||
style: initialData.style,
|
||||
temperature: 0.7
|
||||
}
|
||||
handleSendMessage({
|
||||
@@ -97,10 +107,13 @@
|
||||
}
|
||||
})
|
||||
|
||||
const handleSendMessage = async (message: {
|
||||
text: string
|
||||
images: Array<{ url: string; name: string }>
|
||||
}, skipUserMessage = false) => {
|
||||
const handleSendMessage = async (
|
||||
message: {
|
||||
text: string
|
||||
images: Array<{ url: string; name: string }>
|
||||
},
|
||||
skipUserMessage = false
|
||||
) => {
|
||||
console.log('Message sent:', message)
|
||||
isPaused.value = false
|
||||
isGenerating.value = true
|
||||
@@ -197,6 +210,7 @@
|
||||
console.log('传输结束 end---', contentBody)
|
||||
aiMessage.streaming = false
|
||||
aiMessage.loading = false
|
||||
isGenerating.value = false
|
||||
flag = false
|
||||
break
|
||||
}
|
||||
@@ -217,12 +231,21 @@
|
||||
isNodeIdEvent = true
|
||||
// continue
|
||||
}
|
||||
console.log('event', event)
|
||||
if (event.includes('error')) {
|
||||
aiMessage.text = '出现错误,请重试'
|
||||
aiMessage.streaming = false
|
||||
aiMessage.loading = false
|
||||
isGenerating.value = false
|
||||
flag = false
|
||||
break
|
||||
}
|
||||
|
||||
const dataLines = event
|
||||
.split(/\n/)
|
||||
.filter((line) => line.startsWith('data:'))
|
||||
.map((line) => line.replace(/^data:\s*/, '').trim())
|
||||
console.log('dataLInes', dataLines)
|
||||
// console.log('dataLInes', dataLines)
|
||||
if (isNodeIdEvent) {
|
||||
params.versionID = dataLines[0]
|
||||
}
|
||||
@@ -232,10 +255,14 @@
|
||||
|
||||
try {
|
||||
const jsonData = JSON.parse(jsonText)
|
||||
|
||||
console.log('jsonData', jsonData);
|
||||
|
||||
// 赋值 project_id 和 version_id
|
||||
if (jsonData.project_id) params.projectID = jsonData.project_id
|
||||
if (jsonData.version_id) params.versionID = jsonData.version_id
|
||||
// if (jsonData.project_id) params.projectID = jsonData.project_id
|
||||
// if (jsonData.version_id) params.versionID = jsonData.version_id
|
||||
if (jsonData.image_url) {
|
||||
sketchList.value.push(jsonData.image_url)
|
||||
}
|
||||
if (
|
||||
jsonData.content &&
|
||||
jsonData.content.length > 0 &&
|
||||
@@ -243,6 +270,7 @@
|
||||
) {
|
||||
contentBody += jsonData.content
|
||||
aiMessage.text = contentBody
|
||||
aiMessage.loading = false
|
||||
}
|
||||
if (jsonData.type === 'end') {
|
||||
aiMessage.streaming = false
|
||||
|
||||
Reference in New Issue
Block a user