1.0.1 • Published 5 months ago
@huanglf/elpis v1.0.1
实现 Elpis 全栈全流程支持多应用建设的平台
model 配置
{
// 模板类型,不同模板类型对应不一样的模板数据结构
mode: "dashboard";
// 应用名称
name: "";
// 应用描述
desc: "";
// 应用icon
icon: "";
// 应用首页(项目配置)
homePage: "";
// 头部菜单
menu: [{
// 菜单key, 唯一的标识
key: "",
// 菜单名称, ...: 表示菜单项的配置,可以有多个
name: "",
// 菜单类型,枚举值:group(菜单组) / module(模块/菜单)
menuType: "",
// menuType === "group" 的配置, ...: 表示菜单项的配置,可以有多个
subMenu: [{
// 可递归的 menuItem
}, ... ],
// menuType === "module" 的配置
// 模块类型,枚举值:sider(侧边栏)/iframe(第三方嵌入)/custom(自定义)/schema(通用模板配置的页面)
moduleType: '',
// moduleType === "sider" 时的配置
siderConfig: {
menu: [{
// 除了 moduleType === "sider" 之外可递归的 menuItem
}, ...]
},
// moduleType === "iframe" 时的配置
iframeConfig: {
// iframe 路径
path: "",
},
// moduleType === "custom" 时的配置
customConfig: {
// 自定义页面路径
path: ""
},
// moduleType === "schema" 时的配置
schemaConfig: {
// 获取配置的路径,遵循 RESTFUL 规范
api: "",
// 模块的数据结构
schema: {
type: "object",
properties: {
key: {
// 标准的 schema 配置,
...schema,
// 字段类型
type: "",
// 字段名称
label: "" ,
// 字段在 table 中的相关配置
tableOption: {
// 标准的 el-table 配置
...elTableColumnConfig,
// 保留两位小数
toFixed: 2,
// 控制该属性是否显示, 默认为 true
visible: true
},
// 字段在 search-bar 相关配置
searchOption: {
// 标准的 el-component-column 配置
...elComponentConfig,
// 配置组件的类型
comType: "",
// 默认值
default: "",
// 当 comType === "select" 时的配置
enumList: [],
// 当 comType === "dynamicSelect" 时的配置
api: '',
},
// 字段在不同 component 中的相关配置,前缀对应 componentConfig 中的 key
// 如:componentConfig.createForm 对应 这里的 createFormOption
// 字段在 createForm 中的相关配置
createFormOption: {
// 标准的 el-component 相关配置
...elComponentConfig,
// 控件类型,如:input, select, dynamicSelect, datePicker, ...
comType: "",
// 是否展示该字段,默认为 true
visible: true,
// 默认值
default: "",
// 当 comType === "select" 时的配置
// 枚举列表
enumList: [],
// 当 comType === "dynamicSelect" 时的配置
api: ""
},
editFormOption: {
// 标准的 el-component 相关配置
...elComponentConfig,
// 控件类型,如:input, select, dynamicSelect, datePicker, ...
comType: "",
// 是否展示该字段,默认为 true
visible: true,
// 默认值
default: "",
// 当 comType === "select" 时的配置
enumList: [],
// 当 comType === "dynamicSelect" 时的配置
api: ""
},
detailPanelOption: {
// 标准的 el-component 相关配置
...elComponentConfig,
}
},
...
},
// 标记哪些字段在表单必填
required: [],
// table 相关配置
tableConfig: {
// 页面全局按钮
headerButtons: [{
// 标准的 el-button 配置
...elButtonConfig,
// 按钮中文名
label: "",
// 按钮事件名
eventKey: "",
// 按钮事件具体配置
eventOption: {
// 当 eventKey === showComponent 时的配置
// 组件名称
comName: ""
},
// 控制该属性是否显示, 默认为 true
visible: true
}, ...],
// 行按钮
rowButtons: [{
// 标准的 el-button 配置
...elButtonConfig,
// 按钮中文名
label: "",
// 按钮事件名
eventKey: "",
// 按钮事件具体配置
eventOption: {
// 当 eventKey === showComponent 时的配置
// 组件名称
comName: "",
// 当 eventKey === remove 时的配置
params: {
// paramKey: 删除的数据的键值
// rowValueKey: 删除的数据的值 rowValueKey的值为 schema::tableKey 时,到 table中找到对应的 tableKey 值
paramKey: rowValueKey
}
},
// 控制该属性是否显示, 默认为 true
visible: true
}, ...]
},
// search 相关配置
searchConfig: {},
// 动态组件 相关配置
componentConfig: {
// create-form 表单相关配置
createForm: {
// 表单标题
title: "",
// 保存按钮文案
saveBtnText: ""
},
// edit-form 表单的相关配置
editForm: {
// 表单主键, 用于表示修改哪一个数据
mainKey: "",
// 表单表标题
title: "",
// 保存按钮文案
saveBtnText: ""
},
// detail-panel 相关配置
detailPanel: {
// 行数据主键,用于表示展示哪个数据的详情
mainKey: "",
// 详情页标题
title: "",
}
}
// ...支持用户动态拓展
}
}
}, ...];
};
服务端启动
const { serverStart } = require("@huanglf/elpis");
// 启动 elpis 服务
const app = serverStart({
name: "ElpisDemo",
homePage: "/view/project-list"
// homePage: "/view/dashboard/schema?proj_key=pdd&key=product"
});
自定义服务端配置
- config
- extend
- router-schema
- controller
- service
- router
前端构建
const { frontEndBuild } = require("@huanglf/elpis");
// 编译构建前端工程
frontEndBuild(process.env._ENV);
自定义页面拓展配置
- 在
app/pages/
目录下写入口entry.xxx.js
dashboard / custom-view 自定义页面拓展配置
- 在
app/pages/dashboard/xxx
下写页面
dashboard / schema-view /components 自定义页面拓展配置
- 在
app/pages/dashboard/complex-view/schema-view/components/xxx
下写组件 - 在
app/pages/dashboard/complex-view/schema-view/component-config.js
下写组件的配置
widgets / schema-view 自定义页面拓展配置
- 在
app/pages/widgets/schema-form/complex-view/xxxx
下写控件 - 在
app/pages/widgets/schema-view/form-item-config.js
下写控件的配置
widgets / schema-search-bar 自定义页面拓展配置
- 在
app/pages/widgets/schema-search-bar/complex-view/xxxx
下写控件 - 在
app/pages/widgets/schema-search-bar/schema-search-item-config.js
下写控件的配置