Files
lanecarford_front/src/components/selectStyle/selectItem.vue

184 lines
4.0 KiB
Vue
Raw Normal View History

2025-10-09 13:56:00 +08:00
<script setup lang="ts">
2025-10-09 16:04:55 +08:00
import { onMounted, onUnmounted, reactive, toRefs } from "vue";
const props = defineProps({
selectList: {
type: Array,
default: () => [],
} as any,
select: {
2025-10-21 13:46:27 +08:00
type: Object,
default: () => {},
} as any,
2025-10-09 16:04:55 +08:00
})
const emit = defineEmits([
2025-10-21 13:46:27 +08:00
'selectItem','updateStyle'
])
2025-10-09 13:56:00 +08:00
let data = reactive({
})
2025-10-09 16:04:55 +08:00
const setLike = (item,str)=>{
if(str === 'like'){
item.isLike = true
}else{
item.isLike = false
}
}
const setSelectList = (item)=>{
if(item.status == 'SUCCEEDED')emit('selectItem', item)
2025-10-09 16:04:55 +08:00
}
const deleteStyle = (index)=>{
props.selectList.splice(index,1)
}
const updateStyle = (item,index)=>{
if(!['RUNNING','PENDING'].includes(item.status))emit('updateStyle', {item,index})
2025-10-09 16:04:55 +08:00
}
2025-11-19 18:02:44 +08:00
const vLoading = {
mounted: (el: HTMLElement, binding: any) =>{
binding.value.timer = ()=>{
setTimeout(()=>{
binding.value.isLoading = true
},5000)
}
binding.value.timer()
},
unmounted(el: HTMLElement, binding: any) {
binding.value.isLoading = false
clearTimeout(binding.value.timer)
}
}
2025-10-09 13:56:00 +08:00
onMounted(()=>{
})
onUnmounted(()=>{
})
defineExpose({})
const {} = toRefs(data);
</script>
<template>
2025-10-09 16:04:55 +08:00
<div class="list">
<div class="item" v-for="(item,index) in selectList" :key="item.id">
<div class="title">look {{ index + 1 }}</div>
<div class="imgBox" @click="setSelectList(item)">
2025-10-28 13:57:48 +08:00
<img v-if="item?.path" :src="item?.path" alt="">
2025-11-19 18:02:44 +08:00
<div v-else v-loading="item">
<van-loading size="20rem"/>
<span v-if="item?.isLoading" style="font-size: 2.8rem;">
Still generating...
</span>
</div>
2025-10-21 13:46:27 +08:00
<!-- <img v-for="(img,index) in item?.imgList" :key="index" :src="img" alt=""> -->
<div class="icon" v-if="item.id == select?.id">
<SvgIcon name="modelSelected" size="60" />
</div>
2025-10-28 17:05:53 +08:00
<div class="mask running" v-if="item.status == 'RUNNING'">
<van-loading type="spinner" size="20rem"/>
</div>
<div class="mask failed" v-if="item.status == 'FAILED'">
Generation failed. Please click refresh to try again.
</div>
2025-10-21 13:46:27 +08:00
<div class="mask" v-if="item.id == select?.oldId"></div>
2025-10-09 16:04:55 +08:00
</div>
<!-- <div class="btn">
2025-10-09 16:04:55 +08:00
<div>
<SvgIcon @click.stop="updateStyle(item,index)" name="update" size="30" />
2025-10-09 16:04:55 +08:00
</div>
</div> -->
2025-10-09 16:04:55 +08:00
</div>
2025-10-09 13:56:00 +08:00
</div>
</template>
<style lang="less" scoped>
2025-10-09 16:04:55 +08:00
.list{
display: flex;
width: 100%;
flex-wrap: wrap;
justify-content: space-between;
2025-10-09 16:04:55 +08:00
> .item{
width: calc(50% - 3.5rem / 2);
2025-10-09 16:04:55 +08:00
position: relative;
2025-11-17 11:24:46 +08:00
// margin-bottom: 3.3rem;
2025-10-09 16:04:55 +08:00
display: flex;
flex-direction: column;
> .title{
2025-11-17 11:24:46 +08:00
font-size: 3.44rem;
font-weight: 700;
color: #000;
font-family: 'satoshiMedium';
2025-10-09 16:04:55 +08:00
}
> .imgBox{
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
2025-11-17 11:24:46 +08:00
height: 45rem;
margin: 2.3rem 0;
background-color: #fff;
justify-content: center;
border: .6px solid #acacac;
border-radius: 1.3px;
position: relative;
2025-10-21 13:46:27 +08:00
> .mask{
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
top: 0;
left: 0;
&.failed{
color: #fff;
font-size: 2rem;
display: flex;
align-items: center;
justify-content: center;
}
2025-10-30 15:52:11 +08:00
.van-loading {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
}
2025-10-21 13:46:27 +08:00
}
> .icon{
position: absolute;
width: 6rem;
height: 6rem;
bottom: -1.8rem;
right: -2.1rem;
}
2025-10-09 16:04:55 +08:00
> img{
2025-10-21 13:46:27 +08:00
// height: 26rem;
width: 100%;
height: 100%;
// object-fit: cover;
object-fit: contain;
// max-width: 50%;
// max-height: 50%;
2025-10-09 16:04:55 +08:00
}
}
// > .btn{
// display: flex;
// align-items: center;
// justify-content: flex-end;
// > div{
// color: #000;
// margin-right: 1.2rem;
// border-radius: 50%;
// width: 5.2rem;
// height: 5.2rem;
// padding: 1rem;
// background-color: #fff;
// &:last-child{
// margin-right: 0rem;
// }
// &:hover{
// color: #000;
// }
// }
// }
2025-10-09 16:04:55 +08:00
}
2025-10-09 13:56:00 +08:00
}
</style>