mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-25 16:16:20 +08:00
perf: adjustment of form spelling errors, type adjustment, closer to actual development (#4694)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @zh_CN 登陆页面 url 地址
|
||||
* @zh_CN 登录页面 url 地址
|
||||
*/
|
||||
export const LOGIN_PATH = '/auth/login';
|
||||
|
||||
|
@@ -1,8 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import type { Recordable } from '@vben/types';
|
||||
import type { VbenFormSchema } from '@vben-core/form-ui';
|
||||
|
||||
import type { LoginCodeEmits } from './types';
|
||||
|
||||
import { computed, reactive } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
@@ -19,7 +18,7 @@ interface Props {
|
||||
*/
|
||||
loading?: boolean;
|
||||
/**
|
||||
* @zh_CN 登陆路径
|
||||
* @zh_CN 登录路径
|
||||
*/
|
||||
loginPath?: string;
|
||||
/**
|
||||
@@ -49,12 +48,12 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
submit: LoginCodeEmits['submit'];
|
||||
submit: [Recordable<any>];
|
||||
}>();
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const [Form, { validate }] = useVbenForm(
|
||||
const [Form, { validate, getValues }] = useVbenForm(
|
||||
reactive({
|
||||
commonConfig: {
|
||||
hideLabel: true,
|
||||
@@ -66,8 +65,8 @@ const [Form, { validate }] = useVbenForm(
|
||||
);
|
||||
|
||||
async function handleSubmit() {
|
||||
const { valid, values } = await validate();
|
||||
|
||||
const { valid } = await validate();
|
||||
const values = await getValues();
|
||||
if (valid) {
|
||||
emit('submit', {
|
||||
code: values?.code,
|
||||
|
@@ -17,7 +17,7 @@ interface Props {
|
||||
*/
|
||||
loading?: boolean;
|
||||
/**
|
||||
* @zh_CN 登陆路径
|
||||
* @zh_CN 登录路径
|
||||
*/
|
||||
loginPath?: string;
|
||||
/**
|
||||
@@ -47,10 +47,10 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
submit: [string];
|
||||
submit: [Record<string, any>];
|
||||
}>();
|
||||
|
||||
const [Form, { validate }] = useVbenForm(
|
||||
const [Form, { validate, getValues }] = useVbenForm(
|
||||
reactive({
|
||||
commonConfig: {
|
||||
hideLabel: true,
|
||||
@@ -64,10 +64,10 @@ const [Form, { validate }] = useVbenForm(
|
||||
const router = useRouter();
|
||||
|
||||
async function handleSubmit() {
|
||||
const { valid, values } = await validate();
|
||||
|
||||
const { valid } = await validate();
|
||||
const values = await getValues();
|
||||
if (valid) {
|
||||
emit('submit', values?.email);
|
||||
emit('submit', values);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -4,8 +4,4 @@ export { default as AuthenticationLogin } from './login.vue';
|
||||
export { default as AuthenticationLoginExpiredModal } from './login-expired-modal.vue';
|
||||
export { default as AuthenticationQrCodeLogin } from './qrcode-login.vue';
|
||||
export { default as AuthenticationRegister } from './register.vue';
|
||||
export type {
|
||||
AuthenticationProps,
|
||||
LoginAndRegisterParams,
|
||||
LoginCodeParams,
|
||||
} from './types';
|
||||
export type { AuthenticationProps } from './types';
|
||||
|
@@ -1,7 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import type { Recordable } from '@vben/types';
|
||||
import type { VbenFormSchema } from '@vben-core/form-ui';
|
||||
|
||||
import type { AuthenticationProps, LoginEmits } from './types';
|
||||
import type { AuthenticationProps } from './types';
|
||||
|
||||
import { computed, onMounted, reactive, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
@@ -40,10 +41,10 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
submit: LoginEmits['submit'];
|
||||
submit: [Recordable<any>];
|
||||
}>();
|
||||
|
||||
const [Form, { setFieldValue, validate }] = useVbenForm(
|
||||
const [Form, { setFieldValue, validate, getValues }] = useVbenForm(
|
||||
reactive({
|
||||
commonConfig: {
|
||||
hideLabel: true,
|
||||
@@ -62,13 +63,14 @@ 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 = await getValues();
|
||||
if (valid) {
|
||||
localStorage.setItem(
|
||||
REMEMBER_ME_KEY,
|
||||
rememberMe.value ? values?.username : '',
|
||||
);
|
||||
emit('submit', values as { password: string; username: string });
|
||||
emit('submit', values);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,7 @@ interface Props {
|
||||
*/
|
||||
loading?: boolean;
|
||||
/**
|
||||
* @zh_CN 登陆路径
|
||||
* @zh_CN 登录路径
|
||||
*/
|
||||
loginPath?: string;
|
||||
/**
|
||||
|
@@ -1,8 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import type { Recordable } from '@vben/types';
|
||||
import type { VbenFormSchema } from '@vben-core/form-ui';
|
||||
|
||||
import type { RegisterEmits } from './types';
|
||||
|
||||
import { computed, reactive } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
@@ -19,7 +18,7 @@ interface Props {
|
||||
*/
|
||||
loading?: boolean;
|
||||
/**
|
||||
* @zh_CN 登陆路径
|
||||
* @zh_CN 登录路径
|
||||
*/
|
||||
loginPath?: string;
|
||||
/**
|
||||
@@ -50,10 +49,10 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
submit: RegisterEmits['submit'];
|
||||
submit: [Recordable<any>];
|
||||
}>();
|
||||
|
||||
const [Form, { validate }] = useVbenForm(
|
||||
const [Form, { validate, getValues }] = useVbenForm(
|
||||
reactive({
|
||||
commonConfig: {
|
||||
hideLabel: true,
|
||||
@@ -67,7 +66,8 @@ const [Form, { validate }] = useVbenForm(
|
||||
const router = useRouter();
|
||||
|
||||
async function handleSubmit() {
|
||||
const { valid, values } = await validate();
|
||||
const { valid } = await validate();
|
||||
const values = await getValues();
|
||||
if (valid) {
|
||||
emit('submit', values as { password: string; username: string });
|
||||
}
|
||||
|
@@ -67,30 +67,4 @@ interface AuthenticationProps {
|
||||
submitButtonText?: string;
|
||||
}
|
||||
|
||||
type LoginAndRegisterParams = Record<string, any>;
|
||||
|
||||
interface LoginCodeParams {
|
||||
code: string;
|
||||
phoneNumber: string;
|
||||
}
|
||||
|
||||
interface LoginEmits {
|
||||
submit: [LoginAndRegisterParams];
|
||||
}
|
||||
|
||||
interface LoginCodeEmits {
|
||||
submit: [LoginCodeParams];
|
||||
}
|
||||
|
||||
interface RegisterEmits {
|
||||
submit: [LoginAndRegisterParams];
|
||||
}
|
||||
|
||||
export type {
|
||||
AuthenticationProps,
|
||||
LoginAndRegisterParams,
|
||||
LoginCodeEmits,
|
||||
LoginCodeParams,
|
||||
LoginEmits,
|
||||
RegisterEmits,
|
||||
};
|
||||
export type { AuthenticationProps };
|
||||
|
@@ -1,4 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import type { Recordable } from '@vben/types';
|
||||
|
||||
import { computed, reactive } from 'vue';
|
||||
|
||||
import { $t } from '@vben/locales';
|
||||
@@ -11,14 +13,6 @@ interface Props {
|
||||
text?: string;
|
||||
}
|
||||
|
||||
interface LockAndRegisterParams {
|
||||
lockScreenPassword: string;
|
||||
}
|
||||
|
||||
interface RegisterEmits {
|
||||
submit: [LockAndRegisterParams];
|
||||
}
|
||||
|
||||
defineOptions({
|
||||
name: 'LockScreenModal',
|
||||
});
|
||||
@@ -29,10 +23,10 @@ withDefaults(defineProps<Props>(), {
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
submit: RegisterEmits['submit'];
|
||||
submit: [Recordable<any>];
|
||||
}>();
|
||||
|
||||
const [Form, { resetForm, validate }] = useVbenForm(
|
||||
const [Form, { resetForm, validate, getValues }] = useVbenForm(
|
||||
reactive({
|
||||
commonConfig: {
|
||||
hideLabel: true,
|
||||
@@ -68,7 +62,8 @@ const [Modal] = useVbenModal({
|
||||
});
|
||||
|
||||
async function handleSubmit() {
|
||||
const { valid, values } = await validate();
|
||||
const { valid } = await validate();
|
||||
const values = await getValues();
|
||||
if (valid) {
|
||||
emit('submit', values?.lockScreenPassword);
|
||||
}
|
||||
|
Reference in New Issue
Block a user