This commit is contained in:
lzp
2026-03-31 14:36:14 +08:00
2 changed files with 21 additions and 15 deletions

View File

@@ -345,9 +345,21 @@
if (hasSketch) {
hasSketchEvent = true
sketchList.value.push({
[Object.keys(jsonData)[0]]: jsonData[Object.keys(jsonData)[0]]
console.log('当前sketchList',sketchList.value);
console.log('当前收到的sketch',jsonData,typeof jsonData);
// Object.keys(jsonData).forEach((key) => {
// sketchList.value.push(jsonData[key])
// })
Object.keys(jsonData).forEach((key) => {
if (!sketchList.value.some((item) => item[key])) {
sketchList.value.push({
[key]: jsonData[key]
})
}
})
// sketchList.value.push({
// [Object.keys(jsonData)[0]]: jsonData[Object.keys(jsonData)[0]]
// })
// 通知 Preview 有新 sketch 正在加载,传入 sketch 索引
MyEvent.emit('loading-sketch', sketchList.value.length - 1)
MyEvent.emit('OpenSketch')
@@ -377,7 +389,6 @@
}
}
if (jsonData.type === 'end') {
console.log('end------hasSketch', hasSketch)
aiMessage.streaming = false
aiMessage.loading = false
isGenerating.value = false
@@ -387,7 +398,6 @@
} catch (e) {
// 检查是否为纯文本 [DONE]
if (jsonText.trim() === '[DONE]') {
console.log('done-----------hasSketch', hasSketch)
console.log('结束-----------------------')
aiMessage.text = contentBody

View File

@@ -45,14 +45,13 @@
</div>
<!-- 已加载完成的 sketch 显示实际图片 -->
<img
v-show="!pendingSketchIndexes.includes(index)"
v-img-loading="getImageSrc(item, index)"
@load="handleImageLoad(index)"
/>
<!-- 正在加载的 sketch 显示 loading gif overlay -->
<div v-if="pendingSketchIndexes.includes(index)" class="loading-wrapper">
<!-- <div v-if="pendingSketchIndexes.includes(index)" class="loading-wrapper">
<img src="@/assets/images/sketch-loading.gif" alt="loading" />
</div>
</div> -->
</div>
</template>
<template v-else-if="type === 'url'">
@@ -119,8 +118,7 @@
// 存储每个图片的加载状态
const loadedStatus = ref<boolean[]>([])
// 存储正在加载的 sketch 索引
const pendingSketchIndexes = ref<number[]>([])
const props = withDefaults(
defineProps<{
@@ -138,7 +136,7 @@
() => {
// 当 sketchList 变化时,重置加载状态
loadedStatus.value = new Array(combineSketchList.value.length).fill(false)
pendingSketchIndexes.value = []
// pendingSketchIndexes.value = []
}
)
@@ -210,12 +208,10 @@
// 图片加载完成时触发
const handleImageLoad = (index: number) => {
loadedStatus.value[index] = true
pendingSketchIndexes.value = pendingSketchIndexes.value.filter((i) => i !== index)
}
// 图片加载失败时触发
const handleImageError = (index: number) => {
pendingSketchIndexes.value = pendingSketchIndexes.value.filter((i) => i !== index)
console.error(`Failed to load sketch at index ${index}`)
}
@@ -272,9 +268,9 @@
const handleLoadingSketch = (sketchIndex?: number) => {
showLoading.value = true
// 记录正在加载的 sketch 索引
if (sketchIndex !== undefined) {
pendingSketchIndexes.value.push(sketchIndex)
}
// if (sketchIndex !== undefined) {
// pendingSketchIndexes.value.push(sketchIndex)
// }
}
const handleClickUrl = (item: { url: string; title: string }) => {