Commit ee209646 authored by web's avatar web

up template

parent 2a3cfc26
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 @@ ...@@ -4,7 +4,11 @@
<div> <div>
<!-- 页面内容 --> <!-- 页面内容 -->
<div class="container"> <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="uni-form-item uni-column">
<div class="title">Upload your photos</div> <div class="title">Upload your photos</div>
...@@ -27,10 +31,24 @@ ...@@ -27,10 +31,24 @@
</div> </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="title">Customize your clothing logo</div>
<div class="content"> <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>
</div> </div>
...@@ -53,11 +71,12 @@ ...@@ -53,11 +71,12 @@
</template> </template>
<script setup> <script setup>
import { ref } from 'vue'; import { ref, onMounted } from 'vue';
import { showToast } from 'vant'; import { showToast } from 'vant';
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { AI } from 'aonweb' import { AI } from 'aonweb'
import { getTemplate } from '../lib/getTemplate'
import 'vant/lib/index.css'; import 'vant/lib/index.css';
import Header from '../components/Header.vue'; import Header from '../components/Header.vue';
...@@ -67,9 +86,11 @@ const router = useRouter() ...@@ -67,9 +86,11 @@ const router = useRouter()
const showLoading = ref(false); const showLoading = ref(false);
const showError = ref(false); const showError = ref(false);
const logoText = ref(''); const prompt = ref('');
const imgUrl = ref(''); const imgUrl = ref('');
const submitImgUrl = ref(''); const submitImgUrl = ref('');
const templateList = ref([]);
const templateId = ref(1);
const maxSize = 30 * 1024 * 1024; const maxSize = 30 * 1024 * 1024;
function goToComplete(url) { function goToComplete(url) {
...@@ -81,18 +102,15 @@ function goToComplete(url) { ...@@ -81,18 +102,15 @@ function goToComplete(url) {
} }
const onOversize = (file) => { const onOversize = (file) => {
console.log(file);
showToast('文件大小不能超过 30MB'); showToast('文件大小不能超过 30MB');
}; };
function afterRead(file) { function afterRead(file) {
const formData = new FormData(); const formData = new FormData();
formData.append('file', file.file); formData.append('file', file.file);
console.log(formData, file.file)
// 调用上传接口 // 调用上传接口
uploadFile(formData).then(res => { uploadFile(formData).then(res => {
console.log(res);
if (res.code == 200 && res.data && res.data.length) { if (res.code == 200 && res.data && res.data.length) {
submitImgUrl.value = res.data submitImgUrl.value = res.data
} }
...@@ -113,7 +131,6 @@ const uploadFile = async (formData) => { ...@@ -113,7 +131,6 @@ const uploadFile = async (formData) => {
}); });
const data = await response.json(); const data = await response.json();
console.log(data);
return data; return data;
}; };
...@@ -135,7 +152,8 @@ function deleteImg() { ...@@ -135,7 +152,8 @@ function deleteImg() {
const formSubmit = async () => { const formSubmit = async () => {
if (!logoText.value || !imgUrl.value || !submitImgUrl.value) { console.log(prompt.value, submitImgUrl.value)
if (!imgUrl.value || !submitImgUrl.value) {
showError.value = true showError.value = true
setTimeout(() => { setTimeout(() => {
...@@ -158,16 +176,14 @@ const formSubmit = async () => { ...@@ -158,16 +176,14 @@ const formSubmit = async () => {
input: { input: {
"image": submitImgUrl.value, "image": submitImgUrl.value,
"style": "3D", "style": "3D",
"prompt": logoText.value, "prompt": prompt.value,
"negative_prompt": "", "negative_prompt": "",
"prompt_strength": 4.5, "prompt_strength": 4.5,
"denoising_strength": 1, "denoising_strength": 1,
"instant_id_strength": 0.8 "instant_id_strength": 0.8
} }
} }
console.log("formSubmit data", data)
let response = await aonet.prediction("/predictions/ai/face-to-many", data) let response = await aonet.prediction("/predictions/ai/face-to-many", data)
console.log("test", response)
if (response.task.exec_code == 200 && response.task.is_success) { if (response.task.exec_code == 200 && response.task.is_success) {
showLoading.value = false showLoading.value = false
...@@ -191,6 +207,25 @@ const formSubmit = async () => { ...@@ -191,6 +207,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> </script>
<style scoped> <style scoped>
...@@ -198,8 +233,41 @@ const formSubmit = async () => { ...@@ -198,8 +233,41 @@ const formSubmit = async () => {
width: 100%; width: 100%;
height: 27.73vw; height: 27.73vw;
margin-top: 8.53vw; margin-top: 8.53vw;
margin-bottom: 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 { .uni-form-item .title {
...@@ -228,7 +296,12 @@ const formSubmit = async () => { ...@@ -228,7 +296,12 @@ const formSubmit = async () => {
box-sizing: border-box; box-sizing: border-box;
} }
.error-text{
width: 86.67vw;
position: fixed;
bottom: 21.6vw;
}
.error-text .content { .error-text .content {
background-color: #F3A32B; background-color: #F3A32B;
font-size: 3.2vw; font-size: 3.2vw;
...@@ -313,4 +386,59 @@ const formSubmit = async () => { ...@@ -313,4 +386,59 @@ const formSubmit = async () => {
color: transparent; color: transparent;
background-clip: text; 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> </style>
{ {
"extends": "@vue/tsconfig/tsconfig.dom.json", "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__/*"], "exclude": ["src/**/__tests__/*"],
"compilerOptions": { "compilerOptions": {
"composite": true, "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