|
@@ -2,19 +2,22 @@
|
|
|
import { ref, reactive, computed, onMounted } from "vue";
|
|
|
import { useMainStore } from "@/stores/store";
|
|
|
import { useRouter } from "vue-router";
|
|
|
+import { useI18n } from "vue-i18n";
|
|
|
import "animate.css";
|
|
|
import axios from "axios";
|
|
|
import Footer from "../components/Footer.vue";
|
|
|
|
|
|
const router = useRouter();
|
|
|
const store = useMainStore();
|
|
|
+const { t, locale } = useI18n();
|
|
|
+
|
|
|
const apiUrl = import.meta.env.VITE_API_URL;
|
|
|
const imgUrl = import.meta.env.VITE_API_IMG_URL;
|
|
|
console.log("VITE_API_URL", apiUrl);
|
|
|
|
|
|
-let bgImg = reactive({
|
|
|
- list: [],
|
|
|
-});
|
|
|
+// let bgImg = reactive({
|
|
|
+// list: [],
|
|
|
+// });
|
|
|
|
|
|
let assignBgImg = ref("");
|
|
|
|
|
@@ -22,8 +25,7 @@ function handleBgImg(item) {
|
|
|
console.log("name", item);
|
|
|
assignBgImg.value = item;
|
|
|
store.assignBgImg = item;
|
|
|
-
|
|
|
- parameter.value.filter((e, index) => {
|
|
|
+ parameterList.value.filter((e, index) => {
|
|
|
if (e.bg_img === item.bg_img) {
|
|
|
store.styleNum = index;
|
|
|
}
|
|
@@ -55,7 +57,6 @@ const currentPhotos = computed(() => {
|
|
|
const start = currentIndex.value;
|
|
|
const end = start + perPage.value;
|
|
|
return parameter.value.slice(start, end);
|
|
|
- // return bgImg.list.slice(start, end);
|
|
|
});
|
|
|
|
|
|
console.log("currentPhotos", currentPhotos);
|
|
@@ -85,107 +86,236 @@ const currentPage = computed(
|
|
|
);
|
|
|
|
|
|
// 測試欄位
|
|
|
-let parameters = reactive({
|
|
|
- styel_name: "",
|
|
|
- prompt: "",
|
|
|
- negative_prompt: "",
|
|
|
- bg_img: "",
|
|
|
- styles: ["real"],
|
|
|
-});
|
|
|
+// let parameters = reactive({
|
|
|
+// styel_name: "",
|
|
|
+// prompt: "",
|
|
|
+// negative_prompt: "",
|
|
|
+// bg_img: "",
|
|
|
+// styles: ["real"],
|
|
|
+// });
|
|
|
|
|
|
// 算圖測試欄位
|
|
|
-let runParameters = reactive({
|
|
|
- seed: "54987890",
|
|
|
- denoising_strength: "0.35",
|
|
|
- batch_size: "1",
|
|
|
- n_iter: "30",
|
|
|
-});
|
|
|
-
|
|
|
-let fileInput = ref(null);
|
|
|
-let imgFile = ref(null);
|
|
|
-
|
|
|
-function onFileChange() {
|
|
|
- console.log("fileInput", fileInput.value);
|
|
|
- if (fileInput.value.files.length) {
|
|
|
- imgFile.value = fileInput.value.files[0];
|
|
|
- }
|
|
|
- console.log("imgFile.value", imgFile.value);
|
|
|
-}
|
|
|
+// let runParameters = reactive({
|
|
|
+// seed: "54987890",
|
|
|
+// denoising_strength: "0.35",
|
|
|
+// batch_size: "1",
|
|
|
+// n_iter: "30",
|
|
|
+// });
|
|
|
+
|
|
|
+// let fileInput = ref(null);
|
|
|
+// let imgFile = ref(null);
|
|
|
+
|
|
|
+// function onFileChange() {
|
|
|
+// console.log("fileInput", fileInput.value);
|
|
|
+// if (fileInput.value.files.length) {
|
|
|
+// imgFile.value = fileInput.value.files[0];
|
|
|
+// }
|
|
|
+// console.log("imgFile.value", imgFile.value);
|
|
|
+// }
|
|
|
|
|
|
-let parameter = ref([]);
|
|
|
+let parameterList = ref([]);
|
|
|
+
|
|
|
+// 背景清單
|
|
|
+let parameter = ref([
|
|
|
+ {
|
|
|
+ bg_img: "臺北陽明山-母親節.png",
|
|
|
+ title: "taipei_yangmingshan",
|
|
|
+ description: "taipei_yangmingshan_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "台南孔廟.png",
|
|
|
+ title: "tainan_confucius_temple",
|
|
|
+ description: "tainan_confucius_temple_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "臺北中正紀念堂-2.png",
|
|
|
+ title: "taipei_chiang_kai_shek_memorial_hall_2",
|
|
|
+ description: "taipei_chiang_kai_shek_memorial_hall_2_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "台東嘉明湖.png",
|
|
|
+ title: "taitung_jiaming_lake",
|
|
|
+ description: "taitung_jiaming_lake_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "中秋節.png",
|
|
|
+ title: "mid_autumn_festival",
|
|
|
+ description: "mid_autumn_festival_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "新北野柳女王頭.png",
|
|
|
+ title: "new_taipei_yehliu_queen_head",
|
|
|
+ description: "new_taipei_yehliu_queen_head_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "基隆和平島公園.png",
|
|
|
+ title: "keelung_heping_island_park",
|
|
|
+ description: "keelung_heping_island_park_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "台中日月潭.png",
|
|
|
+ title: "taichung_sun_moon_lake",
|
|
|
+ description: "taichung_sun_moon_lake_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "臺北中正紀念堂.png",
|
|
|
+ title: "taipei_chiang_kai_shek_memorial_hall",
|
|
|
+ description: "taipei_chiang_kai_shek_memorial_hall_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "台南鹽田.png",
|
|
|
+ title: "tainan_salt_field",
|
|
|
+ description: "tainan_salt_field_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "高雄美麗島.png",
|
|
|
+ title: "kaohsiung_formosa_boulevard_station",
|
|
|
+ description: "kaohsiung_formosa_boulevard_station_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "新北十分瀑布.png",
|
|
|
+ title: "new_taipei_shifen_waterfall",
|
|
|
+ description: "new_taipei_shifen_waterfall_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "臺北故宮.png",
|
|
|
+ title: "taipei_national_palace_museum",
|
|
|
+ description: "taipei_national_palace_museum_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "臺北故宮-2.png",
|
|
|
+ title: "taipei_national_palace_museum_2",
|
|
|
+ description: "taipei_national_palace_museum_2_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "台中歌劇院.png",
|
|
|
+ title: "national_taichung_theater",
|
|
|
+ description: "national_taichung_theater_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "嘉義森林之歌.png",
|
|
|
+ title: "chiayi_song_of_forest",
|
|
|
+ description: "chiayi_song_of_forest_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "基隆八斗子鐵路.png",
|
|
|
+ title: "keelung_baduzi_railway",
|
|
|
+ description: "keelung_baduzi_railway_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "花蓮清水斷崖.png",
|
|
|
+ title: "hualien_qingshui_cliff",
|
|
|
+ description: "hualien_qingshui_cliff_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "澎湖.png",
|
|
|
+ title: "penghu",
|
|
|
+ description: "penghu_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "南投清境農場.png",
|
|
|
+ title: "nantou_qingjing_farm",
|
|
|
+ description: "nantou_qingjing_farm_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "高雄流行音樂中心.png",
|
|
|
+ title: "kaohsiung_music_center",
|
|
|
+ description: "kaohsiung_music_center_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "花蓮金針花山.png",
|
|
|
+ title: "hualien_daylily_mountain",
|
|
|
+ description: "hualien_daylily_mountain_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "新北九份老街.png",
|
|
|
+ title: "new_taipei_jiufen_old_street",
|
|
|
+ description: "new_taipei_jiufen_old_street_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "嘉義阿里山小火車.png",
|
|
|
+ title: "chiayi_alishan_forest_railways",
|
|
|
+ description: "chiayi_alishan_forest_railways_description",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bg_img: "台中高美濕地.png",
|
|
|
+ title: "taichung_gaomei_wetland",
|
|
|
+ description: "taichung_gaomei_wetland_description",
|
|
|
+ },
|
|
|
+]);
|
|
|
+
|
|
|
+console.log("parameter", parameter.value);
|
|
|
|
|
|
async function getParameters() {
|
|
|
let url = `${apiUrl}/sd/parameters`;
|
|
|
|
|
|
try {
|
|
|
let response = await axios.get(url);
|
|
|
- console.log("getParameters", response);
|
|
|
- console.log("response", response);
|
|
|
- parameter.value = response.data;
|
|
|
- console.log("parameter.list", parameter.value);
|
|
|
+ parameterList.value = response.data;
|
|
|
+ console.log("parameterList", parameterList.value);
|
|
|
} catch (error) {
|
|
|
console.log("error", error);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-async function setParameters() {
|
|
|
- let url = `${apiUrl}/sd/paprameter`;
|
|
|
- let getUrl = `${apiUrl}/sd/parameters`;
|
|
|
+// async function setParameters() {
|
|
|
+// let url = `${apiUrl}/sd/paprameter`;
|
|
|
+// let getUrl = `${apiUrl}/sd/parameters`;
|
|
|
|
|
|
- if (assignBgImg.value === "") {
|
|
|
- alert("尚未選取背景圖");
|
|
|
- return;
|
|
|
- } else {
|
|
|
- parameters.bg_img = assignBgImg.value;
|
|
|
- }
|
|
|
+// if (assignBgImg.value === "") {
|
|
|
+// alert("尚未選取背景圖");
|
|
|
+// return;
|
|
|
+// } else {
|
|
|
+// parameters.bg_img = assignBgImg.value;
|
|
|
+// }
|
|
|
|
|
|
- if (!imgFile.value) {
|
|
|
- alert("尚未上傳人物圖");
|
|
|
- }
|
|
|
+// if (!imgFile.value) {
|
|
|
+// alert("尚未上傳人物圖");
|
|
|
+// }
|
|
|
|
|
|
- console.log("parameters", parameters);
|
|
|
+// console.log("parameters", parameters);
|
|
|
|
|
|
- try {
|
|
|
- let response = await axios.post(url, parameters);
|
|
|
- console.log("setParameters", response);
|
|
|
+// try {
|
|
|
+// let response = await axios.post(url, parameters);
|
|
|
+// console.log("setParameters", response);
|
|
|
|
|
|
- if (response.status === 200) {
|
|
|
- let getResponse = await axios.get(getUrl);
|
|
|
- console.log("getResponse", getResponse);
|
|
|
+// if (response.status === 200) {
|
|
|
+// let getResponse = await axios.get(getUrl);
|
|
|
+// console.log("getResponse", getResponse);
|
|
|
|
|
|
- // 算圖
|
|
|
- runImg(getResponse.data.length);
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.log("error", error);
|
|
|
- }
|
|
|
-}
|
|
|
+// // 算圖
|
|
|
+// runImg(getResponse.data.length);
|
|
|
+// }
|
|
|
+// } catch (error) {
|
|
|
+// console.log("error", error);
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
-let imgLoading = ref(false);
|
|
|
-let imgPath = ref("");
|
|
|
+// let imgLoading = ref(false);
|
|
|
+// let imgPath = ref("");
|
|
|
|
|
|
-async function runImg(styleNum) {
|
|
|
- imgPath.value = "";
|
|
|
- imgLoading.value = true;
|
|
|
- console.log("styleNum", styleNum);
|
|
|
- let url = `${apiUrl}/sd/run?seed=${runParameters.seed}&denoising_strength=${runParameters.denoising_strength}&batch_size=${runParameters.batch_size}&n_iter=${runParameters.n_iter}&style_num=${styleNum}`;
|
|
|
+// async function runImg(styleNum) {
|
|
|
+// imgPath.value = "";
|
|
|
+// imgLoading.value = true;
|
|
|
+// console.log("styleNum", styleNum);
|
|
|
+// let url = `${apiUrl}/sd/run?seed=${runParameters.seed}&denoising_strength=${runParameters.denoising_strength}&batch_size=${runParameters.batch_size}&n_iter=${runParameters.n_iter}&style_num=${styleNum}`;
|
|
|
|
|
|
- // 人物圖
|
|
|
- const formData = new FormData();
|
|
|
- formData.append("file", imgFile.value);
|
|
|
+// // 人物圖
|
|
|
+// const formData = new FormData();
|
|
|
+// formData.append("file", imgFile.value);
|
|
|
|
|
|
- try {
|
|
|
- let response = await axios.post(url, formData);
|
|
|
- console.log("runImg", response);
|
|
|
+// try {
|
|
|
+// let response = await axios.post(url, formData);
|
|
|
+// console.log("runImg", response);
|
|
|
|
|
|
- if (response.status === 200) {
|
|
|
- imgPath.value = response.data[0].path;
|
|
|
- imgLoading.value = false;
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.log("error", error);
|
|
|
- }
|
|
|
-}
|
|
|
+// if (response.status === 200) {
|
|
|
+// imgPath.value = response.data[0].path;
|
|
|
+// imgLoading.value = false;
|
|
|
+// }
|
|
|
+// } catch (error) {
|
|
|
+// console.log("error", error);
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
let alertShow = ref(false);
|
|
|
|
|
@@ -220,13 +350,32 @@ function checkImg() {
|
|
|
v-for="item in currentPhotos"
|
|
|
class="bg-img"
|
|
|
>
|
|
|
- <img
|
|
|
+ <v-img
|
|
|
+ cover
|
|
|
+ class="cover"
|
|
|
+ :lazy-src="`http://172.104.93.163:3219/static/assets/img/bg/${item.bg_img}`"
|
|
|
+ :src="`http://172.104.93.163:3219/static/assets/img/bg/${item.bg_img}`"
|
|
|
+ >
|
|
|
+ <template v-slot:placeholder>
|
|
|
+ <div class="d-flex align-center justify-center fill-height">
|
|
|
+ <v-progress-circular
|
|
|
+ color="grey-lighten-4"
|
|
|
+ indeterminate
|
|
|
+ ></v-progress-circular>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </v-img>
|
|
|
+
|
|
|
+ <p>{{ t(item.title) }}</p>
|
|
|
+
|
|
|
+ <!-- <img
|
|
|
class="cover"
|
|
|
:src="`http://172.104.93.163:3219/static/assets/img/bg/${item.bg_img}`"
|
|
|
alt=""
|
|
|
- />
|
|
|
- <!-- {{ bg_img }} -->
|
|
|
- <p>{{ item.bg_img.replace(".png", "") }}</p>
|
|
|
+ /> -->
|
|
|
+
|
|
|
+ <!-- <p>{{ item.bg_img.replace(".png", "") }}</p> -->
|
|
|
+
|
|
|
<img
|
|
|
v-if="item === assignBgImg"
|
|
|
class="icon active"
|
|
@@ -316,7 +465,7 @@ function checkImg() {
|
|
|
|
|
|
<a @click="checkImg()" href="javascript:;" class="main-btn">下一步</a>
|
|
|
|
|
|
- <!-- <router-link to="/step4" class="main-btn">下一步</router-link> -->
|
|
|
+ <!-- <router-link to="/step5" class="main-btn">下一步</router-link> -->
|
|
|
|
|
|
<div v-if="alertShow" class="alert-item">
|
|
|
<v-alert border="top" type="warning" variant="outlined" class="mt-5">
|
|
@@ -375,9 +524,9 @@ function checkImg() {
|
|
|
// border-radius: 5px;
|
|
|
// }
|
|
|
|
|
|
-img {
|
|
|
- width: 100%;
|
|
|
-}
|
|
|
+// img {
|
|
|
+// width: 100%;
|
|
|
+// }
|
|
|
|
|
|
// .title {
|
|
|
// padding-top: 4rem;
|
|
@@ -409,7 +558,7 @@ img {
|
|
|
|
|
|
.cover {
|
|
|
max-width: 100%;
|
|
|
- width: 30rem;
|
|
|
+ width: 20rem;
|
|
|
height: 25vh;
|
|
|
object-fit: cover;
|
|
|
}
|