From 5999a862b688fc28ce846be9c1b2f3db7e2316c2 Mon Sep 17 00:00:00 2001 From: Vben Date: Mon, 4 Nov 2024 22:46:16 +0800 Subject: [PATCH] perf: expose the formApi for a login form (#4806) --- packages/@core/base/shared/package.json | 2 + .../src/ui/authentication/code-login.vue | 10 +- .../src/ui/authentication/forget-password.vue | 10 +- .../common-ui/src/ui/authentication/login.vue | 12 +- .../src/ui/authentication/register.vue | 10 +- .../plugins/src/vxe-table/use-vxe-grid.vue | 23 +- pnpm-lock.yaml | 817 ++++++++++++------ pnpm-workspace.yaml | 26 +- 8 files changed, 589 insertions(+), 321 deletions(-) diff --git a/packages/@core/base/shared/package.json b/packages/@core/base/shared/package.json index 747610b04f2..bc50b9dc110 100644 --- a/packages/@core/base/shared/package.json +++ b/packages/@core/base/shared/package.json @@ -81,10 +81,12 @@ "dependencies": { "@ctrl/tinycolor": "catalog:", "@tanstack/vue-store": "catalog:", + "@types/lodash.get": "catalog:", "@vue/shared": "catalog:", "clsx": "catalog:", "defu": "catalog:", "lodash.clonedeep": "catalog:", + "lodash.get": "catalog:", "nprogress": "catalog:", "tailwind-merge": "catalog:", "theme-colors": "catalog:" diff --git a/packages/effects/common-ui/src/ui/authentication/code-login.vue b/packages/effects/common-ui/src/ui/authentication/code-login.vue index cf950abdd0b..7de5dd3b438 100644 --- a/packages/effects/common-ui/src/ui/authentication/code-login.vue +++ b/packages/effects/common-ui/src/ui/authentication/code-login.vue @@ -53,7 +53,7 @@ const emit = defineEmits<{ const router = useRouter(); -const [Form, { validate, getValues }] = useVbenForm( +const [Form, formApi] = useVbenForm( reactive({ commonConfig: { hideLabel: true, @@ -65,8 +65,8 @@ const [Form, { validate, getValues }] = useVbenForm( ); async function handleSubmit() { - const { valid } = await validate(); - const values = await getValues(); + const { valid } = await formApi.validate(); + const values = await formApi.getValues(); if (valid) { emit('submit', { code: values?.code, @@ -78,6 +78,10 @@ async function handleSubmit() { function goToLogin() { router.push(props.loginPath); } + +defineExpose({ + getFormApi: () => formApi, +});