feat(editor): 组件默认的名称,id配置只要在业务不提供时才加入

This commit is contained in:
roymondchen 2025-04-28 20:14:01 +08:00
parent e5bcd762b2
commit 2dc0bbc679

View File

@ -156,22 +156,21 @@ export const displayTabConfig: TabPaneConfig = {
* @param config * @param config
* @returns Object * @returns Object
*/ */
export const fillConfig = (config: FormConfig = [], labelWidth = '80px'): FormConfig => [ export const fillConfig = (config: FormConfig = [], labelWidth = '80px'): FormConfig => {
{ const propsConfig: FormConfig = [];
type: 'tab',
labelWidth,
items: [
{
title: '属性',
items: [
// 组件类型,必须要有 // 组件类型,必须要有
{ if (!config.find((item) => item.name === 'type')) {
propsConfig.push({
text: 'type', text: 'type',
name: 'type', name: 'type',
type: 'hidden', type: 'hidden',
}, });
}
if (!config.find((item) => item.name === 'id')) {
// 组件id必须要有 // 组件id必须要有
{ propsConfig.push({
name: 'id', name: 'id',
text: 'ID', text: 'ID',
type: 'text', type: 'text',
@ -190,13 +189,24 @@ export const fillConfig = (config: FormConfig = [], labelWidth = '80px'): FormCo
}); });
}, },
}, },
}, });
{ }
if (!config.find((item) => item.name === 'name')) {
propsConfig.push({
name: 'name', name: 'name',
text: '组件名称', text: '组件名称',
}, });
...config, }
],
return [
{
type: 'tab',
labelWidth,
items: [
{
title: '属性',
items: [...propsConfig, ...config],
}, },
{ ...styleTabConfig }, { ...styleTabConfig },
{ ...eventTabConfig }, { ...eventTabConfig },
@ -205,3 +215,4 @@ export const fillConfig = (config: FormConfig = [], labelWidth = '80px'): FormCo
], ],
}, },
]; ];
};