forget-password.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <script setup lang="ts">
  2. import { computed, reactive } from 'vue';
  3. import { useRouter } from 'vue-router';
  4. import { LOGIN_PATH } from '@vben/constants';
  5. import { $t } from '@vben-core/locales';
  6. import { VbenButton, VbenInput } from '@vben-core/shadcn-ui';
  7. import Title from './auth-title.vue';
  8. interface Props {
  9. /**
  10. * @zh_CN 是否处于加载处理状态
  11. */
  12. loading?: boolean;
  13. /**
  14. * @zh_CN 登陆路径
  15. */
  16. loginPath?: string;
  17. }
  18. defineOptions({
  19. name: 'AuthenticationForgetPassword',
  20. });
  21. const props = withDefaults(defineProps<Props>(), {
  22. loading: false,
  23. loginPath: LOGIN_PATH,
  24. });
  25. const emit = defineEmits<{
  26. submit: [string];
  27. }>();
  28. const router = useRouter();
  29. const formState = reactive({
  30. email: '',
  31. submitted: false,
  32. });
  33. const emailStatus = computed(() => {
  34. return formState.submitted && !formState.email ? 'error' : 'default';
  35. });
  36. function handleSubmut() {
  37. formState.submitted = true;
  38. if (emailStatus.value !== 'default') {
  39. return;
  40. }
  41. emit('submit', formState.email);
  42. }
  43. function goLogin() {
  44. router.push(props.loginPath);
  45. }
  46. </script>
  47. <template>
  48. <div>
  49. <Title>
  50. {{ $t('authentication.forgetPassword') }} 🤦🏻‍♂️
  51. <template #desc>
  52. {{ $t('authentication.forgetPasswordSubtitle') }}
  53. </template>
  54. </Title>
  55. <div class="mb-6">
  56. <VbenInput
  57. v-model="formState.email"
  58. :error-tip="$t('authentication.emailTip')"
  59. :label="$t('authentication.email')"
  60. :status="emailStatus"
  61. autofocus
  62. name="email"
  63. placeholder="example@example.com"
  64. type="text"
  65. />
  66. </div>
  67. <div>
  68. <VbenButton class="mt-2 w-full" @click="handleSubmut">
  69. {{ $t('authentication.sendResetLink') }}
  70. </VbenButton>
  71. <VbenButton class="mt-4 w-full" variant="outline" @click="goLogin()">
  72. {{ $t('common.back') }}
  73. </VbenButton>
  74. </div>
  75. </div>
  76. </template>