Przeglądaj źródła

Merge branch 'master' of http://59.110.91.129:3000/zhangmengying/AIClass

丸子 10 miesięcy temu
rodzic
commit
b53359870d
2 zmienionych plików z 30 dodań i 11 usunięć
  1. 5 6
      src/api/questions.js
  2. 25 5
      src/views/AIPainting.vue

+ 5 - 6
src/api/questions.js

@@ -59,12 +59,11 @@ export function CreatePainting (data){
   })
 }
 // 绘画
-export function PaintingGetMys (ids){
-  const convertedIds = ids.map(id => String(Number(id)));
-  console.log(convertedIds);
-  return axios({
+export async function PaintingGetMys(ids) {
+  return await axios({
     url: "bjdxWeb/ai/painting-get-mys",
     method: 'get',
-    params: { ids: convertedIds.join(',') }
+    data: {ids: ids.join(',')}
   })
-}
+}
+

+ 25 - 5
src/views/AIPainting.vue

@@ -22,6 +22,7 @@
               <div class="user-message" v-if="item.type === 'user'">
                 {{ item.content }}
               </div>
+
               <!-- AI生成图片对话框 -->
               <div class="ai-message" v-if="item.type !== 'user'">
                 {{ item.content }}
@@ -133,7 +134,7 @@ const inputMessage = ref('')
 // 发送消息函数
 const sendMessage = () => {
   if (inputMessage.value.trim()) {
-    messages.value.push(inputMessage.value.trim())
+    // messages.value.push(inputMessage.value.trim())
     inputMessage.value = ''
 
     let content = inputMessage.value.trim()
@@ -157,8 +158,8 @@ const sendMessage = () => {
     }).then(res => {
       console.log('生成图片', res)
       //目前写死调用已生成的图片,全部通了后再改
-      // inProgressImageMap.value[res.data] = {}
-      inProgressImageMap.value[260] = {}
+      inProgressImageMap.value[res.data] = {id:res.data,status:AiImageStatusEnum.IN_PROGRESS}
+      // inProgressImageMap.value[260] = {id:260,status:AiImageStatusEnum.IN_PROGRESS}
     })
   }
 }
@@ -177,12 +178,14 @@ import {
   ZoomOut
 } from '@element-plus/icons-vue'
 
+
 // const url =
 //   'https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg'
 // const srcList = [
 //   'https://fuss10.elemecdn.com/0/6f/e35ff375812e6b0020b6b4e8f9583jpeg.jpeg',
 // ]
 
+
 const imageAllList = ref([]) // 对话的消息列表
 const imageList = ref([]) // image 列表
 // 图片轮询相关的参数(正在生成中的)
@@ -191,14 +194,16 @@ const inProgressTimer = ref() // 生成中的 image 定时器,轮询生成进
 
 /** 轮询生成中的 image 列表 */
 const refreshWatchImages = async () => {
-  const imageIds = Object.keys(inProgressImageMap.value)
-  if (imageIds.length == 0) {
+  const imageIds = Object.keys(inProgressImageMap.value).map(Number)
+  if (imageIds.length === 0) {
     return
   }
   console.log('轮询生成中的 image 列表', imageIds)
+  console.log("轮询生成中的 image 列表",imageIds,imageIds.join(','))
   const list = await PaintingGetMys(imageIds)
   console.log('轮询生成中的 image 列表', list)
   const newWatchImages = {}
+
   // 添加空值检查
   if (list.data) {
     list.data.forEach(image => {
@@ -220,6 +225,21 @@ const refreshWatchImages = async () => {
     })
   }
   console.log('================', imageAllList)
+
+  list.data.forEach((image) => {
+    if (image.status === AiImageStatusEnum.IN_PROGRESS) {
+      newWatchImages[image.id] = image
+    } else {
+
+      imageAllList.value.pop();
+      imageAllList.value.push({
+        type: 'ai',
+        content: "已为您生成图片:",
+        imageList: image.picUrl,
+      })
+    }
+  })
+  console.log("================",imageAllList)
   inProgressImageMap.value = newWatchImages
 }