From b1f5dba3ee08423a7e447901af2cac7ea6ae218b Mon Sep 17 00:00:00 2001 From: lvxiaojiao Date: Mon, 26 Jun 2023 12:57:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:dataschema=E5=A2=9E=E5=8A=A0typeLabel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-core/src/types.ts | 1 + packages/amis-core/src/utils/DataScope.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/amis-core/src/types.ts b/packages/amis-core/src/types.ts index c47c34502..d287b85a4 100644 --- a/packages/amis-core/src/types.ts +++ b/packages/amis-core/src/types.ts @@ -382,6 +382,7 @@ export type FunctionPropertyNames = { export type JSONSchema = JSONSchema7 & { group?: string; // 分组 + typeLabel?: string; // 类型说明 }; // export type Omit = Pick>; diff --git a/packages/amis-core/src/utils/DataScope.ts b/packages/amis-core/src/utils/DataScope.ts index 130d3c107..8f4618f38 100644 --- a/packages/amis-core/src/utils/DataScope.ts +++ b/packages/amis-core/src/utils/DataScope.ts @@ -1,6 +1,15 @@ import {JSONSchema} from '../types'; import {guid, keyToPath, mapTree} from './helper'; +const TYPE_MAP: {[type: string]: string} = { + boolean: '布尔', + integer: '整数', + number: '数字', + string: '文本', + array: '数组', + object: '对象' +}; + export class DataScope { // 指向父级 parent?: DataScope; @@ -213,7 +222,7 @@ export class DataScope { value: schema.title === '成员' ? '' : path.value, path: schema.title === '成员' ? '' : path.label, type: schema.type, - tag: schema.type, + tag: schema.typeLabel ?? TYPE_MAP[schema.type as string] ?? schema.type, description: schema.description, isMember, disabled: schema.title === '成员'