1
1
2
2
<template >
3
- <el-card body-class =" " class =" image-card" v-loading = " imageDetail.status === 'in_progress' " >
3
+ <el-card body-class =" " class =" image-card" >
4
4
<div class =" image-operation" >
5
5
<div >
6
6
<el-button type =" " text bg v-if =" imageDetail.status === 'in_progress'" >生成中</el-button >
13
13
<el-button class =" btn" text :icon =" More" @click =" handlerBtnClick('more', imageDetail)" />
14
14
</div >
15
15
</div >
16
- <div class =" image-wrapper" >
16
+ <div class =" image-wrapper" ref = " cardImageRef " >
17
17
<img class =" image" :src =" imageDetail?.picUrl" />
18
18
</div >
19
19
</el-card >
22
22
import {Delete , Download , More } from " @element-plus/icons-vue" ;
23
23
import {ImageDetailVO } from " @/api/ai/image" ;
24
24
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
25
29
26
30
const props = defineProps ({
27
31
imageDetail: {
@@ -37,16 +41,40 @@ const handlerBtnClick = async (type, imageDetail: ImageDetailVO ) => {
37
41
emits (' onBtnClick' , type , imageDetail )
38
42
}
39
43
44
+ // 监听 imageDetail
45
+ // const { imageDetail } = toRefs(props)
46
+ // watch(imageDetail, async (newVal, oldValue) => {
47
+ // console.log('首次 watch')
48
+ //
49
+ // })
50
+
40
51
// emits
41
52
const emits = defineEmits ([' onBtnClick' ])
42
53
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
+ })
43
68
</script >
44
69
45
70
<style scoped lang="scss">
46
71
47
72
.image-card {
48
73
width : 320px ;
49
74
border-radius : 10px ;
75
+ position : relative ;
76
+ display : flex ;
77
+ flex-direction : column ;
50
78
51
79
.image-operation {
52
80
display : flex ;
@@ -63,6 +91,8 @@ const emits = defineEmits(['onBtnClick'])
63
91
.image-wrapper {
64
92
overflow : hidden ;
65
93
margin-top : 20px ;
94
+ height : 280px ;
95
+ flex : 1 ;
66
96
67
97
.image {
68
98
width : 100% ;
0 commit comments