refactor: use waterflow component in mj, sd and dall image drawing page

This commit is contained in:
RockYang
2024-05-13 19:04:00 +08:00
parent 5fb9f84182
commit 43b6665370
19 changed files with 1118 additions and 759 deletions

View File

@@ -297,43 +297,40 @@
<div class="job-list-box">
<h2>任务列表</h2>
<div class="running-job-list">
<ItemList :items="runningJobs" v-if="runningJobs.length > 0" :width="240">
<template #default="scope">
<div class="job-item">
<div v-if="scope.item.progress > 0" class="job-item-inner">
<el-image :src="scope.item['img_url']"
fit="cover"
loading="lazy">
<template #placeholder>
<div class="image-slot">
正在加载图片
</div>
</template>
<div class="running-job-box" v-if="runningJobs.length > 0">
<div class="job-item" v-for="item in runningJobs">
<div v-if="item.progress > 0" class="job-item-inner">
<el-image :src="item['img_url']" fit="cover" loading="lazy">
<template #placeholder>
<div class="image-slot">
正在加载图片
</div>
</template>
<template #error>
<div class="image-slot">
<el-icon v-if="scope.item['img_url'] !== ''">
<Picture/>
</el-icon>
</div>
</template>
</el-image>
<div class="progress">
<el-progress type="circle" :percentage="scope.item.progress" :width="100" color="#47fff1"/>
</div>
</div>
<el-image fit="cover" v-else>
<template #error>
<div class="image-slot">
<i class="iconfont icon-quick-start"></i>
<span>任务正在排队中</span>
<el-icon>
<Picture/>
</el-icon>
</div>
</template>
</el-image>
<div class="progress">
<el-progress type="circle" :percentage="item.progress" :width="100"
color="#47fff1"/>
</div>
</div>
</template>
</ItemList>
<el-image fit="cover" v-else>
<template #error>
<div class="image-slot">
<i class="iconfont icon-quick-start"></i>
<span>任务正在排队中</span>
</div>
</template>
</el-image>
</div>
</div>
<el-empty :image-size="100" v-else/>
</div>
<h2>创作记录</h2>
@@ -344,7 +341,7 @@
:list="finishedJobs"
srcKey="img_thumb"
:gap="20"
:bottomGap="10"
:bottomGap="-10"
:colWidth="colWidth"
:distanceToScroll="100"
:isLoading="loading"
@@ -369,49 +366,15 @@
</div>
</div>
</template>
<template #footer>
<div class="no-more-data">
<span>没有更多数据了</span>
<i class="iconfont icon-face"></i>
</div>
</template>
</v3-waterfall>
<!-- <ItemList :items="finishedJobs" :width="240" :gap="16">-->
<!-- <template #default="scope">-->
<!-- <div class="job-item animate" @click="showTask(scope.item)">-->
<!-- <el-image-->
<!-- :src="scope.item['img_url']+'?imageView2/1/w/240/h/240/q/75'"-->
<!-- fit="cover"-->
<!-- loading="lazy">-->
<!-- <template #placeholder>-->
<!-- <div class="image-slot">-->
<!-- 正在加载图片-->
<!-- </div>-->
<!-- </template>-->
<!-- <template #error>-->
<!-- <div class="image-slot">-->
<!-- <el-icon>-->
<!-- <Picture/>-->
<!-- </el-icon>-->
<!-- </div>-->
<!-- </template>-->
<!-- </el-image>-->
<!-- <div class="remove">-->
<!-- <el-button type="danger" :icon="Delete" @click="removeImage($event,scope.item)" circle/>-->
<!-- <el-button type="warning" v-if="scope.item.publish"-->
<!-- @click="publishImage($event,scope.item, false)"-->
<!-- circle>-->
<!-- <i class="iconfont icon-cancel-share"></i>-->
<!-- </el-button>-->
<!-- <el-button type="success" v-else @click="publishImage($event,scope.item, true)" circle>-->
<!-- <i class="iconfont icon-share-bold"></i>-->
<!-- </el-button>-->
<!-- </div>-->
<!-- </div>-->
<!-- </template>-->
<!-- </ItemList>-->
<!-- <div class="no-more-data" v-if="isOver">-->
<!-- <span>没有更多数据了</span>-->
<!-- <i class="iconfont icon-face"></i>-->
<!-- </div>-->
</div>
<el-empty :image-size="100" v-else/>
</div> <!-- end finish job list-->
@@ -541,10 +504,9 @@
<script setup>
import {onMounted, onUnmounted, ref} from "vue"
import {DocumentCopy, InfoFilled, Orange, Picture} from "@element-plus/icons-vue";
import {Delete, DocumentCopy, InfoFilled, Orange, Picture} from "@element-plus/icons-vue";
import {httpGet, httpPost} from "@/utils/http";
import {ElMessage, ElMessageBox, ElNotification} from "element-plus";
import ItemList from "@/components/ItemList.vue";
import Clipboard from "clipboard";
import {checkSession} from "@/action/session";
import {useRouter} from "vue-router";
@@ -560,16 +522,8 @@ const showLoginDialog = ref(false)
const isLogin = ref(false)
const loading = ref(true)
const colWidth = ref(240)
// 计算瀑布流列宽度
const calcColWidth = () => {
const listBoxWidth = window.innerWidth - 400
const rows = Math.floor(listBoxWidth / colWidth.value)
colWidth.value = Math.floor((listBoxWidth - (rows - 1) * 12) / rows)
}
calcColWidth()
window.onresize = () => {
calcColWidth()
listBoxHeight.value = window.innerHeight - 40
paramBoxHeight.value = window.innerHeight - 150
}
@@ -645,7 +599,7 @@ const connect = () => {
reader.onload = () => {
const message = String(reader.result)
if (message === "FINISH") {
page.value = 1
page.value = 0
fetchFinishJobs()
isOver.value = false
}
@@ -695,6 +649,7 @@ const initData = () => {
power.value = user['power']
userId.value = user.id
isLogin.value = true
page.value = 0
fetchRunningJobs()
fetchFinishJobs()
connect()
@@ -735,7 +690,7 @@ const pageSize = ref(20)
const isOver = ref(false)
// 获取已完成的任务
const fetchFinishJobs = () => {
if (!isLogin.value) {
if (!isLogin.value || isOver.value === true) {
return
}
loading.value = true
@@ -749,7 +704,7 @@ const fetchFinishJobs = () => {
for (let i = 0; i < imageList.length; i++) {
imageList[i]["img_thumb"] = imageList[i]["img_url"] + "?imageView2/4/w/300/h/0/q/75"
}
if (page === 1) {
if (page.value === 1) {
finishedJobs.value = imageList
} else {
finishedJobs.value = finishedJobs.value.concat(imageList)