Skip to content

Commit c6ced8c

Browse files
committed
update docs
1 parent 13e6684 commit c6ced8c

File tree

14 files changed

+623
-500
lines changed

14 files changed

+623
-500
lines changed

docs/.vuepress/bulletin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ export const myBulletin: BulletinOptions = {
66
content: `
77
::: center
88
9-
**知识星球:** [玩转 FBA,不止 FBA](https://t.zsxq.com/sDbws)
9+
**Discord 服务器:** [Python 开发交流社区](https://discord.com/invite/yNN3wTbVAC)
1010
1111
<hr>
1212
13-
<p style="font-size: 14px; color: rgb(160, 160, 160);">加入 <a href="https://discord.gg/yNN3wTbVAC">Discord</a> 频道,即可领取免费体验机会,更有大额优惠券随机发放,先到先得!</p>
13+
<p style="font-size: 14px; color: rgb(160, 160, 160);">加入并订阅此服务器,即可尊享闲聊,技术分享,疑难杂症解答,与大佬肩并肩,速速行动吧!</p>
1414
15-
<img src="https://wu-clan.github.io/picx-images-hosting/知识星球.png">
15+
<iframe src="https://discord.com/widget?id=1185035164577972344&theme=dark" width="350" height="500" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>
1616
1717
:::
1818
`,

docs/.vuepress/config.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {myNavbar} from "./navbar";
22
import {mySidebar} from "./sidebar";
33
import {defineUserConfig} from "vuepress";
44
import plumeTheme from "vuepress-theme-plume";
5-
import { viteBundler } from '@vuepress/bundler-vite'
5+
import {viteBundler} from '@vuepress/bundler-vite'
66
import {myBulletin} from "./bulletin";
77

88

@@ -11,7 +11,7 @@ export default defineUserConfig({
1111
lang: 'zh-CN',
1212
title: 'FastAPI Best Architecture',
1313
head: [
14-
['link', {rel: 'icon', href: 'https://fastapi.tiangolo.com/img/favicon.png'}]
14+
['link', {rel: 'icon', href: 'https://wu-clan.github.io/picx-images-hosting/logo/fba.svg'}]
1515
],
1616
theme: plumeTheme({
1717
blog: false,
@@ -24,14 +24,15 @@ export default defineUserConfig({
2424
bulletin: myBulletin,
2525
sidebar: mySidebar,
2626
navbar: myNavbar,
27-
logo: 'https://fastapi.tiangolo.com/img/favicon.png',
27+
logo: 'https://wu-clan.github.io/picx-images-hosting/logo/fba.png',
2828
docsRepo: 'https://github.com/fastapi-practices/fastapi_best_architecture_docs',
2929
docsBranch: 'master',
3030
docsDir: 'docs',
3131
social: [
32-
{ icon: 'github', link: 'https://github.com/fastapi-practices/fastapi_best_architecture' }
32+
{icon: 'github', link: 'https://github.com/fastapi-practices/fastapi_best_architecture'},
33+
{icon: 'discord', link: 'https://discord.com/invite/yNN3wTbVAC'}
3334
],
34-
navbarSocialInclude: ['github'],
35+
// navbarSocialInclude: ['github'],
3536
editLinkText: '在 GitHub 上编辑此页面',
3637
// lastUpdated: {
3738
// text: 'Releases',
@@ -42,14 +43,14 @@ export default defineUserConfig({
4243
},
4344
plugins: {
4445
shiki: {
45-
languages: ['shell','yaml','py']
46+
languages: ['shell', 'yaml', 'py']
4647
},
4748
watermark: true,
4849
markdownPower: {
4950
icons: true,
5051
bilibili: true,
5152
},
52-
}
53+
},
5354
}),
5455
bundler: viteBundler(),
5556
})

docs/guide/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ mvc 架构作为常规设计模式,在 python web 中很常见,但是三层
100100

101101
## 相关
102102

103-
<RepoCard repo="fastapi-practices/sqlalchemy-crud-plus" />
103+
<RepoCard repo="wu-clan/sqlalchemy-crud-plus" />
104104

105105
::: tip 特别鸣谢
106106
本文档由 [vuepress-theme-plume](https://github.com/pengzhanbo/vuepress-theme-plume)

docs/guide/mixin/user.md

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,14 @@
22
title: Mixin
33
---
44

5-
我们默认提供的所有模型都是没有操作人员信息的,在很多项目中,可能会添加每条数据的创建人、更新人,
6-
虽然我们没有实行这一特性,但是,我们提供了非常简易的集成方式
5+
<div align="center">
76

8-
## 如何应用?
7+
此内容为非公开内容,扫码加入知识星球,即可获取独家内容
98

10-
`common/model.py` 文件中,我们提供了用户 Mixin 类
9+
但请注意,我们并不保证星球内容更新频率,您可以依据星球规则进行全额退款
1110

12-
```py
13-
class UserMixin(MappedAsDataclass):
14-
"""用户 Mixin 数据类"""
11+
<p style="color: rgb(160, 160, 160);">注:加入的 Discord 频道,可领取免费体验资格</p>
1512

16-
create_user: Mapped[int] = mapped_column(sort_order=998, comment='创建者')
17-
update_user: Mapped[int | None] = mapped_column(init=False, default=None, sort_order=998, comment='修改者')
18-
```
13+
<img height="349" width="415" src="https://wu-clan.github.io/picx-images-hosting/知识星球.png" alt="知识星球">
1914

20-
通常情况下,你会在自定义模型类中继承 `Base` 父类,要想灵活的应用操作人员信息,你只需在继承 `Base` 父类的同时,也继承
21-
`UserMixin` 类,这样就将自动添加操作人员列到模型
22-
23-
## 如何使用?
24-
25-
应用操作人员信息后,首先,你要在接口参数中,传递 `request: Request`,并作为第一个参数(在 Django,flask 等框架中,这可能很常见)
26-
27-
然后,在执行创建或更新操作时,可通过 `request.user.id` 直接获取操作人员 id,并进行数据库写入
28-
29-
我们之所以没有默认应用此功能,是因为我们不想所有接口重复调用 `request` 参数(作者强迫症)
15+
</div>

docs/guide/reference/RBAC.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ RBAC 提供了两种解决方案,第一种【角色菜单】可能更加常见
1414
要想实现此 RBAC 调用,涉及到三处相关配置
1515

1616
::: steps
17+
1718
1. 更新 RBAC 鉴权配置
1819

1920
`core/conf.py` 文件中找到以下配置,并更新 `PERMISSION_MODE``role-menu`
@@ -25,7 +26,7 @@ RBAC 提供了两种解决方案,第一种【角色菜单】可能更加常见
2526

2627
2. 添加接口依赖
2728

28-
只有在接口中参加此依赖时,才能自动应用此鉴权
29+
只有在接口中填加此依赖时,才能自动应用此鉴权方式
2930

3031
```py{5-6}
3132
@router.post(
@@ -40,8 +41,8 @@ RBAC 提供了两种解决方案,第一种【角色菜单】可能更加常见
4041

4142
3. 在菜单中添加权限标识
4243

43-
我们在接口依赖中可以看到 `sys:api:add` 之类的值,这些值正是对应着菜单中的权限标识,只有它们完全一致,并且用户拥有菜单时,才有权执行操作
44-
:::
44+
我们在接口依赖中可以看到 `sys:api:add` 之类的值,这些值正是对应着菜单中的权限标识,只有它们完全一致,并且用户拥有菜单时,才会获得相应的操作权限
45+
:::
4546

4647
### Casbin
4748

@@ -77,15 +78,15 @@ m = g(r.sub, p.sub) && (keyMatch(r.obj, p.obj) || keyMatch3(r.obj, p.obj)) && (r
7778
p 策略:
7879
7980
- 推荐添加基于角色的访问权限, 需配合添加 g 策略才能真正拥有访问权限,适合配置全局接口访问策略<br>
80-
**格式**: 角色 role + 访问路径 path + 访问方法 method
81+
**格式**: 角色 role + 访问路径 path + 访问方法 method
8182
8283
- 如果添加基于用户的访问权限, 不需配合添加 g 策略就能真正拥有权限,适合配置指定用户接口访问策略<br>
83-
**格式**: 用户 uuid + 访问路径 path + 访问方法 method
84+
**格式**: 用户 uuid + 访问路径 path + 访问方法 method
8485
8586
g 策略 (**依赖 p 策略**):
8687
8788
- 如果在 p 策略中添加了基于角色的访问权限, 则还需要在 g 策略中添加基于用户组的访问权限, 才能真正拥有访问权限<br>
88-
**格式**: 用户 uuid + 角色 role
89+
**格式**: 用户 uuid + 角色 role
8990
9091
- 如果在 p 策略中添加了基于用户的访问权限, 则不添加相应的 g 策略能直接拥有访问权限<br>
91-
但是拥有的不是用户角色的所有权限, 而只是单一的对应的 p 策略所添加的访问权限
92+
但是拥有的不是用户角色的所有权限, 而只是单一的对应的 p 策略所添加的访问权限

docs/guide/reference/code-generation.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ title: 代码生成
88
> 代码生成器使用 api 调用实现,包含两个模组,设计可能存在缺陷,相关问题请直接提交 issues
99
1010
> [!WARNING]
11-
> 由于 jinja2 在渲染模版时,文本方式输出可能存在格式问题,所以 `preview` 接口可能无法直观预览代码,这是为前端进行的预设
11+
> 由于 jinja2 在渲染模版时,文本方式输出可能存在格式问题,所以 `preview` 接口可能无法直观预览代码,这是为前端进行的预设,
12+
> 你可以在我们的在线预览中更加直观的查看生成效果
1213
1314
## 概念
1415

@@ -20,13 +21,7 @@ title: 代码生成
2021

2122
包含代码生成所需要的模型列信息,就像正常定义模型列一样,目前支持的功能有限
2223

23-
## 使(食)用
24-
25-
1. 启动后端服务,打开 swagger 文档直接操作
26-
2. 通过第三方 api 调试工具发送接口请求
27-
3. 同时启动前后端,从页面进行操作
28-
29-
接口参数基本都有说明,请注意查看
24+
## 使用
3025

3126
### F. 纯手动模式
3227

docs/guide/reference/cors.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
title: 跨域
33
---
44

5-
当进行前后端项目联调或服务器部署时,你通常会遇到跨域问题,不过没关系,你只需修改后端配置,就可以轻松解决 CORS 相关问题
5+
当进行前后端项目联调或服务器部署时,你通常会遇到跨域问题,不过没关系,你只需进入 `core/conf.py` 文件,修改
6+
`CORS_ALLOWED_ORIGINS` 配置即可,就可以轻松解决 CORS 相关问题
67

78
## 本地
89

9-
进入 `core/conf.py` 文件,修改 `CORS_ALLOWED_ORIGINS` 配置即可
10-
1110
```py
1211
CORS_ALLOWED_ORIGINS: list[str] = [
1312
'http://localhost:5173', # 前端访问地址,末尾不要带 '/'
@@ -16,8 +15,6 @@ CORS_ALLOWED_ORIGINS: list[str] = [
1615

1716
## 服务器
1817

19-
进入 `core/conf.py` 文件,修改 `CORS_ALLOWED_ORIGINS` 配置即可
20-
2118
1. 非 https 部署
2219

2320
```py

docs/guide/reference/oauth.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22
title: 授权
33
---
44

5-
::: note
5+
::: tip
66
通过 JWT 中间件实现全局自动授权
77
:::
88

9-
我们编写了自定义的 JWT 授权中间件,使其可以在每次请求发起时,自动调用此中间件实现自动授权,并且,通过 Redis 和 Rust 库对用户信息进行快速缓存,
10-
使其性能影响尽可能降到最低
9+
我们编写了自定义的 JWT 授权中间件,使其可以在每次请求发起时,自动调用此中间件实现自动授权,并且,通过 Redis 和 Rust
10+
库对用户信息进行快速缓存,使其性能影响尽可能降到最低,你可以通过以下几种方式进行自动授权
1111

1212
## 验证码登录
1313

14-
我们提供了数字验证码方式的登录授权接口,登录成功后,JWT 将包含在接口响应信息中
14+
这种方式更适用于前端界面调用
1515

16-
17-
## Swagger 授权
16+
## Swagger 登录
1817

1918
这是一种快捷的授权方式,但仅出于调试目的,在服务启动后,进入 Swagger UI,可通过此调试接口进行快速登录授权(无需验证码)
2019

docs/guide/reference/transaction.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
title: 事务
33
---
44

5-
我们可以通过两种方式实现数据库事务
6-
75
## session 生成器
86

97
这是官方一种比较流行的方法,通过迭代 session 控制隔离,并通过上下文异常进行回滚,最后关闭 session

docs/guide/summary/fsm.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
title: 精简版本
33
---
44

5-
我们有一些简化版本的 fastapi 三层架构脚手架,但是它们的更新可能并不同步,这意味着,你可能无法及时在便捷版中获得新功能支持和的问题修复
5+
我们有一些简化版本的 fastapi 三层架构脚手架,==但是它们的更新可能并不同步==,这意味着,你可能无法及时在便捷版中获得新功能支持和问题修复
66

7-
::: info
7+
::: tip
88
我们积极寻找这些版本仓库的维护人员,如果你对此感兴趣,请直接在对应仓库创建 ISSUES
99
:::
1010

11+
<RepoCard repo="wu-clan/fastapi_sqlalchemy_mysql" />
12+
1113
<CardGrid>
12-
<RepoCard repo="fastapi-practices/fastapi_sqlalchemy_mysql" />
13-
<RepoCard repo="fastapi-practices/fastapi_tortoise_mysql" />
14-
<RepoCard repo="fastapi-practices/fastapi_sqlmodel_mysql" />
14+
<RepoCard repo="wu-clan/fastapi_tortoise_mysql" />
15+
<RepoCard repo="wu-clan/fastapi_sqlmodel_mysql" />
1516
</CardGrid>

0 commit comments

Comments
 (0)