2024-05-19 21:20:42 +08:00
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { computed, reactive } from 'vue';
|
|
|
|
|
import { useRouter } from 'vue-router';
|
|
|
|
|
|
2024-07-05 23:15:46 +08:00
|
|
|
|
import { LOGIN_PATH } from '@vben/constants';
|
2024-07-07 00:17:44 +08:00
|
|
|
|
import { $t } from '@vben-core/locales';
|
2024-06-08 19:49:06 +08:00
|
|
|
|
import { VbenButton, VbenInput } from '@vben-core/shadcn-ui';
|
|
|
|
|
|
2024-05-19 21:20:42 +08:00
|
|
|
|
import Title from './auth-title.vue';
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
/**
|
|
|
|
|
* @zh_CN 是否处于加载处理状态
|
|
|
|
|
*/
|
|
|
|
|
loading?: boolean;
|
2024-06-02 21:21:34 +08:00
|
|
|
|
/**
|
|
|
|
|
* @zh_CN 登陆路径
|
|
|
|
|
*/
|
|
|
|
|
loginPath?: string;
|
2024-05-19 21:20:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defineOptions({
|
|
|
|
|
name: 'AuthenticationForgetPassword',
|
|
|
|
|
});
|
|
|
|
|
|
2024-06-02 21:21:34 +08:00
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
2024-05-19 21:20:42 +08:00
|
|
|
|
loading: false,
|
2024-07-05 23:15:46 +08:00
|
|
|
|
loginPath: LOGIN_PATH,
|
2024-05-19 21:20:42 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
|
submit: [string];
|
|
|
|
|
}>();
|
|
|
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const formState = reactive({
|
|
|
|
|
email: '',
|
|
|
|
|
submitted: false,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const emailStatus = computed(() => {
|
|
|
|
|
return formState.submitted && !formState.email ? 'error' : 'default';
|
|
|
|
|
});
|
|
|
|
|
|
2024-07-14 13:48:47 +08:00
|
|
|
|
function handleSubmit() {
|
2024-05-19 21:20:42 +08:00
|
|
|
|
formState.submitted = true;
|
|
|
|
|
if (emailStatus.value !== 'default') {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
emit('submit', formState.email);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 12:14:09 +08:00
|
|
|
|
function goToLogin() {
|
2024-06-02 21:21:34 +08:00
|
|
|
|
router.push(props.loginPath);
|
2024-05-19 21:20:42 +08:00
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<Title>
|
2024-07-10 21:55:16 +08:00
|
|
|
|
{{ $t('authentication.forgetPassword') }} 🤦🏻♂️
|
2024-05-19 21:20:42 +08:00
|
|
|
|
<template #desc>
|
2024-07-10 21:55:16 +08:00
|
|
|
|
{{ $t('authentication.forgetPasswordSubtitle') }}
|
2024-05-19 21:20:42 +08:00
|
|
|
|
</template>
|
|
|
|
|
</Title>
|
|
|
|
|
<div class="mb-6">
|
|
|
|
|
<VbenInput
|
|
|
|
|
v-model="formState.email"
|
2024-07-10 21:55:16 +08:00
|
|
|
|
:error-tip="$t('authentication.emailTip')"
|
2024-05-19 21:20:42 +08:00
|
|
|
|
:label="$t('authentication.email')"
|
2024-06-09 13:31:43 +08:00
|
|
|
|
:status="emailStatus"
|
2024-05-19 21:20:42 +08:00
|
|
|
|
autofocus
|
2024-06-09 13:31:43 +08:00
|
|
|
|
name="email"
|
2024-05-19 21:20:42 +08:00
|
|
|
|
placeholder="example@example.com"
|
|
|
|
|
type="text"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
2024-07-14 13:48:47 +08:00
|
|
|
|
<VbenButton class="mt-2 w-full" @click="handleSubmit">
|
2024-07-10 21:55:16 +08:00
|
|
|
|
{{ $t('authentication.sendResetLink') }}
|
2024-05-19 21:20:42 +08:00
|
|
|
|
</VbenButton>
|
2024-07-12 12:14:09 +08:00
|
|
|
|
<VbenButton class="mt-4 w-full" variant="outline" @click="goToLogin()">
|
2024-05-19 21:20:42 +08:00
|
|
|
|
{{ $t('common.back') }}
|
|
|
|
|
</VbenButton>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|