1.1.1 • Published 8 months ago
@bpromote/elpis-dsl v1.1.1
@bpromote/elpis-dsl
简介
@bpromote/elpis-dsl 是一个全栈实现的企业级应用框架,通过结合 JSON - Schema 提供了强大的 DSL(领域特定语言)配置能力,能够帮助开发者快速搭建和定制企业级应用。通过灵活的配置和扩展机制,开发者可以根据不同的业务需求轻松定制页面、菜单、数据结构等。
DSL 配置
整体结构
DSL 配置是框架的核心,用于定义应用的各个方面,包括模板类型、菜单、数据结构等。以下是一个完整的 DSL 配置示例:
{
"mode": "dashboard",
"name": "",
"desc": "",
"icon": "",
"homePage": "",
"menu": [
{
"key": "",
"name": "",
"menuType": "",
"subMenu": [
{
// 可递归的菜单项
}
],
"moduleType": "",
"siderConfig": {
"menu": [
{
// 可递归的菜单项(除 moduleType === sider)
}
]
},
"iframeConfig": {
"path": ""
},
"customConfig": {
"path": ""
},
"schemaConfig": {
"api": "",
"schema": {
"type": "object",
"properties": {
"key": {
"type": "",
"label": "",
"tableOption": {
"toFixed": 0,
"visible": true
},
"searchOption": {
"comType": "",
"default": "",
"enumList": [],
"api": ""
},
"createFormOption": {
"comType": "",
"visible": true,
"disabled": false,
"enumList": []
},
"editFormOption": {
"comType": "",
"visible": true,
"disabled": false,
"default": "",
"enumList": []
},
"detailPanelOption": {
"comType": "",
"disabled": false,
"default": "",
"enumList": []
}
}
},
"required": []
},
"tableConfig": {
"headerButtons": [
{
"label": "",
"eventKey": "",
"eventOption": {
"comName": ""
}
}
],
"rowButtons": [
{
"label": "",
"eventKey": "",
"eventOption": {
"params": {
"paramKey": "rowValueKey"
}
}
}
]
},
"searchConfig": {},
"componentConfig": {
"createForm": {
"title": "",
"saveBtnText": ""
},
"editForm": {
"mainKey": "",
"title": "",
"saveBtnText": ""
},
"detailPanel": {
"mainKey": "",
"title": ""
}
}
}
}
]
}配置项详细说明
mode:模板类型,不同的类型会渲染不同的页面,例如dashboard类型可能会渲染仪表盘页面。name:模板的名称,方便识别和管理。desc:模板的描述信息,用于记录模板的用途和特点。icon:模板对应的图标,可用于界面展示。homePage:应用的首页地址。menu:头部菜单的配置数组,每个菜单项包含以下属性:key:菜单的唯一标识,用于区分不同的菜单项。name:菜单的显示名称。menuType:菜单类型,可选值为group/module等等 。- 当
menuType为group时,可配置subMenu数组,用于创建子菜单。 - 当
menuType为module时,可配置moduleType,其可选值为iframe、custom、schema、sider等等...siderConfig:当moduleType为sider时,配置侧边栏菜单。iframeConfig:当moduleType为iframe时,配置 iframe 的地址。customConfig:当moduleType为custom时,配置自定义路径。schemaConfig:当moduleType为schema时,配置数据结构、表格、搜索栏和动态组件等。api:数据源 API,需遵循 RESTful 规范。schema:板块的数据结构,包含字段的类型、标签、表格和搜索栏的配置等。tableConfig:表格的配置,包括表头按钮和行按钮。searchConfig:搜索栏的配置。componentConfig:动态组件的配置,如创建表单、编辑表单和详情面板等。
- 当
服务端启动
要启动 elpis-dsl 服务,可使用以下代码:
const { serverStart } = require("@bpromote/elpis-dsl");
// 启动 elpis-dsl 服务
const app = serverStart({});这段代码从 @bpromote/elpis-dsl 模块中引入 serverStart 函数,并调用该函数启动服务。
自定义服务端
你可以从以下几个方面对服务端进行自定义扩展:
router-schemaroutercontrollerserviceextendconfigmiddleware
前端构建
使用以下代码编译构建前端工程:
const { frontendBuild } = require("@bpromote/elpis-dsl");
// 编译构建前端工程
frontendBuild(process.env._ENV);注意事项
前端扩展
自定义页面扩展
若要进行自定义页面扩展,可在 app/pages 目录下编写入口文件 entry.xxx.js。
dashboard / custom-view 自定义页面扩展
对于 dashboard 或 custom-view 的自定义页面扩展,可在 app/pages/dashboard/xxx 目录下编写页面代码。
dashboard / schema-view / components 动态组件扩展
- 在
app/pages/dashboard/schema-view/components目录下编写组件代码。 - 将组件配置到
app/pages/dashboard/schema-view/components/component-config.js文件中。
schema-form 控件扩展
- 在
app/widgets/schema-form/complex-view目录下编写控件代码。 - 将控件配置到
app/widgets/schema-form/form-item-config.js文件中。
schema-search-bar 控件扩展
- 在
app/widgets/schema-search-bar/complex-view目录下编写控件代码。 - 将控件配置到
app/widgets/schema-search-bar/search-item-config.js文件中。
通过以上的配置和扩展方式,你可以充分发挥 @bpromote/elpis-dsl 框架的优势,快速搭建和定制符合企业需求的应用。