feat(editor): props 服务新增配置/值的批量获取与存在性判断方法

新增 getPropsConfigs、hasPropsConfig、getPropsValues、hasPropsValue 方法,便于外部按类型查询表单配置与初始值。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
roymondchen 2026-05-08 19:57:06 +08:00
parent a1f71f02d1
commit d8133629b4

View File

@ -93,6 +93,10 @@ class Props extends BaseService {
this.emit('props-configs-change');
}
public getPropsConfigs(): Record<string, FormConfig> {
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<string, Partial<MNode> | PropsFormValueFunction>) {
Object.keys(values).forEach((type: string) => {
this.setPropsValue(toLine(type), values[type]);
});
}
public getPropsValues(): Record<string, Partial<MNode>> {
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()}`;
}