|
@@ -0,0 +1,175 @@
|
|
|
+<script setup lang="ts">
|
|
|
+import { ref, reactive, watch,computed } from "vue";
|
|
|
+import { useMainStore } from "@/stores/main";
|
|
|
+import { required } from "@/utils";
|
|
|
+import { useI18n } from "vue-i18n";
|
|
|
+
|
|
|
+const mainStore = useMainStore();
|
|
|
+const { t } = useI18n();
|
|
|
+const valid = ref(true);
|
|
|
+const dialog = ref(false);
|
|
|
+const title = ref("");
|
|
|
+const Form = ref();
|
|
|
+let imgFiles = ref();
|
|
|
+let imgList: any[] = reactive([]);
|
|
|
+
|
|
|
+const plusOne = computed(() => imgFiles.value.files)
|
|
|
+console.log('plusOne',plusOne);
|
|
|
+
|
|
|
+
|
|
|
+watch(imgList, (newVal, oldVal) => {
|
|
|
+ console.log('newVal',newVal);
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+async function upload() {
|
|
|
+ for (let i = 0; i < imgFiles.value.files.length; i++) {
|
|
|
+ const item = imgFiles.value.files[i];
|
|
|
+ imgList.push(item)
|
|
|
+ console.log('element',item.name);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// async function Submit() {
|
|
|
+// setTimeout(() => {
|
|
|
+// dialog.value = true;
|
|
|
+// }, 2000);
|
|
|
+// await (Form as any).value.validate();
|
|
|
+// if (valid.value) {
|
|
|
+// valid.value = false;
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+const headers = [
|
|
|
+ {
|
|
|
+ title: "檔名",
|
|
|
+ sortable: true,
|
|
|
+ key: "name",
|
|
|
+ align: "left",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t("state"),
|
|
|
+ sortable: true,
|
|
|
+ key: "progress_state",
|
|
|
+ align: "left",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t("preview"),
|
|
|
+ key: "id",
|
|
|
+ },
|
|
|
+];
|
|
|
+
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <v-container fluid>
|
|
|
+ <v-card class="ma-3 pa-3">
|
|
|
+ <v-card-title primary-title>
|
|
|
+ <h3 class="card-title mb-3">圖片優化</h3>
|
|
|
+ </v-card-title>
|
|
|
+ <v-card-text>
|
|
|
+ <v-form v-model="valid" ref="Form" class="img-form">
|
|
|
+ <img src="@/assets/img/icon/add-image.png" alt="" class="mb-4" />
|
|
|
+ <input
|
|
|
+ @change="upload()"
|
|
|
+ ref="imgFiles"
|
|
|
+ type="file"
|
|
|
+ multiple
|
|
|
+ class="file-input"
|
|
|
+ />
|
|
|
+ <p>請點擊加入圖片並開始優化</p>
|
|
|
+ </v-form>
|
|
|
+ </v-card-text>
|
|
|
+ <v-card-actions class="justify-center">
|
|
|
+ <v-btn
|
|
|
+ variant="flat"
|
|
|
+ size="large"
|
|
|
+ color="primary"
|
|
|
+ class="px-5"
|
|
|
+ prepend-icon="file_upload"
|
|
|
+ >上傳圖片</v-btn
|
|
|
+ >
|
|
|
+ </v-card-actions>
|
|
|
+ </v-card>
|
|
|
+
|
|
|
+ <v-card class="ma-3 pa-3 mt-6 img-progress">
|
|
|
+ <v-card-title primary-title>
|
|
|
+ <h3 class="card-title mb-3">上傳清單</h3>
|
|
|
+ </v-card-title>
|
|
|
+
|
|
|
+
|
|
|
+ <v-data-table :headers="headers" :items="imgList">
|
|
|
+ <template v-slot:item.progress_state="{ item }">
|
|
|
+ <span v-if="item.raw.progress_state === 'completed'">
|
|
|
+ <v-icon icon="check_circle" color="success" />
|
|
|
+ 完成
|
|
|
+ </span>
|
|
|
+ <span v-else-if="item.raw.progress_state === 'waiting'">
|
|
|
+ <v-icon icon="pending" color="warning" />
|
|
|
+ 等待中
|
|
|
+ </span>
|
|
|
+ <span v-else-if="item.raw.progress_state === 'processing'">
|
|
|
+ <v-progress-circular
|
|
|
+ indeterminate
|
|
|
+ color="info"
|
|
|
+ style="width: 20px"
|
|
|
+ ></v-progress-circular>
|
|
|
+ 處理中
|
|
|
+ </span>
|
|
|
+ <span v-else>
|
|
|
+ <v-icon icon="check_circle" color="success" />
|
|
|
+ 完成
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ <template v-slot:item.id="{ item }">
|
|
|
+ <v-icon icon="crop_original" />
|
|
|
+ </template>
|
|
|
+ </v-data-table>
|
|
|
+ </v-card>
|
|
|
+ </v-container>
|
|
|
+</template>
|
|
|
+
|
|
|
+<style lang="scss">
|
|
|
+.img-form {
|
|
|
+ position: relative;
|
|
|
+ top: 50%;
|
|
|
+ left: 50%;
|
|
|
+ margin-left: -250px;
|
|
|
+ width: 500px;
|
|
|
+ height: 200px;
|
|
|
+ border: 2px dashed #b5b5b5;
|
|
|
+ .file-input {
|
|
|
+ position: absolute;
|
|
|
+ z-index: 100;
|
|
|
+ margin: 0;
|
|
|
+ padding: 0;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ outline: none;
|
|
|
+ opacity: 0;
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+ img {
|
|
|
+ position: absolute;
|
|
|
+ width: 50px;
|
|
|
+ left: 50%;
|
|
|
+ top: 50%;
|
|
|
+ transform: translate(-50%, -80%);
|
|
|
+ }
|
|
|
+ p {
|
|
|
+ width: 100%;
|
|
|
+ text-align: center;
|
|
|
+ position: absolute;
|
|
|
+ bottom: 50px;
|
|
|
+ font-size: 18px;
|
|
|
+ font-weight: 600;
|
|
|
+ letter-spacing: 1px;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.img-progress {
|
|
|
+ .v-data-table-footer {
|
|
|
+ margin-top: 20px;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|