【优化】优化 Image Card 加载中
This commit is contained in:
parent
ad10328b73
commit
91fc46691e
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-card body-class="" class="image-card" v-loading="imageDetail.status === 'in_progress'" >
|
<el-card body-class="" class="image-card">
|
||||||
<div class="image-operation">
|
<div class="image-operation">
|
||||||
<div>
|
<div>
|
||||||
<el-button type="" text bg v-if="imageDetail.status === 'in_progress'">生成中</el-button>
|
<el-button type="" text bg v-if="imageDetail.status === 'in_progress'">生成中</el-button>
|
||||||
@ -13,7 +13,7 @@
|
|||||||
<el-button class="btn" text :icon="More" @click="handlerBtnClick('more', imageDetail)" />
|
<el-button class="btn" text :icon="More" @click="handlerBtnClick('more', imageDetail)" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="image-wrapper">
|
<div class="image-wrapper" ref="cardImageRef">
|
||||||
<img class="image" :src="imageDetail?.picUrl" />
|
<img class="image" :src="imageDetail?.picUrl" />
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
@ -22,6 +22,10 @@
|
|||||||
import {Delete, Download, More} from "@element-plus/icons-vue";
|
import {Delete, Download, More} from "@element-plus/icons-vue";
|
||||||
import {ImageDetailVO} from "@/api/ai/image";
|
import {ImageDetailVO} from "@/api/ai/image";
|
||||||
import {PropType} from "vue";
|
import {PropType} from "vue";
|
||||||
|
import {ElLoading} from "element-plus";
|
||||||
|
|
||||||
|
const cardImageRef = ref<any>() // 卡片 image ref
|
||||||
|
const cardImageLoadingInstance = ref<any>() // 卡片 image ref
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
imageDetail: {
|
imageDetail: {
|
||||||
@ -37,9 +41,30 @@ const handlerBtnClick = async (type, imageDetail: ImageDetailVO ) => {
|
|||||||
emits('onBtnClick', type, imageDetail)
|
emits('onBtnClick', type, imageDetail)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 监听 imageDetail
|
||||||
|
// const { imageDetail } = toRefs(props)
|
||||||
|
// watch(imageDetail, async (newVal, oldValue) => {
|
||||||
|
// console.log('首次 watch')
|
||||||
|
//
|
||||||
|
// })
|
||||||
|
|
||||||
// emits
|
// emits
|
||||||
const emits = defineEmits(['onBtnClick'])
|
const emits = defineEmits(['onBtnClick'])
|
||||||
|
|
||||||
|
//
|
||||||
|
onMounted( async () => {
|
||||||
|
if (props.imageDetail.status === 'in_progress') {
|
||||||
|
cardImageLoadingInstance.value = ElLoading.service({
|
||||||
|
target: cardImageRef.value,
|
||||||
|
text: '生成中...'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
if (cardImageLoadingInstance.value) {
|
||||||
|
cardImageLoadingInstance.value.close();
|
||||||
|
cardImageLoadingInstance.value = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@ -47,6 +72,9 @@ const emits = defineEmits(['onBtnClick'])
|
|||||||
.image-card {
|
.image-card {
|
||||||
width: 320px;
|
width: 320px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
.image-operation {
|
.image-operation {
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -63,6 +91,8 @@ const emits = defineEmits(['onBtnClick'])
|
|||||||
.image-wrapper {
|
.image-wrapper {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
|
height: 280px;
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
.image {
|
.image {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
Loading…
Reference in New Issue
Block a user