bugfix: 图片加载问题
This commit is contained in:
@@ -345,9 +345,21 @@
|
|||||||
|
|
||||||
if (hasSketch) {
|
if (hasSketch) {
|
||||||
hasSketchEvent = true
|
hasSketchEvent = true
|
||||||
sketchList.value.push({
|
console.log('当前sketchList',sketchList.value);
|
||||||
[Object.keys(jsonData)[0]]: jsonData[Object.keys(jsonData)[0]]
|
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 索引
|
// 通知 Preview 有新 sketch 正在加载,传入 sketch 索引
|
||||||
MyEvent.emit('loading-sketch', sketchList.value.length - 1)
|
MyEvent.emit('loading-sketch', sketchList.value.length - 1)
|
||||||
MyEvent.emit('OpenSketch')
|
MyEvent.emit('OpenSketch')
|
||||||
@@ -377,7 +389,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (jsonData.type === 'end') {
|
if (jsonData.type === 'end') {
|
||||||
console.log('end------hasSketch', hasSketch)
|
|
||||||
aiMessage.streaming = false
|
aiMessage.streaming = false
|
||||||
aiMessage.loading = false
|
aiMessage.loading = false
|
||||||
isGenerating.value = false
|
isGenerating.value = false
|
||||||
@@ -387,7 +398,6 @@
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
// 检查是否为纯文本 [DONE]
|
// 检查是否为纯文本 [DONE]
|
||||||
if (jsonText.trim() === '[DONE]') {
|
if (jsonText.trim() === '[DONE]') {
|
||||||
console.log('done-----------hasSketch', hasSketch)
|
|
||||||
|
|
||||||
console.log('结束-----------------------')
|
console.log('结束-----------------------')
|
||||||
aiMessage.text = contentBody
|
aiMessage.text = contentBody
|
||||||
|
|||||||
@@ -45,14 +45,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- 已加载完成的 sketch 显示实际图片 -->
|
<!-- 已加载完成的 sketch 显示实际图片 -->
|
||||||
<img
|
<img
|
||||||
v-show="!pendingSketchIndexes.includes(index)"
|
|
||||||
v-img-loading="getImageSrc(item, index)"
|
v-img-loading="getImageSrc(item, index)"
|
||||||
@load="handleImageLoad(index)"
|
@load="handleImageLoad(index)"
|
||||||
/>
|
/>
|
||||||
<!-- 正在加载的 sketch 显示 loading gif overlay -->
|
<!-- 正在加载的 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" />
|
<img src="@/assets/images/sketch-loading.gif" alt="loading" />
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="type === 'url'">
|
<template v-else-if="type === 'url'">
|
||||||
@@ -119,8 +118,7 @@
|
|||||||
// 存储每个图片的加载状态
|
// 存储每个图片的加载状态
|
||||||
const loadedStatus = ref<boolean[]>([])
|
const loadedStatus = ref<boolean[]>([])
|
||||||
|
|
||||||
// 存储正在加载的 sketch 索引
|
|
||||||
const pendingSketchIndexes = ref<number[]>([])
|
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
@@ -138,7 +136,7 @@
|
|||||||
() => {
|
() => {
|
||||||
// 当 sketchList 变化时,重置加载状态
|
// 当 sketchList 变化时,重置加载状态
|
||||||
loadedStatus.value = new Array(combineSketchList.value.length).fill(false)
|
loadedStatus.value = new Array(combineSketchList.value.length).fill(false)
|
||||||
pendingSketchIndexes.value = []
|
// pendingSketchIndexes.value = []
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -210,12 +208,10 @@
|
|||||||
// 图片加载完成时触发
|
// 图片加载完成时触发
|
||||||
const handleImageLoad = (index: number) => {
|
const handleImageLoad = (index: number) => {
|
||||||
loadedStatus.value[index] = true
|
loadedStatus.value[index] = true
|
||||||
pendingSketchIndexes.value = pendingSketchIndexes.value.filter((i) => i !== index)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 图片加载失败时触发
|
// 图片加载失败时触发
|
||||||
const handleImageError = (index: number) => {
|
const handleImageError = (index: number) => {
|
||||||
pendingSketchIndexes.value = pendingSketchIndexes.value.filter((i) => i !== index)
|
|
||||||
console.error(`Failed to load sketch at index ${index}`)
|
console.error(`Failed to load sketch at index ${index}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,9 +268,9 @@
|
|||||||
const handleLoadingSketch = (sketchIndex?: number) => {
|
const handleLoadingSketch = (sketchIndex?: number) => {
|
||||||
showLoading.value = true
|
showLoading.value = true
|
||||||
// 记录正在加载的 sketch 索引
|
// 记录正在加载的 sketch 索引
|
||||||
if (sketchIndex !== undefined) {
|
// if (sketchIndex !== undefined) {
|
||||||
pendingSketchIndexes.value.push(sketchIndex)
|
// pendingSketchIndexes.value.push(sketchIndex)
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleClickUrl = (item: { url: string; title: string }) => {
|
const handleClickUrl = (item: { url: string; title: string }) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user