Upload.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. dialog.value = true;
  21. await (Form as any).value.validate();
  22. if (valid.value) {
  23. await mainStore.uploadPlot(title.value, zipFiles.value[0]);
  24. (Form as any).value.reset();
  25. }
  26. }
  27. </script>
  28. <template>
  29. <v-container fluid>
  30. <v-card class="ma-3 pa-3">
  31. <v-card-title primary-title>
  32. <h3 class="card-title mb-3">{{ t("makeVideo") }}</h3>
  33. </v-card-title>
  34. <v-card-text>
  35. <v-form v-model="valid" ref="Form">
  36. <v-text-field
  37. :label="$t('title')"
  38. v-model="title"
  39. :rules="required"
  40. prepend-icon="title"
  41. >
  42. </v-text-field>
  43. <v-file-input
  44. v-model="zipFiles"
  45. :rules="[(v) => v.length || 'select zip file.']"
  46. accept=".zip"
  47. :label="$t('fileInput')"
  48. prepend-icon="folder_zip"
  49. ></v-file-input>
  50. </v-form>
  51. </v-card-text>
  52. <v-card-actions>
  53. <v-spacer></v-spacer>
  54. <v-btn @click="Submit" :disabled="!valid">
  55. {{ t("send") }}
  56. </v-btn>
  57. </v-card-actions>
  58. </v-card>
  59. <template>
  60. <div class="text-center">
  61. <v-dialog v-model="dialog" width="auto">
  62. <v-card>
  63. <v-card-text>
  64. <section class="d-flex flex-column align-center">
  65. <v-icon
  66. style="font-size: 70px"
  67. icon="info"
  68. color="orange-darken-3"
  69. />
  70. <p class="mt-3">影片處理需要約 5-10 分鐘,敬請耐心等候</p>
  71. </section>
  72. </v-card-text>
  73. <v-card-actions>
  74. <v-btn color="primary" block @click="dialog = false">{{
  75. t("close")
  76. }}</v-btn>
  77. </v-card-actions>
  78. </v-card>
  79. </v-dialog>
  80. </div>
  81. </template>
  82. </v-container>
  83. </template>