admin-vben5/packages/effects/common-ui/src/authentication/forget-password.vue

88 lines
1.9 KiB
Vue
Raw Normal View History

2024-05-19 21:20:42 +08:00
<script setup lang="ts">
import { computed, reactive } from 'vue';
import { useRouter } from 'vue-router';
import { LOGIN_PATH } from '@vben/constants';
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;
/**
* @zh_CN 登陆路径
*/
loginPath?: string;
2024-05-19 21:20:42 +08:00
}
defineOptions({
name: 'AuthenticationForgetPassword',
});
const props = withDefaults(defineProps<Props>(), {
2024-05-19 21:20:42 +08:00
loading: false,
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);
}
function goToLogin() {
router.push(props.loginPath);
2024-05-19 21:20:42 +08:00
}
</script>
<template>
<div>
<Title>
{{ $t('authentication.forgetPassword') }} 🤦🏻
2024-05-19 21:20:42 +08:00
<template #desc>
{{ $t('authentication.forgetPasswordSubtitle') }}
2024-05-19 21:20:42 +08:00
</template>
</Title>
<div class="mb-6">
<VbenInput
v-model="formState.email"
: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">
{{ $t('authentication.sendResetLink') }}
2024-05-19 21:20:42 +08:00
</VbenButton>
<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>