123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <script setup lang="ts">
- import { ref, reactive } from "vue";
- import { useMainStore } from "@/stores/main";
- import { required } from "@/utils";
- import { useI18n } from "vue-i18n";
- import type { ArticleCreate } from "@/interfaces";
- // import Dialog from "@/components/Dialog.vue";
- const mainStore = useMainStore();
- const { t } = useI18n();
- const valid = ref(true);
- const Form = ref();
- let title = ref("");
- let link = ref("");
- let content = ref("");
- // props
- // let dialog = reactive({
- // msg: "上傳成功!",
- // state: "success",
- // show: false,
- // });
- async function Submit() {
- // setTimeout(() => {
- // dialog.show = true;
- // }, 2000);
- await (Form as any).value.validate();
- if (valid.value) {
- valid.value = false;
- const article_data: ArticleCreate = {
- title: title.value,
- link: link.value,
- content: content.value,
- };
- await mainStore.uploadArticle(article_data);
- // (Form as any).value.reset();
- }
- }
- </script>
- <template>
- <v-container fluid>
- <v-card class="ma-3 pa-3">
- <v-card-title primary-title>
- <h3 class="card-title mb-3">{{ t("makeArticle") }}</h3>
- </v-card-title>
- <v-card-text>
- <v-form v-model="valid" ref="Form">
- <v-text-field
- :label="$t('articleTitle')"
- v-model="title"
- :rules="required"
- prepend-icon="title"
- >
- </v-text-field>
- <v-text-field
- v-model="link"
- :label="$t('articleLink')"
- prepend-icon="link"
- >
- </v-text-field>
- <v-textarea
- v-model="content"
- :label="$t('articleContent')"
- prepend-icon="edit_document"
- ></v-textarea>
- </v-form>
- </v-card-text>
- <v-card-actions>
- <v-spacer></v-spacer>
- <v-btn @click="Submit" :disabled="!valid">
- {{ t("send") }}
- </v-btn>
- </v-card-actions>
- </v-card>
- <!-- <template>
- <div class="text-center">
- <Dialog
- :msg="dialog.msg"
- :state="dialog.state"
- :dialog="dialog.show"
- @close="dialog.show = false"
- ></Dialog>
- </div>
- </template> -->
- </v-container>
- </template>
- <style lang="scss"></style>
|