Commit d63e0393 authored by anxin100's avatar anxin100 Committed by GitHub

Merge branch 'main' into dev

parents 78375e5f ee209646
This diff is collapsed.
[
{
"id": "1",
"image": "template1.png",
"prompt": "A figure engulfed in light, with intense glow radiating fiercely behind."
},
{
"id": "2",
"image": "template2.png",
"prompt": "A person standing amidst a storm, lightning crackling in the background."
},
{
"id": "3",
"image": "template3.png",
"prompt": "A silhouette surrounded by swirling mist, ethereal light illuminating the scene behind."
},
{
"id": "4",
"image": "template4.png",
"prompt": "A figure emerging from a dense forest, with beams of sunlight creating a radiant backdrop."
}
]
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
interface Template {
id: string
image: string
prompt: string
}
// 获取模板
export async function getTemplate() {
const imgOrigin = window.location.origin
const response = await fetch('/templates/template.json');
const resList = await response.json();
if(resList && resList.length > 0){
resList.forEach((item: Template) => {
item.image = `${imgOrigin}/templates/images/${item.image}`
})
}
return resList
}
\ No newline at end of file
......@@ -4,7 +4,11 @@
<div>
<!-- 页面内容 -->
<div class="container">
<img class="banner" src="../assets/images/banner.png" mode=""></img>
<div class="banner">
<img src="../assets/images/banner.png" mode=""></img>
<p>AON 3D Clothing</p>
<p>Customize your clothing logo and generate a 3D avatar</p>
</div>
<div class="uni-form-item uni-column">
<div class="title">Upload your photos</div>
......@@ -27,10 +31,24 @@
</div>
<div class="uni-form-item uni-column">
<!-- <div class="uni-form-item uni-column">
<div class="title">Customize your clothing logo</div>
<div class="content">
<input v-model="logoText" name="input" placeholder="Please enter the logo text on your clothes" />
<input v-model="prompt" name="input" placeholder="Please enter the logo text on your clothes" />
</div>
</div> -->
<div class="uni-form-item uni-column">
<div class="title">Choose your template</div>
<div class="templateCon" v-if="templateList.length > 0">
<div v-for="(item, index) in templateList"
:class="`template_item ${Number(item.id) === templateId ? 'templateActive' : ''}`"
@click="selectTemplate(Number(item.id), item.image, item.prompt)" :key="index">
<img :src="item.image" alt="" />
<div :class="`isActiveIcon ${Number(item.id) === templateId ? 'active' : ''}`">
<img src="../assets/icons/selectIcon.png" alt="" v-if="Number(item.id) === templateId">
</div>
</div>
</div>
</div>
......@@ -53,11 +71,12 @@
</template>
<script setup>
import { ref } from 'vue';
import { ref, onMounted } from 'vue';
import { showToast } from 'vant';
import { useRouter } from 'vue-router'
import { AI } from 'aonweb'
import { getTemplate } from '../lib/getTemplate'
import 'vant/lib/index.css';
import Header from '../components/Header.vue';
......@@ -67,9 +86,11 @@ const router = useRouter()
const showLoading = ref(false);
const showError = ref(false);
const logoText = ref('');
const prompt = ref('');
const imgUrl = ref('');
const submitImgUrl = ref('');
const templateList = ref([]);
const templateId = ref(1);
const maxSize = 30 * 1024 * 1024;
function goToComplete(url) {
......@@ -81,18 +102,15 @@ function goToComplete(url) {
}
const onOversize = (file) => {
console.log(file);
showToast('文件大小不能超过 30MB');
};
function afterRead(file) {
const formData = new FormData();
formData.append('file', file.file);
console.log(formData, file.file)
// 调用上传接口
uploadFile(formData).then(res => {
console.log(res);
if (res.code == 200 && res.data && res.data.length) {
submitImgUrl.value = res.data
}
......@@ -113,7 +131,6 @@ const uploadFile = async (formData) => {
});
const data = await response.json();
console.log(data);
return data;
};
......@@ -135,7 +152,8 @@ function deleteImg() {
const formSubmit = async () => {
if (!logoText.value || !imgUrl.value || !submitImgUrl.value) {
console.log(prompt.value, submitImgUrl.value)
if (!imgUrl.value || !submitImgUrl.value) {
showError.value = true
setTimeout(() => {
......@@ -159,7 +177,7 @@ const formSubmit = async () => {
input: {
"image": submitImgUrl.value,
"style": "3D",
"prompt": logoText.value,
"prompt": prompt.value,
"negative_prompt": "",
"prompt_strength": 4.5,
"denoising_strength": 1,
......@@ -193,6 +211,25 @@ const formSubmit = async () => {
}
async function getTemplateList() {
try {
const list = await getTemplate()
templateList.value = list
prompt.value = list[0].prompt
} catch (error) {
console.log(error)
}
}
function selectTemplate(id, imageUrl, prompt_) {
templateId.value = id
prompt.value = prompt_
}
onMounted(() => {
getTemplateList()
})
</script>
<style scoped>
......@@ -200,8 +237,41 @@ const formSubmit = async () => {
width: 100%;
height: 27.73vw;
margin-top: 8.53vw;
margin-bottom: 8.53vw;
position: relative;
padding: 4.27vw;
}
.banner img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.banner p {
position: relative;
z-index: 10;
font-family: Roboto-Black;
font-weight: 900;
font-size: 6.4vw;
color: #FFFFFF;
text-align: left;
font-style: normal;
text-transform: none;
}
.banner p:last-child {
width: 49.07vw;
font-family: Roboto-Regular;
font-weight: 400;
font-size: 2.4vw;
color: #FFFFFF;
line-height: 4.27vw;
text-align: left;
font-style: normal;
text-transform: none;
}
.uni-form-item .title {
......@@ -230,7 +300,12 @@ const formSubmit = async () => {
box-sizing: border-box;
}
.error-text{
width: 86.67vw;
position: fixed;
bottom: 21.6vw;
}
.error-text .content {
background-color: #F3A32B;
font-size: 3.2vw;
......@@ -315,4 +390,59 @@ const formSubmit = async () => {
color: transparent;
background-clip: text;
}
.templateCon {
display: flex;
flex-direction: row;
justify-content: space-between;
flex-wrap: wrap;
height: auto;
background: transparent;
}
.template_item {
width: 24.8vw;
height: 44vw;
background: #F1F1F1;
border-radius: 1.07vw;
margin-bottom: 4.53vw;
position: relative;
overflow: hidden;
box-sizing: border-box;
}
.template_item img {
width: 100%;
height: 100%;
object-fit: cover;
}
.templateActive {
border: .27vw solid #000;
}
.isActiveIcon {
position: absolute;
bottom: 1.6vw;
right: 1.6vw;
width: 3.2vw;
height: 3.2vw;
background: #FFFFFF;
border: .27vw solid #000000;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
}
.isActiveIcon img{
height: 2.13vw;
width: 2.13vw;
}
.active{
background: #EBCC2F;
}
</style>
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"include": ["env.d.ts", "src/**/*", "src/**/*.vue", "src/**/*.ts", "src/**/*.json"],
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
"composite": true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment