2021-04-17 13:33:21 +00:00
|
|
|
|
---
|
|
|
|
|
title: 介绍
|
|
|
|
|
order: 1
|
|
|
|
|
toc: menu
|
|
|
|
|
nav:
|
|
|
|
|
title: 核心
|
|
|
|
|
order: 2
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# 介绍
|
|
|
|
|
|
|
|
|
|
NocoBase 核心主要围绕三点:
|
|
|
|
|
|
2021-07-12 14:13:48 +00:00
|
|
|
|
- 数据的结构
|
|
|
|
|
- 数据的行为
|
|
|
|
|
- 数据的形态
|
2021-04-17 13:33:21 +00:00
|
|
|
|
|
2021-07-12 14:13:48 +00:00
|
|
|
|
由此抽象了三类配置协议
|
2021-04-17 13:33:21 +00:00
|
|
|
|
|
2021-07-12 14:13:48 +00:00
|
|
|
|
- Collection:用于描述数据的结构和关系
|
|
|
|
|
- Resourcer:用于描述数据资源和操作方法
|
|
|
|
|
- UI Schema:用于描述用户界面(组件树结构)
|
2021-04-17 13:33:21 +00:00
|
|
|
|
|
2021-07-12 14:13:48 +00:00
|
|
|
|
## Collection
|
2021-04-17 13:33:21 +00:00
|
|
|
|
|
2021-07-12 14:13:48 +00:00
|
|
|
|
基于 Sequelize ModelOptions
|
2021-04-17 13:33:21 +00:00
|
|
|
|
|
2021-07-12 14:13:48 +00:00
|
|
|
|
```ts
|
|
|
|
|
{
|
|
|
|
|
name: 'posts',
|
|
|
|
|
fields: [
|
|
|
|
|
{type: 'string', name: 'title'},
|
|
|
|
|
{type: 'text', name: 'content'},
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
```
|
2021-04-17 13:33:21 +00:00
|
|
|
|
|
2021-07-12 14:13:48 +00:00
|
|
|
|
## Resourcer
|
2021-04-17 13:33:21 +00:00
|
|
|
|
|
2021-07-12 14:13:48 +00:00
|
|
|
|
基于资源(resource)和操作方法(action)设计,将 REST 和 RPC 思想融合起来
|
2021-04-17 13:33:21 +00:00
|
|
|
|
|
2021-07-12 14:13:48 +00:00
|
|
|
|
```ts
|
|
|
|
|
{
|
|
|
|
|
name: 'posts',
|
|
|
|
|
actions: {
|
|
|
|
|
list: {
|
|
|
|
|
filter: {}, // 过滤
|
|
|
|
|
fields: [], // 输出哪些字段
|
|
|
|
|
sort: '-created_at', // 排序
|
|
|
|
|
page: 1,
|
|
|
|
|
perPage: 20,
|
|
|
|
|
// ...
|
|
|
|
|
},
|
|
|
|
|
get: {
|
|
|
|
|
filter: {},
|
|
|
|
|
fields: [],
|
|
|
|
|
// ...
|
|
|
|
|
},
|
|
|
|
|
create: {
|
|
|
|
|
fields: [],
|
|
|
|
|
values: {},
|
|
|
|
|
// ...
|
|
|
|
|
},
|
|
|
|
|
update: {
|
|
|
|
|
fields: [],
|
|
|
|
|
values: {},
|
|
|
|
|
// ...
|
|
|
|
|
},
|
|
|
|
|
destroy: {
|
|
|
|
|
filter: {},
|
|
|
|
|
// ...
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## UI Schema
|
|
|
|
|
|
|
|
|
|
基于 Formily Schema 2.0
|
|
|
|
|
|
|
|
|
|
```ts
|
|
|
|
|
{
|
|
|
|
|
type: 'object',
|
|
|
|
|
// 'x-component': 'Form',
|
|
|
|
|
properties: {
|
|
|
|
|
title: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
title: '标题',
|
|
|
|
|
'x-component': 'Input',
|
|
|
|
|
},
|
|
|
|
|
content: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
title: '标题',
|
|
|
|
|
'x-component': 'Input.TextArea',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
更进一步,构建了整个 NocoBase 架构:
|
|
|
|
|
|
|
|
|
|
<img src="https://nocobase.oss-cn-beijing.aliyuncs.com/60ffd9aff98871c643569219c2873749.png" style="max-width: 800px;width:100%"/>
|