|
@@ -2,10 +2,12 @@
|
|
|
import { ref, reactive, onMounted } from "vue";
|
|
|
import { useMainStore } from "@/stores/store";
|
|
|
import { useRouter } from "vue-router";
|
|
|
+import { useI18n } from "vue-i18n";
|
|
|
import axios from "axios";
|
|
|
import Footer from "../components/Footer.vue";
|
|
|
import VuePictureCropper, { cropper } from "vue-picture-cropper";
|
|
|
|
|
|
+const { t } = useI18n();
|
|
|
const router = useRouter();
|
|
|
const store = useMainStore();
|
|
|
const apiUrl = import.meta.env.VITE_API_URL;
|
|
@@ -76,33 +78,37 @@ function reset() {
|
|
|
cropper.reset();
|
|
|
}
|
|
|
|
|
|
-// function ready() {
|
|
|
-// console.log("Cropper is ready.");
|
|
|
-// }
|
|
|
-// 測試結束
|
|
|
+// 重新上傳
|
|
|
+function remove() {
|
|
|
+ file.value = null;
|
|
|
+ imgFile.value = null;
|
|
|
+ // imageUrl.value = null;
|
|
|
+ pic.value = "";
|
|
|
+ result.dataURL = "";
|
|
|
+}
|
|
|
|
|
|
console.log("step5 store.assignBgImg", store.assignBgImg);
|
|
|
|
|
|
let file = ref(null);
|
|
|
-let fileInput = ref(null);
|
|
|
+// let fileInput = ref(null);
|
|
|
let imgFile = ref(null);
|
|
|
-let imageUrl = ref(null);
|
|
|
+// let imageUrl = ref(null);
|
|
|
|
|
|
// 選擇檔案
|
|
|
-function onFileChange() {
|
|
|
- console.log("fileInput", fileInput.value);
|
|
|
- if (fileInput.value.files.length) {
|
|
|
- imgFile.value = fileInput.value.files[0];
|
|
|
-
|
|
|
- // 預覽相片
|
|
|
- const reader = new FileReader();
|
|
|
- reader.onload = () => {
|
|
|
- imageUrl.value = reader.result;
|
|
|
- };
|
|
|
- reader.readAsDataURL(imgFile.value);
|
|
|
- }
|
|
|
- console.log("imgFile.value", imgFile.value);
|
|
|
-}
|
|
|
+// function onFileChange() {
|
|
|
+// console.log("fileInput", fileInput.value);
|
|
|
+// if (fileInput.value.files.length) {
|
|
|
+// imgFile.value = fileInput.value.files[0];
|
|
|
+
|
|
|
+// // 預覽相片
|
|
|
+// const reader = new FileReader();
|
|
|
+// reader.onload = () => {
|
|
|
+// imageUrl.value = reader.result;
|
|
|
+// };
|
|
|
+// reader.readAsDataURL(imgFile.value);
|
|
|
+// }
|
|
|
+// console.log("imgFile.value", imgFile.value);
|
|
|
+// }
|
|
|
|
|
|
let imgLoading = ref(false);
|
|
|
|
|
@@ -123,7 +129,7 @@ async function upload() {
|
|
|
|
|
|
store.imgPath = "";
|
|
|
imgLoading.value = true;
|
|
|
- console.log("store styleNum >>>", store.styleNum);
|
|
|
+ console.log("store styleNum", store.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=${store.styleNum}`;
|
|
|
|
|
@@ -147,12 +153,6 @@ async function upload() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function remove() {
|
|
|
- file.value = null;
|
|
|
- imgFile.value = null;
|
|
|
- imageUrl.value = null;
|
|
|
-}
|
|
|
-
|
|
|
const openUploadInput = () => {
|
|
|
if (uploadInput.value) {
|
|
|
uploadInput.value.click();
|
|
@@ -168,8 +168,8 @@ const openUploadInput = () => {
|
|
|
class="d-flex flex-column align-center justify-center"
|
|
|
>
|
|
|
<p class="mb-15">
|
|
|
- 明信片製作中… <br />
|
|
|
- 請稍等約 30 秒
|
|
|
+ {{ t("postcard.step5.text_1") }}<br />
|
|
|
+ {{ t("postcard.step5.text_2") }}
|
|
|
</p>
|
|
|
|
|
|
<v-progress-circular
|
|
@@ -179,11 +179,11 @@ const openUploadInput = () => {
|
|
|
indeterminate
|
|
|
></v-progress-circular>
|
|
|
|
|
|
- <p class="mt-15">AI 正在迅速地帶您前往該景點</p>
|
|
|
+ <p class="mt-15">{{ t("postcard.step5.text_3") }}</p>
|
|
|
</div>
|
|
|
|
|
|
<div v-else>
|
|
|
- <p class="title mb-5">請上傳您的相片</p>
|
|
|
+ <p class="title mb-5">{{ t("postcard.step5.text_4") }}</p>
|
|
|
|
|
|
<div class="d-flex justify-center">
|
|
|
<v-btn
|
|
@@ -194,7 +194,7 @@ const openUploadInput = () => {
|
|
|
>
|
|
|
<span class="d-flex align-center">
|
|
|
<v-icon icon="mdi-camera" class="me-3 pt-1"> </v-icon>
|
|
|
- <p>照相/選擇相片</p>
|
|
|
+ <p>{{ t("postcard.step5.text_5") }}</p>
|
|
|
</span>
|
|
|
</v-btn>
|
|
|
</div>
|
|
@@ -232,11 +232,11 @@ const openUploadInput = () => {
|
|
|
|
|
|
<div class="mt-5 d-flex justify-end">
|
|
|
<v-btn @click="reset" color="grey" variant="flat" class="me-3">
|
|
|
- 重置
|
|
|
+ {{ t("postcard.step5.text_6") }}
|
|
|
</v-btn>
|
|
|
|
|
|
<v-btn @click="getResult" color="primary" variant="flat">
|
|
|
- 裁剪
|
|
|
+ {{ t("postcard.step5.text_7") }}
|
|
|
</v-btn>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -254,6 +254,10 @@ const openUploadInput = () => {
|
|
|
></div>
|
|
|
<!-- <img :src="result.dataURL" /> -->
|
|
|
</div>
|
|
|
+
|
|
|
+ <p class="text-white mt-5">
|
|
|
+ 將人像放置於畫面右下角<br />會得到最好看的畫面唷!
|
|
|
+ </p>
|
|
|
</section>
|
|
|
|
|
|
<!-- <v-file-input
|
|
@@ -269,14 +273,16 @@ const openUploadInput = () => {
|
|
|
<div class="preview-img">
|
|
|
<img class="w-100 mt-5" :src="imageUrl" alt="照片" v-if="imageUrl" />
|
|
|
</div> -->
|
|
|
+
|
|
|
+ <div class="btn-content">
|
|
|
+ <button @click="remove()" class="main-btn">
|
|
|
+ {{ t("postcard.step5.text_8") }}
|
|
|
+ </button>
|
|
|
+ <button @click="upload()" class="main-btn">{{ t("confirm") }}</button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
|
|
|
<!-- <router-link to="/step6" class="main-btn">確定</router-link> -->
|
|
|
-
|
|
|
- <div class="btn-content">
|
|
|
- <button @click="remove()" class="main-btn">重新上傳</button>
|
|
|
- <button @click="upload()" class="main-btn">確定</button>
|
|
|
- </div>
|
|
|
</v-container>
|
|
|
|
|
|
<Footer url="/step4" />
|
|
@@ -346,7 +352,7 @@ const openUploadInput = () => {
|
|
|
|
|
|
.btn-content {
|
|
|
width: 100%;
|
|
|
- padding: 100px 20px 20px;
|
|
|
+ padding: 100px 10px 20px;
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
// position: absolute;
|