1.0.0 • Published 8 months ago

@hemushanpi/elpis v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

#elpis

一个企业级全栈应用框架

开发环境

node 18.19.0

model配置

{
	mode: 'dashboard', // 模板类型,不同模板类型对应不一样的模板数据结构
	name: '', // 名称
	desc: '', // 描述
	icon: '', // 图标
	homePage: '', // 首页
	menu: [
		{
			key: '', // 菜单唯一标识
			name: '', // 菜单名称
			menuType: '', // 枚举值: group / module
			subMenu: [
				{
					// 可递归menuItem
				}
			],
			// 当menuType为module时
			moduleType: '', // 枚举值: sider / iframe / custom / schema

			// 当menuType为sider时
			siderConfig: {
				menu: [{
					// 可递归menuItem(除 moduleType为sider的)
				}]
			},

			// 当menuType为iframe时
			iframeConfig: {
				path: '', // iframe路径
			},

			// 当menuType为custom时
			customConfig: {
				path: '', // 自定义路由路径
			},

			// 当menuType为schema时
			schemaConfig: {
				api: '', // 数据源API(遵循 RESTFUL 规范)
				schema: { // 板块数据结构
					type: 'object',
					properties: {
						key: {
							...schema,
							type: '', // 字段类型
							label: '', // 字段的中文名
							// 字段在table的相关配置
							tableOption: {
								...elTableColumnConfig, // 标准el-table-column配置
								toFixed: 0, // 保留小数点后几位
								visible: true, // 默认为true (false则表示不在表格中显示)
							},
							// 字段在search-bar中的相关配置
							searchOption: {
								...elComponentConfig, // 标准el-component-column配置
								comType: '', // 配置组件类型 input / select / date-picker / cascader / ...
								default: '', // 默认值
								// 当comType为select时,可配置选项列表
								enumList: [], // 下拉框选项列表
								// 当comType为dynamicSelect时,可配置获取选项列表的接口地址
								api: '', // 动态选择器的选项接口地址
							},
							// 字段在不同动态component中的相关配置,前缀对应componentConnfig中的键值
							// 如 componentConfig.createForm,这里对应createFormOption
							// 字段在createForm中相关配置
							createFormOption: {
								...elComponentConfig, // 标准el-component配置
								comType: '', // 配置组件类型 input / select / date-picker / cascader / ...
								visible: true, // 默认为true (false则表示不在表单中显示)
								disable: false, // 默认为false (true则表示禁用)
								default: '', // 默认值
								// comType为select时,可配置选项列表
								enumList: [], // 下拉框选项列表
							},
							// 字段在editForm中相关配置
							editFormOption: {
								...elComponentConfig, // 标准el-component配置
								comType: '', // 配置组件类型 input / select / date-picker / cascader / ...
								visible: true, // 默认为true (false则表示不在表单中显示)
								disable: false, // 默认为false (true则表示禁用)
								default: '', // 默认值
								// comType为select时,可配置选项列表
								enumList: [], // 下拉框选项列表
							}
							,
							// 字段在detailPanel中相关配置
							detailPanelOption: {
								...elComponentConfig, // 标准el-component配置
							}
						}
					},
					required: [], // 必填字段列表
				},
				tableConfig: {
					headerButtons: [{
						label: '', // 按钮名称
						eventKey: '', // 按钮事件名
						// 按钮事件具体配置
						eventOption: {
							// 当eventKey==='showComponent'
							comName: '', // 组件名称
						},
						...elButtonConfig // 标准el-button配置
					}], // 表头按钮
					rowButtons: [{
						label: '', // 按钮名称
						eventKey: '', // 按钮事件名
						eventOption: {
							// 当eventKey==='showComponent'
							comName: '', // 组件名称
							// 当eventKey==='remove'
							params: {
								// paramKey = 参数的键值
								// rowValueKey=参数值,格式为schema::tableKey,到table中找到相应字段
								paramKey: rowValueKey
							}
						}, // 按钮具体配置
						...elButtonConfig // 标准el-button配置
					}], // 行按钮
				}, // table相关配置
				searchConfig: {}, // search-bar相关配置
				// 动态组件相关配置
				componentConfig: {
					// create-form 表单相关配置
					createForm: {
						title: '', // 表单标题
						saveBtnText: '', // 保存按钮文字
					},
					editForm: {
						mainKey: '', // 表单组件,用于唯一标识要修改的数据对象
						title: '', // 表单标题
						saveBtnText: '', // 保存按钮文字
					},
					detailPanel: {
						mainKey: '', // 详情组件,用于唯一标识
						title: '', // 表单标题
					}
					// 支持用户动态拓展
				}
			},
		}
	]
}

服务端启动

const { serverStart } = require('@hemushanpi/elpis')

const app = serverStart({})

自定义服务端

  • router-schema
  • router
  • controller
  • service
  • extend
  • config

前端构建

const {frontendBuild} = require('@hemushanpi/elpis');
frontendBuild(process.env._ENV); 

自定义页面扩展

  • app/pages/ 目录下写入口 entry.xxx.js

dashboard/custom-view 自定义页面扩展

  • app/pages/dashboard/xxx 目录下写自定义页面

dashboard/schema-view/components 动态组件扩展

  1. app/pages/dashboard/complex-view/schema-view/components 目录下写组件
  2. app/pages/dashboard/complex-view/schema-view/components/component-config.js 中配置组件

schema-form 控件扩展

  1. app/widgets/schema-form/complex-view 目录下写控件
  2. app/widgets/schema-form/form-item-config.js 中配置控件

schema-search-bar 控件扩展

  1. app/widgets/schema-search-bar/complex-view 目录下写控件
  2. app/widgets/schema-search-bar/search-item-config.js 中配置控件