auth.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <div class="w-full h-full flex justify-center items-center">
  3. <form @submit.prevent="auth" class="flex flex-col gap-3">
  4. <h1 class="text-4xl font-light text-center">KTC Auth</h1>
  5. <input class="bg-transparent border-[1px] border-white text-white text-lg outline-none p-3 rounded-md" placeholder="Логин" type="text" v-model="authData.login">
  6. <input class="bg-transparent border-[1px] border-white text-white text-lg outline-none p-3 rounded-md" placeholder="Пароль" type="password" v-model="authData.password">
  7. <button class="border-[1px] font-semibold text-md border-primary rounded-md flex gap-3 justify-center items-center duration-150" :class="isLoading ? 'h-10' : 'h-12'" type="submit">
  8. <Icon name="svg-spinners:ring-resize" v-if="isLoading" class="w-6 h-6" />
  9. <p class="text-lg">{{ isLoading ? 'Авторизация' : 'Войти в аккаунт' }}</p>
  10. </button>
  11. </form>
  12. </div>
  13. </template>
  14. <script setup lang="ts">
  15. import { $fetch } from 'ofetch'
  16. import { useUser } from '~/store/useUser';
  17. definePageMeta({
  18. layout: 'none'
  19. })
  20. const { public: {API_URL} } = useRuntimeConfig()
  21. const user = useUser()
  22. const isLoading = ref(false)
  23. const router = useRouter()
  24. const authData = reactive({
  25. login: "rp-09-21-1-morozovvv",
  26. password: "whwye323"
  27. })
  28. async function auth() {
  29. isLoading.value = true
  30. const res = await $fetch(`${API_URL}/user/login`, {
  31. method: "POST",
  32. body: authData
  33. })
  34. user.setUserData(res)
  35. router.push('/profile')
  36. console.log('ok')
  37. }
  38. </script>