Skip to content

Commit

Permalink
Merge pull request #25 from JunyaoHu/13-photomaker-example-support
Browse files Browse the repository at this point in the history
[add] image selector
  • Loading branch information
JunyaoHu authored Jan 5, 2025
2 parents 6597804 + 00ec8fd commit e22fa48
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 0 deletions.
Binary file added public/image_selector/input/486.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/image_selector/input/mmk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/image_selector/input/nina.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/image_selector/input/rupa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/image_selector/input/tomo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/image_selector/output/486_model.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/image_selector/output/mmk_model.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/image_selector/output/nina_model.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/image_selector/output/rupa_model.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/image_selector/output/tomo_model.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/components/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Carousel from './sections/Carousel.vue'
import Video from './sections/Video.vue'
import ImageSlider from './sections/ImageSlider.vue'
import ImageSliderInner from './sections/ImageSliderInner.vue'
import ImageSelector from './sections/ImageSelector.vue'
import Echart from './sections/Echart.vue'
import Table from './sections/Table.vue'
import Collapse from './sections/Collapse.vue'
Expand All @@ -24,6 +25,7 @@ export default {
Video,
ImageSlider,
ImageSliderInner,
ImageSelector,
Echart,
Collapse,
Table,
Expand All @@ -50,6 +52,7 @@ export default {
<SeletionForComparison/>
<ImageSliderInner/>
<ImageSlider/>
<ImageSelector/>
<BibTeX/>
<Comment/>
</template>
121 changes: 121 additions & 0 deletions src/components/sections/ImageSelector.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<script setup>
import { ref, onMounted } from 'vue';
const imageSeletorPaths = [
"./image_selector/input/486.png",
"./image_selector/input/mmk.png",
"./image_selector/input/nina.png",
"./image_selector/input/rupa.png",
"./image_selector/input/tomo.png"
];
const outputImagesPathsStr = [
"./image_selector/output/486_model.jpg",
"./image_selector/output/mmk_model.jpg",
"./image_selector/output/nina_model.jpg",
"./image_selector/output/rupa_model.jpg",
"./image_selector/output/tomo_model.jpg"
];
const outputImagesPaths = [];
let outputImagePath = ref("");
let indexSelected = ref(0);
let isLoading = ref(true);
const preloadImageSelector = () => {
const promises = [];
for (let i = 0; i < outputImagesPathsStr.length; i++) {
const outputImg = new Image();
outputImagesPaths[i] = outputImg;
const outputPromise = new Promise((resolve) => {
outputImg.onload = resolve;
});
outputImg.src = outputImagesPathsStr[i];
promises.push(outputPromise);
}
return Promise.all(promises).then(() => {
isLoading.value = false;
console.log("preloadImageSelector finished");
});
}
onMounted(() => {
preloadImageSelector();
handleChange(0);
});
const handleChange = (value) => {
outputImagePath.value = outputImagesPaths[value].src;
};
</script>

<template>
<div>
<el-divider />

<el-row justify="center">
<h1 class="section-title">Image Selector</h1>
</el-row>

<el-row justify="center">
<el-col :xs="24" :sm="20" :md="16" :lg="12" :xl="12">
<el-row justify="space-evenly" style="margin-top: 20px;">
<el-col :span="4" v-for="(imageSeletorPath, index) in imageSeletorPaths" :key="index">
<el-image
class="image"
:src="imageSeletorPath" style="aspect-ratio: 1;"
fit="scale-down"
@click="handleChange(index)"
:class="{ 'selected-image': indexSelected === index, 'unselected-image': indexSelected !== index }"
/>
</el-col>
<el-row justify="center" style="margin-top: 10px;">
<el-col :span="12">
<!-- <el-skeleton
style="width: 100%"
:loading="isLoading"
animated
:throttle="1000"> -->
<!-- <template #template>
<el-skeleton-item variant="image" style="width: 100%; height: 100%" />
</template> -->
<!-- <template #default> -->
<el-image
class="output-image"
:src="outputImagePath"
fit="scale-down"
/>
<!-- </template> -->
<!-- </el-skeleton> -->
</el-col>
</el-row>
</el-row>
</el-col>
</el-row>
</div>
</template>

<style scoped>
.image:hover{
transition: none;
box-shadow: 0px 0px 6px 0px #aaaaaa;
}
.selected-image{
transition: 0.5s ease;
box-shadow: 0px 0px 6px 0px #aaaaaa;
}
/* 未选中图像的样式,颜色变灰 */
.unselected-image {
transition: 0.5s ease;
opacity: 0.4;
}
</style>

0 comments on commit e22fa48

Please sign in to comment.