Upload.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <script setup lang="ts">
  2. import { ref, watch } from "vue";
  3. import { useMainStore } from "@/stores/main";
  4. import { required } from "@/utils";
  5. import { useI18n } from "vue-i18n";
  6. import router from "@/router";
  7. const { t } = useI18n();
  8. const valid = ref(true);
  9. const dialog = ref(false);
  10. const title = ref("");
  11. const zipFiles = ref();
  12. const Form = ref();
  13. const mainStore = useMainStore();
  14. watch(dialog, (newVal, oldVal) => {
  15. if (!newVal) {
  16. router.push("/main/progress");
  17. }
  18. });
  19. async function Submit() {
  20. setTimeout(() => {
  21. dialog.value = true;
  22. }, 2000);
  23. await (Form as any).value.validate();
  24. if (valid.value) {
  25. valid.value = false;
  26. await mainStore.uploadPlot(title.value, zipFiles.value[0]);
  27. // (Form as any).value.reset();
  28. }
  29. }
  30. </script>
  31. <template>
  32. <v-container fluid>
  33. <v-card class="ma-3 pa-3">
  34. <v-card-title primary-title>
  35. <h3 class="card-title mb-3">{{ t("makeVideo") }}</h3>
  36. </v-card-title>
  37. <v-card-text>
  38. <v-form v-model="valid" ref="Form">
  39. <v-text-field
  40. :label="$t('title')"
  41. v-model="title"
  42. :rules="required"
  43. prepend-icon="title"
  44. >
  45. </v-text-field>
  46. <v-file-input
  47. v-model="zipFiles"
  48. :rules="[(v) => v.length || 'select zip file.']"
  49. accept=".zip"
  50. :label="$t('fileInput')"
  51. prepend-icon="folder_zip"
  52. ></v-file-input>
  53. </v-form>
  54. </v-card-text>
  55. <v-card-actions>
  56. <v-spacer></v-spacer>
  57. <v-btn @click="Submit" :disabled="!valid">
  58. {{ t("send") }}
  59. </v-btn>
  60. </v-card-actions>
  61. </v-card>
  62. <template>
  63. <div class="text-center">
  64. <v-dialog v-model="dialog" width="auto">
  65. <v-card>
  66. <v-card-text>
  67. <section class="d-flex flex-column align-center">
  68. <v-icon
  69. style="font-size: 70px"
  70. icon="info"
  71. color="orange-darken-3"
  72. />
  73. <p class="mt-3">影片處理需要約 5-10 分鐘,敬請耐心等候</p>
  74. </section>
  75. </v-card-text>
  76. <v-card-actions>
  77. <v-btn color="primary" block @click="dialog = false">{{
  78. t("close")
  79. }}</v-btn>
  80. </v-card-actions>
  81. </v-card>
  82. </v-dialog>
  83. </div>
  84. </template>
  85. </v-container>
  86. </template>