@chanxxxx/elpis
v1.0.0
Published
一个基于 Vue 3 + Koa.js 的企业级全栈应用框架,支持 DSL 驱动的动态组件开发。
Readme
Elpis
一个基于 Vue 3 + Koa.js 的企业级全栈应用框架,支持 DSL 驱动的动态组件开发。
核心特性
- Schema 驱动开发 - 通过 JSON Schema 配置动态生成表单、表格、搜索栏等组件
- 动态组件系统 - 支持 createForm、editForm、detailPanel 等动态组件
- 模块化架构 - elpis-core 核心框架 + 业务层分离设计
项目结构
elpis/
├── elpis-core/ # 核心框架
├── app/ # 应用业务代码
│ ├── controller/ # 控制器
│ ├── service/ # 服务层
│ ├── middleware/ # 中间件
│ ├── router/ # 路由配置
│ ├── router-schema/ # 路由 Schema 定义
│ ├── pages/ # 前端页面
│ ├── widgets/ # UI 组件
│ └── webpack/ # 构建配置
├── config/ # 环境配置
├── model/ # 数据模型
├── docs/ # 项目文档
└── test/ # 测试文件model 配置
{
mode: "dashboard", // 模版类型,不同模版类型对应不一样的模版数据结构
name: "", // 名称
desc: "", // 描述
icon: "", // 图标
homePage: "", // 首页(项目配置)
// 头部菜单
menu: [
{
key: "", // 菜单唯一描述
name: "", // 菜单名称
menuType: "", // 枚举值,group /module
// 当 menuType === group 时,才可填写
subMenu: [
{
// 可递归 menuItem
},
],
// 当 menuType === module 时,才可填写(点击之后可跳转)
moduleType: "", // 枚举值,iframe/custom/schema /sider
// 当 moduleType === sider 时,(侧边栏)
siderConfig: {
menu: [
{
// 可递归 menuItem(除 moduleType === sider)
},
],
},
// 当 moduleType === iframe 时
iframeConfig: {
path: "", // iframe 路径
},
// 当 moduleType === custom 时
customConfig: {
path: "", // 自定义组件路径
},
// 当 moduleType === schema 时
schemaConfig: {
api: "/api/user", // 数据源api (遵循 RESTFUL 规范)
schema: {
// 板块数据结构
type: "object",
properties: {
key: {
...schema, // 标准 schema 配置
label: "", // 字段的中文名
type: "", // 字段类型
// 字段在table中的相关配置
tableOption: {
...elTableColumnConfig, // 标准 el-table-column 配置
toFixed: 0, // 保留小数点后几位(演示)
visible: true | false, // 默认为 true(false 时,表示不在表单中显示)
},
// 字段在 search-bar 中的相关配置
searchOption: {
...elComponentConfig, // 标准 el-component-column 配置
comType: "", // 配置组件类型 input/select/...
default: "", // 默认值(例如默认搜索时间的值)
// 当 comType === select 时
enumList: [],
// 当 comType === dynamicSelect 时
api: "",
},
formOption: {},
// 字段在不同动态 component 中的相关配置,前缀对应 componentConfig 中的键值
// 如:componentConfig.createForm ,这里对应 createFormOption
// 字段在 createForm 中相关配置
createFormOption: {
...elComponentConfig, // 标准 el-component-column 配置
comType: "", // 配置控件类型 input/select/...
visible: true, // 默认为 true(false 时,表示不在表单中显示)
disabled: false, // 是否禁用 (true/false)默认为 false
default: "", // 默认值
// 当 comType === select 时 生效
enumList: [], // 枚举列表
},
// 字段在 editForm 中的相关配置
editFormOption: {
...elComponentConfig, // 标准 el-component-column 配置
comType: "", // 配置控件类型 input/select/...
visible: true, // 默认为 true(false 时,表示不在表单中显示)
disabled: false, // 是否禁用 (true/false)默认为 false
default: "", // 默认值
// 当 comType === select 时 生效
enumList: [], // 枚举列表
},
detailPanelOption: {
visible: true, // 默认为 true(false 时,表示不在表单中显示)
...eleComponentConfig, // 标准 el-component-column 配置
},
},
}, // 字段属性,可递归
// 必填字段
required: [], // 标记那些字段是必填字段
},
// 表格配置
tableConfig: {
headerButtons: [
{
label: "", // 按钮中文名
eventKey: "", // 按钮事件名
// 按钮事件具体配置 例如:调起不同的动态组件等
eventOption: {
// 当 eventKey === 'showComponent' 时生效
comName: "", // 组件名称
},
...elButtonConfig, // 标准 el-button 配置
},
],
rowButtons: [
{
label: "", // 按钮中文名
eventKey: "", // 按钮事件名
eventOption: {
// 当 eventKey === 'showComponent' 时生效
comName: "", // 组件名称
// 当 eventKey === remove 时(举例)
params: {
// paramKey = 参数的键值 (e.g. ueserId:rowValueKey)
// rowValueKey = 参数值 (当格式为 schema::tableKey 的时候,到 table 中找到相应的字段)这里的动态的值
// 例子:user_id: schema::user_id
paramKey: rowValueKey,
},
}, // 按钮事件具体配置
...elButtonConfig, // 标准 el-button 配置
},
],
},
// search-bar搜索配置
searchConfig: {},
// 动态组件 相关配置
componentConfig: {
// create-form 表单相关配置
createForm: {
title: "", // 表单标题
saveBtnText: "", // 保存按钮文字
},
// edit-form 表单相关配置
editForm: {
title: "", // 表单标题
saveBtnText: "", // 保存按钮文字
mainKey: "", // 表单主键, 用于唯一标识要修改的数据对象
},
// detail-panel 相关配置
detailPanel: {
mainKey: "",
title: "", // 表单标题
},
// ...支持用户动态拓展
},
},
},
],
}服务端启动
const {serverStart} = require(@chanxxxx/elpis);
// 启动 elpis服务
const app = serverStart({})自定义服务端
- router-schema
- router
- controller
- service
- extend
- config
前端构建
const {frontendBuild} = require(@chanxxxx/elpis);
// 编译构架按前端工程
frrontendBuild(process.env._ENV)
自定义页面扩展
- 在
app/pages/目录下写入口 entry.xxx.js
dashboard / custom-view 自定义页面扩展
- 在
app/pages/dashboard/xxx下写页面
ddashboard / schema-view / components 动态子组件扩展
- 在
app/pages/dashboard/complex-view/schema-view/components/下写组件 - 配置到
app/pages/dashboard/complex-view/schema-view/components/component-config.js
schema-form 控件扩展
- 在
app/pages/widgets/schema-form/complex-view下写控件 - 配置到
app/pages/widgets/schema-form/form-item-config.js
schema-search-bar 控件扩展
- 在
app/pages/widgets/schema-search-bar/complex-view下写控件 - 配置到
app/pages/widgets/schema-search-bar/search-item-config.js
