调整创建项目

This commit is contained in:
X1627315083
2025-05-22 14:26:47 +08:00
parent bcbcc252e1
commit 608a4dec89
13 changed files with 4545 additions and 48 deletions

View File

@@ -135,33 +135,39 @@ export default defineComponent({
let fileList = JSON.parse(JSON.stringify(data.filList))
let fileUrl = (fileList.filter((item:any)=>item.type == 'file').length > 0) ? fileList.filter((item:any)=>item.type == 'file')[0].minioPath : ''
let imageUrlList = (fileList.filter((item:any)=>item.type == 'image').length > 0)? fileList.filter((item:any)=>item.type == 'image').map((item:any)=>item.minioPath).join(',') : ''
// Https.axiosGet(Https.httpUrls.chatCreateProject, {params:{prompt:data.chatContent,process:data.selectFlow.value,fileUrl:fileUrl,imageUrlList}}).then((rv)=>{
// if(rv){
// data.loadingShow = false
// emit('newProject',rv)
// }
// }).catch(()=>{
// data.loadingShow = false
// })
let projectId = ''
const eventSource = new EventSource(`${process.env.VUE_APP_BASE_URL}${Https.httpUrls.llmStream}?token=${getCookie('token')}&prompt=${data.chatContent}&projectId=&fileUrl=${fileUrl}&imageUrlList=${imageUrlList}&enableThinking=${data.enableThinking}&process=${data.selectFlow.value}`);
eventSource.onmessage = function(event) {
let eventData = JSON.parse(event.data)
if(eventData.status == "[PROJECT_CREATE_SIGNAL]"){
projectId = JSON.parse(eventData.tools_data).projectId
}
};
eventSource.onerror = function(error) {
if (eventSource.readyState === EventSource.CLOSED) {
// data.chatList[data.chatList.length-1].content.message='服务器繁忙,请稍后再试。'
} else {
if(projectId){
emit('newProject',projectId)
Https.axiosGet(Https.httpUrls.chatCreateProject, {params:{prompt:data.chatContent,process:data.selectFlow.value,fileUrl:fileUrl,imageUrlList}}).then((rv)=>{
if(rv){
data.loadingShow = false
let value = {
id:rv,
fileList:fileList,
chatContent:data.chatContent,
enableThinking:data.enableThinking,
}
eventSource.close()
emit('newProject',value)
}
}).catch(()=>{
data.loadingShow = false
};
})
// let projectId = ''
// const eventSource = new EventSource(`${process.env.VUE_APP_BASE_URL}${Https.httpUrls.llmStream}?token=${getCookie('token')}&prompt=${data.chatContent}&projectId=&fileUrl=${fileUrl}&imageUrlList=${imageUrlList}&enableThinking=${data.enableThinking}&process=${data.selectFlow.value}`);
// eventSource.onmessage = function(event) {
// let eventData = JSON.parse(event.data)
// if(eventData.status == "[PROJECT_CREATE_SIGNAL]"){
// projectId = JSON.parse(eventData.tools_data).projectId
// }
// };
// eventSource.onerror = function(error) {
// if (eventSource.readyState === EventSource.CLOSED) {
// // data.chatList[data.chatList.length-1].content.message='服务器繁忙,请稍后再试。'
// } else {
// if(projectId){
// emit('newProject',projectId)
// }
// eventSource.close()
// }
// data.loadingShow = false
// };
}
const handleFileUpload = (event:any)=>{
if (event.target.files[0].size > 5 * 1024 * 1024) { // 5MB