From e3f6ef48e63d778e874588a22864d27ac95101d7 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Tue, 3 Dec 2024 14:52:48 +0800 Subject: [PATCH] =?UTF-8?q?feat(form):=20formState=E7=8E=B0=E5=9C=A8?= =?UTF-8?q?=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/form/src/Form.vue | 4 +++- packages/form/src/schema.ts | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/form/src/Form.vue b/packages/form/src/Form.vue index 24f1dfd8e..aae3f495c 100644 --- a/packages/form/src/Form.vue +++ b/packages/form/src/Form.vue @@ -31,7 +31,7 @@ import { provide, reactive, ref, shallowRef, toRaw, watch, watchEffect } from 'vue'; import { cloneDeep, isEqual } from 'lodash-es'; -import { TMagicForm } from '@tmagic/design'; +import { TMagicForm, tMagicMessage, tMagicMessageBox } from '@tmagic/design'; import Container from './containers/Container.vue'; import { getConfig } from './utils/config'; @@ -106,6 +106,8 @@ const formState: FormState = reactive({ setField: (prop: string, field: any) => fields.set(prop, field), getField: (prop: string) => fields.get(prop), deleteField: (prop: string) => fields.delete(prop), + $messageBox: tMagicMessageBox, + $message: tMagicMessage, post: (options: any) => { if (requestFuc) { return requestFuc({ diff --git a/packages/form/src/schema.ts b/packages/form/src/schema.ts index 70865b80b..0f454a307 100644 --- a/packages/form/src/schema.ts +++ b/packages/form/src/schema.ts @@ -16,6 +16,8 @@ * limitations under the License. */ +import type { TMagicMessage, TMagicMessageBox } from '@tmagic/design'; + export interface ValidateError { message: string; field: string; @@ -59,6 +61,8 @@ export type FormState = { setField: (prop: string, field: any) => void; getField: (prop: string) => any; deleteField: (prop: string) => any; + $messageBox: TMagicMessageBox; + $message: TMagicMessage; [key: string]: any; };