This commit is contained in:
dap
2024-10-21 07:58:31 +08:00
77 changed files with 188 additions and 223 deletions

View File

@@ -1,11 +1,7 @@
<script setup lang="ts">
import type { VbenFormSchema } from '@vben-core/form-ui';
import type {
AuthenticationProps,
LoginAndRegisterParams,
LoginEmits,
} from './types';
import type { AuthenticationProps, LoginAndRegisterParams } from './types';
import { computed, onMounted, reactive, ref } from 'vue';
import { useRouter } from 'vue-router';
@@ -13,6 +9,7 @@ import { useRouter } from 'vue-router';
import { $t } from '@vben/locales';
import { useVbenForm } from '@vben-core/form-ui';
import { VbenButton, VbenCheckbox } from '@vben-core/shadcn-ui';
import { cloneDeep } from '@vben-core/shared/utils';
import Title from './auth-title.vue';
import ThirdPartyLogin from './third-party-login.vue';
@@ -44,10 +41,10 @@ const props = withDefaults(defineProps<Props>(), {
});
const emit = defineEmits<{
submit: LoginEmits['submit'];
submit: [LoginAndRegisterParams];
}>();
const [Form, { setFieldValue, validate }] = useVbenForm(
const [Form, { setFieldValue, validate, getValues }] = useVbenForm(
reactive({
commonConfig: {
hideLabel: true,
@@ -66,7 +63,8 @@ const localUsername = localStorage.getItem(REMEMBER_ME_KEY) || '';
const rememberMe = ref(!!localUsername);
async function handleSubmit() {
const { valid, values } = await validate();
const { valid } = await validate();
const values = cloneDeep(await getValues());
if (valid) {
localStorage.setItem(
REMEMBER_ME_KEY,
@@ -126,7 +124,7 @@ defineExpose({ setFieldValue });
<span
v-if="showForgetPassword"
class="text-primary hover:text-primary-hover active:text-primary-active cursor-pointer text-sm font-normal"
class="vben-link text-sm font-normal"
@click="handleGo(forgetPasswordPath)"
>
{{ $t('authentication.forgetPassword') }}
@@ -175,7 +173,7 @@ defineExpose({ setFieldValue });
<div v-if="showRegister" class="mt-3 text-center text-sm">
{{ $t('authentication.accountTip') }}
<span
class="text-primary hover:text-primary-hover active:text-primary-active cursor-pointer text-sm font-normal"
class="vben-link text-sm font-normal"
@click="handleGo(registerPath)"
>
{{ $t('authentication.createAccount') }}