Skip to content

Commit 826b83a

Browse files
committed
update docs
1 parent df6b1fe commit 826b83a

File tree

3 files changed

+185
-129
lines changed

3 files changed

+185
-129
lines changed

docs/plugin/dev.md

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ title: 插件开发
1414
:::: steps
1515

1616
1. clone 最新 fba 项目到本地并配置好开发环境
17-
2. 根据插件模板的目录结构进行插件开发
17+
2. 根据插件模板的 [目录结构](#插件目录结构) 和其他配置说明进行插件开发
1818
3. 完成插件开发
1919
4. 使用插件模板仓库创建个人仓库,并将插件代码更新至个人仓库
2020

@@ -26,7 +26,7 @@ title: 插件开发
2626

2727
::::
2828

29-
### 插件目录结构说明
29+
### 插件目录结构
3030

3131
::: file-tree
3232

@@ -42,27 +42,57 @@ title: 插件开发
4242
- service/ 服务
4343
- utils/ 工具包,如果插件无需独立工具,则无需此目录
4444
- \_\_init__.py 作为 python 包保留(必须项)
45-
- conf.py 配置,如果插件不需要独立配置,则无需此文件
46-
- plugin.toml 插件配置(必填项)
45+
- conf.py 常量配置,如果插件不需要独立常量配置,则无需此文件
46+
- plugin.toml 插件配置文件(必填项)
4747
- README.md 插件使用说明
4848
- requirements.txt 依赖包文件(非必须项)如果插件不需要安装额外依赖,则无需此文件
4949

5050
:::
5151

52-
::: warning 插件接口附加说明
52+
### 插件接口
5353

5454
- 如果插件作为独立 app 发布(在 `backend/app` 目录下的应用,视为独立
5555
app),则插件路由应完全遵循 [路由结构](../guide/reference/router.md#路由结构) 进行定义
56-
- 如果插件作为现有 app 扩展功能发布,则插件路由应当根据现有 app 中的路由结构进行 1:1 结构复制,可参考 fba
56+
- 如果插件作为现有 app 扩展功能发布,则插件路由必须根据现有 app 中的路由结构进行 1:1 结构复制,可参考 fba
5757
源码中的内置插件 [notice](https://github.com/fastapi-practices/fastapi_best_architecture/tree/master/backend/plugin/notice/api)
5858

59-
:::
60-
61-
### 插件路由说明
59+
### 插件路由
6260

6361
如果插件符合插件开发的要求,则插件的所有路由都将自动注入到 FastAPI 应用中,无需任何其他操作,但值得注意的是,启动时间可能会随着插件数量的递增而增加,因为
6462
fba 会在启动前对所有插件进行解析
6563

64+
### 插件配置
65+
66+
`plugin.toml` 是插件的配置文件,它必须存在,此配置文件根据插件的属性进行定义
67+
68+
- 非独立 app
69+
70+
```toml
71+
# app 配置
72+
[app]
73+
# 此插件属于哪个 app
74+
include = ''
75+
76+
# api 配置
77+
# xxx 对应的是插件 api 目录下的接口文件名(不包含后缀)
78+
# 例如接口文件名为 notice.py,则 xxx 应该为 notice
79+
# 如果包含多个接口文件,则应存在多个相应的 api 配置
80+
[api.xxx]
81+
# 路由前缀,必须以 '/' 开头
82+
prefix = ''
83+
# 标签,用于接口文档
84+
tags = ''
85+
```
86+
87+
- 独立 app
88+
89+
```toml
90+
# app 配置
91+
[app]
92+
# 插件路由器版本,默认为 v1(可参考源码 `backend/app/admin/api/router.py`)
93+
router = ['v1']
94+
```
95+
6696
## 前端
6797

6898
一旦 [Vben Admin Antd 下一代实施](https://github.com/fastapi-practices/fba_ui) 生产可用,我们将开启此计划...

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"sass-embedded": "^1.83.0",
2121
"vue": "^3.5.13",
2222
"vuepress": "2.0.0-rc.19",
23-
"vuepress-theme-plume": "1.0.0-rc.130"
23+
"vuepress-theme-plume": "1.0.0-rc.131"
2424
},
2525
"dependencies": {
2626
"@iconify/json": "^2.2.282",

0 commit comments

Comments
 (0)