opt: optimize image preview for MidJourney image list page, only preview current image not for all images

This commit is contained in:
RockYang 2023-11-23 17:55:12 +08:00
parent 4813163eac
commit 67d30353f0

View File

@ -274,7 +274,7 @@
:src="scope.item.type === 'upscale'?scope.item['img_url']+'?imageView2/1/w/240/h/300/q/75':scope.item['img_url']+'?imageView2/1/w/240/h/240/q/75'" :src="scope.item.type === 'upscale'?scope.item['img_url']+'?imageView2/1/w/240/h/300/q/75':scope.item['img_url']+'?imageView2/1/w/240/h/240/q/75'"
:class="scope.item.type === 'upscale'?'upscale':''" :class="scope.item.type === 'upscale'?'upscale':''"
:zoom-rate="1.2" :zoom-rate="1.2"
:preview-src-list="previewImgList" :preview-src-list="[scope.item['img_url']]"
fit="cover" fit="cover"
:initial-index="scope.index" loading="lazy" v-if="scope.item.progress > 0"> :initial-index="scope.index" loading="lazy" v-if="scope.item.progress > 0">
<template #placeholder> <template #placeholder>
@ -390,7 +390,6 @@ const params = ref({
const runningJobs = ref([]) const runningJobs = ref([])
const finishedJobs = ref([]) const finishedJobs = ref([])
const previewImgList = ref([])
const router = useRouter() const router = useRouter()
const socket = ref(null) const socket = ref(null)
@ -433,7 +432,6 @@ const connect = () => {
if (isNew) { if (isNew) {
finishedJobs.value.unshift(data) finishedJobs.value.unshift(data)
} }
previewImgList.value.unshift(data["img_url"])
} else { } else {
for (let i = 0; i < runningJobs.value.length; i++) { for (let i = 0; i < runningJobs.value.length; i++) {
if (runningJobs.value[i].id === data.id) { if (runningJobs.value[i].id === data.id) {
@ -468,10 +466,6 @@ onMounted(() => {
// //
httpGet(`/api/mj/jobs?status=1&user_id=${user['id']}`).then(res => { httpGet(`/api/mj/jobs?status=1&user_id=${user['id']}`).then(res => {
finishedJobs.value = res.data finishedJobs.value = res.data
previewImgList.value = []
for (let index in finishedJobs.value) {
previewImgList.value.push(finishedJobs.value[index]["img_url"])
}
}).catch(e => { }).catch(e => {
ElMessage.error("获取任务失败:" + e.message) ElMessage.error("获取任务失败:" + e.message)
}) })