@choukunbc081/elips
v1.0.2
Published
~##一个企业级应用,通过全栈实现; #package.json--- "dev" : "_ENV='local' nodemon ./index.js", nodemon,这个的作用是为了,开发修改文件之后,会自动把项目重新跑一次
Readme
#elips ~##一个企业级应用,通过全栈实现; #package.json--- "dev" : "_ENV='local' nodemon ./index.js", nodemon,这个的作用是为了,开发修改文件之后,会自动把项目重新跑一次
注意:
window 与 mac 的问题
1. package.json
window 需要安装 cross-env
"dev": "cross-env _ENV=local nodemon ./index.js",
"beta": "cross-env _ENV='beta' node ./index.js",
"prod": "cross-env _ENV='prod' node ./index.js",
Mac写法:
"dev": "_ENV='local' nodemon ./index.js",
"beta": "_ENV='beta' node ./index.js",
"prod": "_ENV='prod' node ./index.js",
2.model\index.js
原因:window 下 glob.sync 和 path.sep 斜杠不一致导致的判断错误
mac写法:
const type = file.indexOf(`${sep}project${sep}`) > -1 ? 'project' : 'model';
window写法:
const type = path.resolve(file).indexOf(`${sep}project${sep}`) > -1 ? 'project' : 'model';model 配置
export default {
mode: 'dashboard', //模版类型,不同模板类型对应不一样的模版数据结构
name: '',// 名称
desc: '', // 描述
icon: '', // 首页(项目配置)
// 头部菜单 header-container
menu: [
{
key: '', //菜单唯一描述
name: '', // 菜单名称
/**
* header-container 里面可能会出现 菜单1 菜单2 菜单组件1 菜单组件2
* meuType设置为两种类型: group 、 module(对应一个板块)
*/
menuType: '', // 枚举值, group / module
// 当 meuType == group 时,可填
subMenu: [{
// 可递归 menuItem 这里递归出来的就是header-container的每一个头部菜单
// ... 表示可以出现多个{}这里面的内容
},
// 更多菜单项...
],
/**
* 点击header-container 中的某一个菜单,可能出现 sider-container/schema-view/iframe-view/custom-view
* schema-view 80%的内容,都已schema沉淀,最终根据配置渲染出页面;
* iframe-view 第三方组件;
* custom-view 自定义页面;
* sider-container 左侧菜单;
* --- 左侧菜单 :里面可能会出现 菜单1 菜单2 菜单组件1 菜单组件2
*/
// 当 meuType == module 时,可填
moduleType: '', // 枚举值: sider/iframe/custom/schema
// 当 moduleType == sider 时,(侧边栏)
siderConfig: {
menu: [{
//可递归 menuItem (除了 moduleType == sider),这里递归出来的就是sider-container的每一个侧边菜单
},
// 更多菜单项...
]
},
// 当 moduleType == iframe 时,
iframeConfig: {
path: '', // iframe的路径
},
// 当 moduleType == custom 时,
customConfig: {
path: '', // 自定义路由路径
},
// 当 moduleType == schema 时,
schemaConfig: {
/**
* DSL(dashboader模版配置)---> schema config ---> 解析器 ---> schema-view
* schema-view 里面有 1.schema-search-bar , select 或者 date-range 或者 其他组件
* 2.其他组件
* 3.schema-table
* 4.schema-table-row , <button>[点击按钮,弹出 schema-form [有 input , select, radio, 其他组件]],其他组件[ 有 其他组件 等]
* 往往重复性的内容,来源于同一份数据,(;可以是同一个api接口返回的数据,也可以是同一份数据库的数据等)
*
*/
api: '/api/user', // 数据源api (遵循 RESTFUL 规范)
schema: { // 板块数据接口
type: 'object',
properties: {
key: {
...schema, // 标准 schema 配置
type: '', // 字段类型
label: '', // 字段的中文名
// 字段在 table 中的相关配置
tableOption: {
...elTableColumnConfig, // 标准 el-tabel-colum 配置
toFixed:0,// 保留小数点后几位
visible: true, // 是否在表单中展示,默认为true(false,表示不在表单中显示)
},
// 字段在 search-bar 中的相关配置 (搜索框)
searchOption:{
...eleComponentConfjg,// 标准 el-component-colum 配置
comType:'', //配置组件类型 input/select/....
default:'',// 默认值
// comType === 'select'
enumList:[], //下拉框可选项
// comType === 'dynamicSelect'
api:''
},
// 字段在不同动态 component 中的相关配置,前缀对应 componentConfig 中的键值
// 如: componentConfig.creatForm, 这里对应 createFormOption
// 字段在 createFrom 中相关配置
createFormOption:{
...eleComponentConfjg,// 标准 el-component-colum 配置
comType:'',// 控件类型,input/select/input-number
visible:true,// 是否展示(true/false),默认为 true
disabled:false, //是否禁用(true/false),默认为 false
default:'', //默认值
// comType === 'select'
enumList:[], //下拉框可选项
},
// 字段在 editForm 表单中的相关配置
editFormOption:{
comType:'',// 控件类型,input/select/input-number
visible:true,// 是否展示(true/false),默认为 true
disabled:false, //是否禁用(true/false),默认为 false
default:'', //默认值
// comType === 'select'
enumList:[], //下拉框可选项
},
detailPanelOption:{
...eleComponentConfjg,// 标准 el-component-colum 配置
comType:'',// 控件类型,input/select/input-number/tableImportExport
// comType === 'tableImportExport' 时的特殊配置
importBtnText: '导入导出', // 按钮文本
buttonType: 'primary', // 按钮类型
buttonSize: 'default', // 按钮大小
buttonIcon: 'Upload', // 按钮图标
uploadUrl: '', // 上传接口
exportFilename: '', // 导出文件名
templateFilename: '', // 模板文件名
sheetName: '', // sheet名称
maxFileSize: 10485760, // 文件大小限制
accept: '.xlsx, .xls, .csv', // 接受的文件类型
showImport: true, // 是否显示导入功能
showExport: true, // 是否显示导出功能
showTemplate: true, // 是否显示模板下载
customButton: false, // 是否使用自定义按钮
disabled: false, // 是否禁用
dialogTitle: '导入导出', // 对话框标题
dialogWidth: '500px', // 对话框宽度
importResultTitle: '导入结果', // 导入结果弹窗标题
}
// 还可以配置其他的 option
// formOption:{}
},
// 更多菜单项...
},
required:[], //标记哪些字段是必填项
},
// tabel 配置,表单描述
tableConfig: {
headerButtons:[
{
label:'', // 按钮中文名
eventKey:'', // 按钮事件名
eventOption:{
// 当 eventKey === 'showComponrnt'
comName:'', // 组件名称
}, // 按钮事件具体配置 (点击按钮事件的配置)
...elButtonConfig, //标准 el-button 配置
},
// 更多选项...
], //某一行,某一列会有按钮
rowButtons:[
{
label:'', //按钮中文名
eventKey:'', //按钮事件名
eventOption: {
// 当 eventKey === 'showComponrnt'
comName:'', // 组件名称
// 当 eventKey === ' remove '
params:{
// paramKey = 参数的键值
// rowValue = 参数值 (格式为 schema::tableKey,到 table 中找相应的字段)
paramKey: rowValueKey
}
}, // 按钮事件具体配置
...elButtonConfig, // 标准 el-button 配置
},
// 更多选项...
], //每一行,某一列会有按钮
},
// search-bar 相关配置
searchConfig: {},
// 动态组件
componentConfig: {
// 有多种不同的配置
// comA:{},
// comB:{},
// crate-form 表单相关配置
createForm:{
title:'', // 表单标题
saveBtnText:'', // 保存按钮文案
},
// edit-form 表单相关配置
editForm:{
mainKey:'',// 表单主键,用于唯一标识要修改的数据对象
title:'', // 表单标题
saveBtnText:'', //保存按钮文案
},
// detail-panel 相关配置
detailPanel:{
mainKey:'',// 表单主键,用于唯一标识要修改的数据对象
title:'', // 表单标题
}
// ...支持用户动态扩展
},
},
}
// 更多菜单项...
]
}服务端启动
const { serverStart } = require('@choukunbc081/elips');
// 启动 elips
const app = serverStart({});自定义服务端
- router-schema
- router
- controller
- service
- extend
- config
前端架构
const { frontendBuild } = require('@choukunbc081/elips');
//编译构建前端工程
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下写组件 - 配置到
app/pages/dashboard/complex-view/schema-view/components/componet-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
