优化创建控件API,引入转换器插件

This commit is contained in:
猴赛雷 2024-04-29 13:57:29 +08:00
parent 3e0843ed74
commit c272632ec9
2 changed files with 66 additions and 60 deletions

View File

@ -110,25 +110,27 @@ export default defineComponent({
"ruler": true,
"background": {color:"#123456",opacity:0.1},
// "theme": "ddei-core-theme-black",
controls: [
{
id: "act_1",
model: "102010",
code: "active_01",
text: "第一步",
border:{color:"yellow",dash:[10,10,5,5],width:5},
fill:{color:"grey"},
},
{
id: "act_2",
model: "102010",
code: "active_02",
width: 200,
height: 100,
text: "第二步",
y: -70,
}
]
initData: {
controls:[
{
id: "act_1",
model: "102010",
code: "active_01",
text: "第一步",
border:{color:"yellow",dash:[10,10,5,5],width:5},
fill:{color:"grey"},
},
{
id: "act_2",
model: "102010",
code: "active_02",
width: 200,
height: 100,
text: "第二步",
y: -70,
}
]
}
},
//
extensions: [
@ -144,24 +146,26 @@ export default defineComponent({
access:{"DEL":false},
"paper":"A5",
"ruler": true,
controls: [
{
id: "act_1",
model: "102010",
code: "active_01",
text: "第一步",
y: 70,
},
{
id: "act_2",
model: "102010",
code: "active_02",
width: 200,
height: 100,
text: "第二步",
y: -70,
}
]
initData: {
controls: [
{
id: "act_1",
model: "102010",
code: "active_01",
text: "第一步",
y: 70,
},
{
id: "act_2",
model: "102010",
code: "active_02",
width: 200,
height: 100,
text: "第二步",
y: -70,
}
]
}
},
//
extensions: [
@ -183,24 +187,26 @@ export default defineComponent({
EXT_STAGE_HEIGHT:false,
ruler:0,
grid: 0,
controls: [
{
id: "rect_1",
model: "102010",
code: "active_01",
width: 200,
height: 100,
text: "第一步"
},
{
id: "rect_2",
model: "102010",
code: "active_02",
width: 200,
height: 100,
text: "第二步"
}
]
initData: {
controls: [
{
id: "rect_1",
model: "102010",
code: "active_01",
width: 200,
height: 100,
text: "第一步"
},
{
id: "rect_2",
model: "102010",
code: "active_02",
width: 200,
height: 100,
text: "第二步"
}
]
}
},
//
extensions: [

View File

@ -100,15 +100,15 @@ export default {
DDeiEditorUtil.getControlIcons(this.editor);
//
if(this.options?.config?.controls){
if(this.options?.config?.initData){
//
let controls = this.options?.config?.controls;
let converters = this.editor.getEnabledConverters(controls, 1);
let initData = this.options?.config?.initData
let converters = this.editor.getEnabledConverters(initData, 1);
//converters
converters?.forEach(converter => {
controls = converter.input(controls)
initData = converter.input(initData)
});
this.editor.addControls(controls)
this.editor.addControls(initData.controls)
}
if (this.options?.config?.access){
this.editor.setAccessInfo(this.options?.config?.access)