2024-05-26 21:50:59 +08:00
|
|
|
|
<template>
|
2024-05-28 10:27:33 +08:00
|
|
|
|
<el-card body-class="" class="image-card">
|
2024-05-26 21:50:59 +08:00
|
|
|
|
<div class="image-operation">
|
|
|
|
|
<div>
|
2024-06-01 16:49:42 +08:00
|
|
|
|
<el-button type="primary" text bg v-if="imageDetail?.status === 10">生成中</el-button>
|
|
|
|
|
<el-button text bg v-else-if="imageDetail?.status === 20">已完成</el-button>
|
|
|
|
|
<el-button type="danger" text bg v-else-if="imageDetail?.status === 30">异常</el-button>
|
2024-05-26 21:50:59 +08:00
|
|
|
|
</div>
|
2024-06-01 16:49:42 +08:00
|
|
|
|
<!-- TODO @fan:1)按钮要不调整成详情、下载、再次生成、删除?;2)如果是再次生成,就把当前的参数填写到左侧的框框里? -->
|
2024-05-26 21:50:59 +08:00
|
|
|
|
<div>
|
2024-05-28 11:35:02 +08:00
|
|
|
|
<el-button class="btn" text :icon="Download"
|
|
|
|
|
@click="handlerBtnClick('download', imageDetail)"/>
|
|
|
|
|
<el-button class="btn" text :icon="Delete" @click="handlerBtnClick('delete', imageDetail)"/>
|
|
|
|
|
<el-button class="btn" text :icon="More" @click="handlerBtnClick('more', imageDetail)"/>
|
2024-05-26 21:50:59 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-05-28 10:27:33 +08:00
|
|
|
|
<div class="image-wrapper" ref="cardImageRef">
|
2024-06-01 16:49:42 +08:00
|
|
|
|
<!-- TODO @fan:要不加个点击,大图预览? -->
|
2024-05-28 11:35:02 +08:00
|
|
|
|
<img class="image" :src="imageDetail?.picUrl"/>
|
2024-06-01 16:49:42 +08:00
|
|
|
|
<div v-if="imageDetail?.status === 30">{{imageDetail?.errorMessage}}</div>
|
2024-05-26 21:50:59 +08:00
|
|
|
|
</div>
|
|
|
|
|
</el-card>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import {Delete, Download, More} from "@element-plus/icons-vue";
|
|
|
|
|
import {ImageDetailVO} from "@/api/ai/image";
|
|
|
|
|
import {PropType} from "vue";
|
2024-05-28 10:27:33 +08:00
|
|
|
|
import {ElLoading} from "element-plus";
|
|
|
|
|
|
|
|
|
|
const cardImageRef = ref<any>() // 卡片 image ref
|
|
|
|
|
const cardImageLoadingInstance = ref<any>() // 卡片 image ref
|
2024-05-26 21:50:59 +08:00
|
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
imageDetail: {
|
|
|
|
|
type: Object as PropType<ImageDetailVO>,
|
|
|
|
|
require: true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 按钮 - 点击事件
|
|
|
|
|
*/
|
2024-05-28 11:35:02 +08:00
|
|
|
|
const handlerBtnClick = async (type, imageDetail: ImageDetailVO) => {
|
2024-05-26 21:56:10 +08:00
|
|
|
|
emits('onBtnClick', type, imageDetail)
|
2024-05-26 21:50:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-01 16:49:42 +08:00
|
|
|
|
const handlerLoading = async (status: number) => {
|
|
|
|
|
// TODO @fan:这个搞成 Loading 组件,然后通过数据驱动,这样搞可以哇?
|
|
|
|
|
if (status === 10) {
|
2024-05-28 10:27:33 +08:00
|
|
|
|
cardImageLoadingInstance.value = ElLoading.service({
|
|
|
|
|
target: cardImageRef.value,
|
|
|
|
|
text: '生成中...'
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
if (cardImageLoadingInstance.value) {
|
|
|
|
|
cardImageLoadingInstance.value.close();
|
|
|
|
|
cardImageLoadingInstance.value = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-28 15:03:12 +08:00
|
|
|
|
}
|
|
|
|
|
// watch
|
|
|
|
|
const { imageDetail } = toRefs(props)
|
|
|
|
|
watch(imageDetail, async (newVal, oldVal) => {
|
|
|
|
|
await handlerLoading(newVal.status as string)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// emits
|
|
|
|
|
const emits = defineEmits(['onBtnClick'])
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
await handlerLoading(props.imageDetail.status as string)
|
2024-05-28 10:27:33 +08:00
|
|
|
|
})
|
2024-05-26 21:50:59 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
|
|
|
|
|
.image-card {
|
2024-05-27 10:47:43 +08:00
|
|
|
|
width: 320px;
|
2024-05-28 14:40:43 +08:00
|
|
|
|
height: auto;
|
2024-05-26 21:50:59 +08:00
|
|
|
|
border-radius: 10px;
|
2024-05-28 10:27:33 +08:00
|
|
|
|
position: relative;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
2024-05-26 21:50:59 +08:00
|
|
|
|
|
|
|
|
|
.image-operation {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
|
|
|
|
.btn {
|
|
|
|
|
//border: 1px solid red;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
margin: 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.image-wrapper {
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
margin-top: 20px;
|
2024-05-28 10:27:33 +08:00
|
|
|
|
height: 280px;
|
|
|
|
|
flex: 1;
|
2024-05-26 21:50:59 +08:00
|
|
|
|
|
|
|
|
|
.image {
|
|
|
|
|
width: 100%;
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|