From b1aee77d103669e5099fd3335d249307a3799a43 Mon Sep 17 00:00:00 2001 From: chenos Date: Sun, 6 Mar 2022 20:38:02 +0800 Subject: [PATCH] feat: improve tab schema designer --- .../antd/tabs/Tabs.Designer.tsx | 48 ++++++++++++++----- .../Initializers/TabPaneInitializers.tsx | 10 ++-- 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/packages/client/src/schema-component/antd/tabs/Tabs.Designer.tsx b/packages/client/src/schema-component/antd/tabs/Tabs.Designer.tsx index 65d741247..289d4ccb8 100644 --- a/packages/client/src/schema-component/antd/tabs/Tabs.Designer.tsx +++ b/packages/client/src/schema-component/antd/tabs/Tabs.Designer.tsx @@ -1,23 +1,47 @@ -import { useField } from '@formily/react'; +import { ISchema, useField, useFieldSchema } from '@formily/react'; import React from 'react'; +import { useTranslation } from 'react-i18next'; +import { useDesignable } from '../..'; import { GeneralSchemaDesigner, SchemaSettings } from '../../../'; export const TabsDesigner = () => { const field = useField(); + const fieldSchema = useFieldSchema(); + const { dn } = useDesignable(); + const { t } = useTranslation(); return ( - { + if (title) { + fieldSchema.title = title; + field.title = title; + dn.emit('patch', { + schema: { + ['x-uid']: fieldSchema['x-uid'], + title, + }, + }); + dn.refresh(); + } }} - > - 编辑 - + /> diff --git a/packages/client/src/schema-initializer/Initializers/TabPaneInitializers.tsx b/packages/client/src/schema-initializer/Initializers/TabPaneInitializers.tsx index a7ae9c1f1..2c8889b84 100644 --- a/packages/client/src/schema-initializer/Initializers/TabPaneInitializers.tsx +++ b/packages/client/src/schema-initializer/Initializers/TabPaneInitializers.tsx @@ -49,16 +49,16 @@ export const TabPaneInitializers = () => { }, type: 'dashed', }, - title: '添加标签页', + title: '{{t("Add tab")}}', properties: { drawer1: { 'x-decorator': 'Form', 'x-component': 'Action.Modal', type: 'void', - title: 'Drawer Title', + title: '{{t("Add tab")}}', properties: { title: { - title: '标题', + title: '{{t("Tab name")}}', required: true, 'x-component': 'Input', 'x-decorator': 'FormItem', @@ -68,7 +68,7 @@ export const TabPaneInitializers = () => { type: 'void', properties: { cancel: { - title: 'Cancel', + title: '{{t("Cancel")}}', 'x-component': 'Action', 'x-component-props': { useAction: () => { @@ -82,7 +82,7 @@ export const TabPaneInitializers = () => { }, }, submit: { - title: 'Submit', + title: '{{t("Submit")}}', 'x-component': 'Action', 'x-component-props': { type: 'primary',