From d8133629b4887d31e12f4f91ee328a828f3b85bc Mon Sep 17 00:00:00 2001 From: roymondchen Date: Fri, 8 May 2026 19:57:06 +0800 Subject: [PATCH] =?UTF-8?q?feat(editor):=20props=20=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=85=8D=E7=BD=AE/=E5=80=BC=E7=9A=84?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E8=8E=B7=E5=8F=96=E4=B8=8E=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E6=80=A7=E5=88=A4=E6=96=AD=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增 getPropsConfigs、hasPropsConfig、getPropsValues、hasPropsValue 方法,便于外部按类型查询表单配置与初始值。 Co-authored-by: Cursor --- packages/editor/src/services/props.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/editor/src/services/props.ts b/packages/editor/src/services/props.ts index 3da07905..664640f0 100644 --- a/packages/editor/src/services/props.ts +++ b/packages/editor/src/services/props.ts @@ -93,6 +93,10 @@ class Props extends BaseService { this.emit('props-configs-change'); } + public getPropsConfigs(): Record { + return this.state.propsConfigMap; + } + public async fillConfig(config: FormConfig, labelWidth?: string) { return fillConfig(config, { labelWidth: typeof labelWidth !== 'function' ? labelWidth : '80px', @@ -125,12 +129,20 @@ class Props extends BaseService { return cloneDeep(this.state.propsConfigMap[toLine(type)] || (await this.fillConfig([]))); } + public hasPropsConfig(type: string): boolean { + return !!this.state.propsConfigMap[toLine(type)]; + } + public setPropsValues(values: Record | PropsFormValueFunction>) { Object.keys(values).forEach((type: string) => { this.setPropsValue(toLine(type), values[type]); }); } + public getPropsValues(): Record> { + return this.state.propsValueMap; + } + /** * 为指点类型组件设置组件初始值 * @param type 组件类型 @@ -178,6 +190,10 @@ class Props extends BaseService { }; } + public hasPropsValue(type: string): boolean { + return !!this.state.propsValueMap[toLine(type)]; + } + public createId(type: string | number): string { return `${type}_${guid()}`; }