tachybase_todo/docs/cores/index.md
2021-07-12 22:13:48 +08:00

102 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: 介绍
order: 1
toc: menu
nav:
title: 核心
order: 2
---
# 介绍
NocoBase 核心主要围绕三点:
- 数据的结构
- 数据的行为
- 数据的形态
由此抽象了三类配置协议
- Collection用于描述数据的结构和关系
- Resourcer用于描述数据资源和操作方法
- UI Schema用于描述用户界面组件树结构
## Collection
基于 Sequelize ModelOptions
```ts
{
name: 'posts',
fields: [
{type: 'string', name: 'title'},
{type: 'text', name: 'content'},
],
}
```
## Resourcer
基于资源resource和操作方法action设计将 REST 和 RPC 思想融合起来
```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%"/>