Explorar o código

处理获取绘画结果记录图片展示

liyanbo hai 1 ano
pai
achega
0f746afafa
Modificáronse 1 ficheiros con 18 adicións e 7 borrados
  1. 18 7
      src/views/AIPainting.vue

+ 18 - 7
src/views/AIPainting.vue

@@ -28,7 +28,6 @@
               <div class="ai-message" v-if="item.type !== 'user'">
 
                 {{ item.content }}
-                {{item.imageList}}
 
                 <div class="image-list" v-if="item.imageList">
                   <el-image
@@ -193,29 +192,41 @@ const refreshWatchImages = async () => {
       imageAllList.value.push({
         type: 'ai',
         content: "已为您生成图片:",
-        imageList: image.picUrl,
+        imageList: [image.picUrl],
       })
     }
   })
   console.log("================",imageAllList)
   inProgressImageMap.value = newWatchImages
+  if (newWatchImages.size === 0) {
+    inProgressTimerFun()
+  }
 }
 
 
 /** 组件挂在的时候 */
 onMounted(async () => {
-  // 自动刷新 image 列表
-  inProgressTimer.value = setInterval(async () => {
-    await refreshWatchImages()
-  }, 1000 * 3)
+  refreshWatchImagesFun()
 })
 
 /** 组件取消挂在的时候 */
 onUnmounted(async () => {
+  inProgressTimerFun()
+})
+
+// 自动刷新 image 列表
+const refreshWatchImagesFun = () => {
+  inProgressTimer.value = setInterval(async () => {
+    await refreshWatchImages()
+  }, 1000 * 3)
+}
+
+// 停止刷新image列表
+const inProgressTimerFun = () => {
   if (inProgressTimer.value) {
     clearInterval(inProgressTimer.value)
   }
-})
+}
 </script>
 
 <style scoped lang="scss">