feat(doc): update api doc
This commit is contained in:
parent
a702f534ba
commit
296fbd6c08
@ -59,6 +59,64 @@ const SchemaComponent = createSchemaComponent({
|
||||
/>
|
||||
```
|
||||
|
||||
SchemaComponent 是通过 Schema 协议渲染的组件,SchemaComponent 可能由多个原子组件组合而成。
|
||||
|
||||
```ts
|
||||
interface ISchema {
|
||||
type: string;
|
||||
name?: string;
|
||||
title?: any;
|
||||
properties?: any;
|
||||
['x-component']?: any;
|
||||
['x-component-props']?: any;
|
||||
['x-decorator']?: any;
|
||||
['x-decorator-props']?: any;
|
||||
['x-designable-bar']?: any;
|
||||
['x-designable-bar-props']?: any;
|
||||
}
|
||||
```
|
||||
|
||||
Schema 组件的完整结构如下:
|
||||
|
||||
<pre lang="tsx">
|
||||
<Decorator>
|
||||
<DesignableBar />
|
||||
<Component>
|
||||
{...properties}
|
||||
</Component>
|
||||
</Decorator>
|
||||
</pre>
|
||||
|
||||
DesignableBar 可以用于修改当前 SchemaComponent 的 Schema。可以以任意形态出现,例如:
|
||||
|
||||
<pre lang="tsx">
|
||||
function DesignableBar() {
|
||||
// 这里是随意写的,当前 schema,可以 update,remove 等等
|
||||
const { schema, update, remove } = useDesignableSchema();
|
||||
return (
|
||||
<Space>
|
||||
<Dropdown overlay={
|
||||
<Menu>
|
||||
<Menu.Item>配置项1</Menu.Item>
|
||||
<Menu.Item>配置项2</Menu.Item>
|
||||
<Menu.Item>配置项3</Menu.Item>
|
||||
</Menu>
|
||||
}>
|
||||
<a>配置<a/>
|
||||
</DropDown>
|
||||
<Dropdown>
|
||||
<a>配置<a/>
|
||||
</DropDown>
|
||||
<Dropdown>
|
||||
<a>配置<a/>
|
||||
</DropDown>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
</pre>
|
||||
|
||||
如果 DesignableBar 只是修改当前层级的参数比较好处理,但是如果修改的是 properties 子节点里的参数,情况会变得比较复杂。
|
||||
|
||||
## 字段组件
|
||||
|
||||
```ts
|
||||
@ -82,7 +140,6 @@ const string: FieldOptions = {
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
|
||||
},
|
||||
operations: [
|
||||
{ label: '包含', value: '$includes', selected: true },
|
||||
@ -92,10 +149,14 @@ const string: FieldOptions = {
|
||||
{ label: '非空', value: '$notNull', noValue: true },
|
||||
{ label: '为空', value: '$null', noValue: true },
|
||||
],
|
||||
designableBar: {
|
||||
key1: {},
|
||||
key2: {},
|
||||
},
|
||||
};
|
||||
|
||||
const CollectionField = createCollectionField({
|
||||
interface: {
|
||||
interfaces: {
|
||||
string,
|
||||
},
|
||||
})
|
||||
|
135
docs/plugins/collections.md
Normal file
135
docs/plugins/collections.md
Normal file
@ -0,0 +1,135 @@
|
||||
# @nocobase/plugin-collections
|
||||
|
||||
提供 HTTP API 的方式管理数据表和字段
|
||||
|
||||
## HTTP API
|
||||
|
||||
### Collections
|
||||
|
||||
```bash
|
||||
GET /api/collections
|
||||
POST /api/collections
|
||||
GET /api/collections/<collectionName>
|
||||
PUT /api/collections/<collectionName>
|
||||
DELETE /api/collections/<collectionName>
|
||||
```
|
||||
|
||||
### Fields
|
||||
|
||||
```bash
|
||||
GET /api/collections/<collectionName>/fields
|
||||
POST /api/collections/<collectionName>/fields
|
||||
GET /api/collections/<collectionName>/fields/<fieldName>
|
||||
PUT /api/collections/<collectionName>/fields/<fieldName>
|
||||
DELETE /api/collections/<collectionName>/fields/<fieldName>
|
||||
```
|
||||
|
||||
<Alert title="注意">
|
||||
|
||||
- 方便开发使用,API Route 上直接暴露的是 collectionName 和 fieldName,这样的可读性更好,但是如果修改了 collectionName 和 fieldName,可能会导致很多不可预知问题,所以要谨慎修改,或者不允许修改。
|
||||
- fieldName 只在某 collectionName 下是唯一的。fields 表要为 collectionName 和 fieldName 建立唯一索引。
|
||||
|
||||
</Alert>
|
||||
|
||||
## Repository API
|
||||
|
||||
### CollectionRepository.load()
|
||||
|
||||
将符合条件的 collections 配置导入 db.collections
|
||||
|
||||
##### Definition
|
||||
|
||||
```ts
|
||||
class CollectionRepository extends Repository {
|
||||
async load(options?: LoadOptions): void;
|
||||
}
|
||||
```
|
||||
|
||||
##### Examples
|
||||
|
||||
```ts
|
||||
const Collection = db.getCollection('collections');
|
||||
await Collection.repository.load({
|
||||
filter: {},
|
||||
});
|
||||
```
|
||||
|
||||
## Model API
|
||||
|
||||
### CollectionModel.migrate()
|
||||
|
||||
##### Definition
|
||||
|
||||
```ts
|
||||
class CollectionModel extends Model {
|
||||
migrate(options?: MigrateOptions): Promise<void>;
|
||||
}
|
||||
```
|
||||
|
||||
##### Examples
|
||||
|
||||
```ts
|
||||
const collection = await Collection.repository.create({
|
||||
name: 'tests',
|
||||
});
|
||||
await collection.migrate();
|
||||
```
|
||||
|
||||
### FieldModel.migrate()
|
||||
|
||||
##### Definition
|
||||
|
||||
```ts
|
||||
class FieldModel extends Model {
|
||||
migrate(options?: MigrateOptions): Promise<void>;
|
||||
}
|
||||
```
|
||||
|
||||
##### Examples
|
||||
|
||||
```ts
|
||||
const Field = db.getCollection('fields');
|
||||
const field = await Field.repository.create({
|
||||
type: 'string',
|
||||
name: 'title',
|
||||
collectionName: 'tests',
|
||||
});
|
||||
await field.migrate();
|
||||
```
|
||||
|
||||
## plugin-collections 和 db.collection() 的区别
|
||||
|
||||
- plugin-collections 增加了绑定组件的相关参数:interface、uiSchema
|
||||
- plugin-collections 的配置存储在数据表里,再同步给 db.collection()
|
||||
- db.collection() 适用于配置较固定的系统表
|
||||
- plugin-collections 适用于配置业务表
|
||||
|
||||
## Examples
|
||||
|
||||
<Alert title="注意">
|
||||
例子待补充
|
||||
</Alert>
|
||||
|
||||
简单的配置
|
||||
|
||||
```ts
|
||||
Collection.repository.create({
|
||||
name: 'tests',
|
||||
fields: [
|
||||
{ type: 'string', name: 'title' },
|
||||
{ type: 'text', name: 'content' },
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
带 uiSchema 的配置
|
||||
|
||||
```ts
|
||||
Collection.repository.create({
|
||||
name: 'tests',
|
||||
fields: [
|
||||
{ type: 'string', name: 'title' },
|
||||
{ type: 'text', name: 'content', uiSchema: {}, interface: 'markdown' },
|
||||
],
|
||||
});
|
||||
```
|
3
docs/plugins/permissions.md
Normal file
3
docs/plugins/permissions.md
Normal file
@ -0,0 +1,3 @@
|
||||
# @nocobase/plugin-permissions
|
||||
|
||||
|
@ -31,7 +31,7 @@ app.db.on('xxx', () => {
|
||||
|
||||
资源实例
|
||||
|
||||
## app.pm
|
||||
## app.pm <Badge>待完善</Badge>
|
||||
|
||||
插件管理器,详情见 [Plugin Manager](plugin-manager)
|
||||
|
||||
@ -71,9 +71,13 @@ app.i18n.t('Hello');
|
||||
|
||||
构造器
|
||||
|
||||
## app.use()
|
||||
## app.use() <Badge>待完善</Badge>
|
||||
|
||||
中间件
|
||||
添加中间件
|
||||
|
||||
## app.unuse() <Badge>待完善</Badge>
|
||||
|
||||
移除中间件
|
||||
|
||||
## app.on()
|
||||
|
||||
@ -87,11 +91,11 @@ app.i18n.t('Hello');
|
||||
|
||||
等同于 app.db.collection()
|
||||
|
||||
## app.actions()
|
||||
## app.actions() <Badge>待完善</Badge>
|
||||
|
||||
等同于 app.resourcer.registerActions()
|
||||
|
||||
## app.resource()
|
||||
## app.resource() <Badge>待完善</Badge>
|
||||
|
||||
等同于 app.resourcer.define()
|
||||
|
||||
@ -99,19 +103,19 @@ app.i18n.t('Hello');
|
||||
|
||||
等同于 app.cli.parse()
|
||||
|
||||
## app.load()
|
||||
## app.load() <Badge>待完善</Badge>
|
||||
|
||||
加载配置
|
||||
|
||||
## app.init()
|
||||
## app.init() <Badge>待完善</Badge>
|
||||
|
||||
初始化
|
||||
|
||||
## app.start()
|
||||
## app.start() <Badge>待完善</Badge>
|
||||
|
||||
启动应用
|
||||
|
||||
## app.stop()
|
||||
## app.stop() <Badge>待完善</Badge>
|
||||
|
||||
停止应用
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
toc: menu
|
||||
---
|
||||
|
||||
# CLI
|
||||
# CLI <Badge>待完善</Badge>
|
||||
|
||||
这里的 CLI 指的是通过 app.cli 提供的默认的 commands。
|
||||
|
||||
@ -23,18 +23,18 @@ toc: menu
|
||||
|
||||
- `--force` 删除重建
|
||||
|
||||
## `pm:download`
|
||||
## `pm:download` <Badge>待完善</Badge>
|
||||
|
||||
下载插件
|
||||
|
||||
## `pm:enable`
|
||||
## `pm:enable` <Badge>待完善</Badge>
|
||||
|
||||
激活插件
|
||||
|
||||
## `pm:disable`
|
||||
## `pm:disable` <Badge>待完善</Badge>
|
||||
|
||||
禁用插件
|
||||
|
||||
## `pm:remove`
|
||||
## `pm:remove` <Badge>待完善</Badge>
|
||||
|
||||
移除插件
|
||||
|
@ -2,15 +2,15 @@
|
||||
toc: menu
|
||||
---
|
||||
|
||||
# Client
|
||||
# Client <Badge>待完善</Badge>
|
||||
|
||||
## APIClient
|
||||
## APIClient <Badge>待完善</Badge>
|
||||
|
||||
## createRouteSwitch
|
||||
## createRouteSwitch <Badge>待完善</Badge>
|
||||
|
||||
## createCollectionField
|
||||
## createCollectionField <Badge>待完善</Badge>
|
||||
|
||||
## createSchemaComponent
|
||||
## createSchemaComponent <Badge>待完善</Badge>
|
||||
|
||||
## i18n
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
toc: menu
|
||||
---
|
||||
|
||||
# Collection
|
||||
# Collection <Badge>待完善</Badge>
|
||||
|
||||
## `collection.addField()`
|
||||
|
||||
|
@ -24,7 +24,7 @@ async (ctx, next) {
|
||||
|
||||
## ctx.resourcer
|
||||
|
||||
## ctx.action
|
||||
## ctx.action <Badge>待完善</Badge>
|
||||
|
||||
## ctx.i18n
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
toc: menu
|
||||
---
|
||||
|
||||
# Operators
|
||||
# Operators <Badge>待完善</Badge>
|
||||
|
||||
## string
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
toc: menu
|
||||
---
|
||||
|
||||
# PluginManager
|
||||
# PluginManager <Badge>待完善</Badge>
|
||||
|
||||
## pm.constructor()
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
toc: menu
|
||||
---
|
||||
|
||||
# Plugin
|
||||
# Plugin <Badge>待完善</Badge>
|
||||
|
||||
## plugin.constructor()
|
||||
## plugin.enable()
|
||||
|
Loading…
Reference in New Issue
Block a user