Skip to content

Commit 91fc466

Browse files
committed
【优化】优化 Image Card 加载中
1 parent ad10328 commit 91fc466

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

src/views/ai/image/ImageTaskCard.vue

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
<template>
3-
<el-card body-class="" class="image-card" v-loading="imageDetail.status === 'in_progress'" >
3+
<el-card body-class="" class="image-card">
44
<div class="image-operation">
55
<div>
66
<el-button type="" text bg v-if="imageDetail.status === 'in_progress'">生成中</el-button>
@@ -13,7 +13,7 @@
1313
<el-button class="btn" text :icon="More" @click="handlerBtnClick('more', imageDetail)" />
1414
</div>
1515
</div>
16-
<div class="image-wrapper">
16+
<div class="image-wrapper" ref="cardImageRef">
1717
<img class="image" :src="imageDetail?.picUrl" />
1818
</div>
1919
</el-card>
@@ -22,6 +22,10 @@
2222
import {Delete, Download, More} from "@element-plus/icons-vue";
2323
import {ImageDetailVO} from "@/api/ai/image";
2424
import {PropType} from "vue";
25+
import {ElLoading} from "element-plus";
26+
27+
const cardImageRef = ref<any>() // 卡片 image ref
28+
const cardImageLoadingInstance = ref<any>() // 卡片 image ref
2529
2630
const props = defineProps({
2731
imageDetail: {
@@ -37,16 +41,40 @@ const handlerBtnClick = async (type, imageDetail: ImageDetailVO ) => {
3741
emits('onBtnClick', type, imageDetail)
3842
}
3943
44+
// 监听 imageDetail
45+
// const { imageDetail } = toRefs(props)
46+
// watch(imageDetail, async (newVal, oldValue) => {
47+
// console.log('首次 watch')
48+
//
49+
// })
50+
4051
// emits
4152
const emits = defineEmits(['onBtnClick'])
4253
54+
//
55+
onMounted( async () => {
56+
if (props.imageDetail.status === 'in_progress') {
57+
cardImageLoadingInstance.value = ElLoading.service({
58+
target: cardImageRef.value,
59+
text: '生成中...'
60+
})
61+
} else {
62+
if (cardImageLoadingInstance.value) {
63+
cardImageLoadingInstance.value.close();
64+
cardImageLoadingInstance.value = null;
65+
}
66+
}
67+
})
4368
</script>
4469

4570
<style scoped lang="scss">
4671
4772
.image-card {
4873
width: 320px;
4974
border-radius: 10px;
75+
position: relative;
76+
display: flex;
77+
flex-direction: column;
5078
5179
.image-operation {
5280
display: flex;
@@ -63,6 +91,8 @@ const emits = defineEmits(['onBtnClick'])
6391
.image-wrapper {
6492
overflow: hidden;
6593
margin-top: 20px;
94+
height: 280px;
95+
flex: 1;
6696
6797
.image {
6898
width: 100%;

0 commit comments

Comments
 (0)