From 31029bc8f1178e3eb1450c779253ed17bcc93bf0 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Tue, 23 Aug 2022 20:32:48 +0800 Subject: [PATCH] =?UTF-8?q?feat(editor):=20propsService=E6=B7=BB=E5=8A=A0f?= =?UTF-8?q?illConfig=E6=96=B9=E6=B3=95=EF=BC=8C=E6=94=AF=E6=8C=81=E6=89=A9?= =?UTF-8?q?=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/editor/src/services/props.ts | 13 +++++++++---- packages/editor/src/utils/props.ts | 3 --- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/editor/src/services/props.ts b/packages/editor/src/services/props.ts index 81aa1d40..57fd3923 100644 --- a/packages/editor/src/services/props.ts +++ b/packages/editor/src/services/props.ts @@ -24,7 +24,7 @@ import type { MComponent, MNode } from '@tmagic/schema'; import { toLine } from '@tmagic/utils'; import type { PropsState } from '../type'; -import { DEFAULT_CONFIG, fillConfig } from '../utils/props'; +import { fillConfig } from '../utils/props'; import BaseService from './BaseService'; @@ -42,6 +42,7 @@ class Props extends BaseService { 'getPropsValue', 'createId', 'setNewItemId', + 'fillConfig', 'getDefaultPropsValue', ]); } @@ -53,13 +54,17 @@ class Props extends BaseService { this.emit('props-configs-change'); } + public async fillConfig(config: FormConfig) { + return fillConfig(config); + } + /** * 为指定类型组件设置组件属性表单配置 * @param type 组件类型 * @param config 组件属性表单配置 */ - public setPropsConfig(type: string, config: FormConfig) { - this.state.propsConfigMap[type] = fillConfig(Array.isArray(config) ? config : [config]); + public async setPropsConfig(type: string, config: FormConfig) { + this.state.propsConfigMap[type] = await this.fillConfig(Array.isArray(config) ? config : [config]); } /** @@ -72,7 +77,7 @@ class Props extends BaseService { return await this.getPropsConfig('button'); } - return cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG); + return cloneDeep(this.state.propsConfigMap[type] || this.fillConfig([])); } public setPropsValues(values: Record) { diff --git a/packages/editor/src/utils/props.ts b/packages/editor/src/utils/props.ts index 162d1838..20282964 100644 --- a/packages/editor/src/utils/props.ts +++ b/packages/editor/src/utils/props.ts @@ -234,6 +234,3 @@ export const fillConfig = (config: FormConfig = []) => [ ], }, ]; - -// 默认组件属性表单配置 -export const DEFAULT_CONFIG: FormConfig = fillConfig([]);