完善开发文档与调整初始化项目架构

This commit is contained in:
wojiaoyishang
2025-01-28 17:47:41 +08:00
parent da5917344e
commit 41bda82c60
13 changed files with 316 additions and 9 deletions
+1 -1
View File
@@ -12,7 +12,7 @@
<p align="center">
<a href="#">
<img src="https://img.shields.io/badge/pear%20admin%20flask-1.0.0-green" alt="Pear Admin Layui Version">
<img src="https://img.shields.io/badge/pear%20admin%20flask-2.0.0-green" alt="Pear Admin Layui Version">
</a>
<a href="#">
<img src="https://img.shields.io/badge/Python-3.8+-green.svg" alt="Python Version">
+4 -2
View File
@@ -18,9 +18,11 @@ def init_plugs(app: Flask) -> None:
# 注册 Flask 功能
init_login_manager(app)
init_databases(app)
init_template_directives(app)
init_error_views(app)
init_mail(app)
init_upload(app)
init_migrate(app)
init_session(app)
# 系统蓝图相关
init_template_directives(app)
init_error_views(app)
@@ -0,0 +1,247 @@
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 Edg/133.0.0.0" version="26.0.6">
<diagram name="第 1 页" id="MiUs9oOc82b6Rctnqw0G">
<mxGraphModel dx="2040" dy="734" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="oXrC6FassujB1rqgt1jG-76" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-1" target="oXrC6FassujB1rqgt1jG-2">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-1" value="&lt;div&gt;&lt;span style=&quot;background-color: transparent; color: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));&quot;&gt;app = create_app()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;font-size: 9px; color: rgb(77, 77, 77);&quot;&gt;app.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="-20" y="220" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-8" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-2" target="oXrC6FassujB1rqgt1jG-3">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-2" value="&lt;div&gt;初始化 Flask()&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;font-size: 9px; color: rgb(77, 77, 77);&quot;&gt;applications/__init__.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="-20" y="130" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-9" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-3" target="oXrC6FassujB1rqgt1jG-4">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-23" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=none;endFill=0;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-3" target="oXrC6FassujB1rqgt1jG-22">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-3" value="&lt;div&gt;载入配置&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;font-size: 9px; color: rgb(77, 77, 77);&quot;&gt;applications/__init__.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="150" y="130" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-10" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-4" target="oXrC6FassujB1rqgt1jG-5">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-26" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=none;endFill=0;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-4" target="oXrC6FassujB1rqgt1jG-25">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-4" value="&lt;div&gt;注册组件&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;font-size: 9px; color: rgb(77, 77, 77);&quot;&gt;applications/__init__.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="330" y="130" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-11" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-5" target="oXrC6FassujB1rqgt1jG-6">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-50" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=none;endFill=0;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-5" target="oXrC6FassujB1rqgt1jG-49">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-5" value="&lt;div&gt;注册应用蓝图&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;font-size: 9px; color: rgb(77, 77, 77);&quot;&gt;applications/__init__.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="516" y="130" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-67" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=none;endFill=0;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-6" target="oXrC6FassujB1rqgt1jG-66">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-70" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-6" target="oXrC6FassujB1rqgt1jG-71">
<mxGeometry relative="1" as="geometry">
<mxPoint x="910" y="351.33331298828125" as="targetPoint" />
<Array as="points">
<mxPoint x="860" y="150" />
<mxPoint x="860" y="330" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-6" value="&lt;div&gt;注册命令&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;font-size: 9px; color: rgb(77, 77, 77);&quot;&gt;applications/__init__.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="700" y="130" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-22" value="&lt;div&gt;读取 BaseConfig&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;font-size: 9px; color: rgb(77, 77, 77);&quot;&gt;配置来自&amp;nbsp;applications/config.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="140" y="190" width="140" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-28" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-25" target="oXrC6FassujB1rqgt1jG-27">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-25" value="&lt;div&gt;初始化插件&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;font-size: 9px; color: rgb(77, 77, 77);&quot;&gt;applications/extensions/init_plugins.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="310" y="190" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-30" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-27" target="oXrC6FassujB1rqgt1jG-29">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-27" value="&lt;div&gt;广播插件&amp;nbsp;event_begin 事件&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;font-size: 9px; color: rgb(77, 77, 77);&quot;&gt;applications/extensions/init_plugins.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;dashed=1;" vertex="1" parent="1">
<mxGeometry x="310" y="250" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-32" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-29" target="oXrC6FassujB1rqgt1jG-31">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-29" value="&lt;div&gt;初始化 Flask LoginManager&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;font-size: 9px; color: rgb(77, 77, 77);&quot;&gt;applications/extensions/init_login.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="310" y="310" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-42" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-31" target="oXrC6FassujB1rqgt1jG-37">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-31" value="&lt;div&gt;初始化 SQLAlchemy 数据库&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;color: rgb(77, 77, 77); font-size: 8px;&quot;&gt;applications/extensions/init_sqlalchemy.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="310" y="370" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-44" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-37" target="oXrC6FassujB1rqgt1jG-43">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-37" value="&lt;div&gt;初始化 Mail 邮件组件&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;color: rgb(77, 77, 77); font-size: 8px;&quot;&gt;applications/extensions/init_error_views.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="310" y="430" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-39" value="&lt;div&gt;初始化 服务器错误蓝图&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;color: rgb(77, 77, 77); font-size: 8px;&quot;&gt;applications/extensions/init_error_views.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="310" y="670" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-48" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-41" target="oXrC6FassujB1rqgt1jG-39">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-41" value="&lt;div&gt;初始化 网页模板公用函数&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;color: rgb(77, 77, 77); font-size: 7px;&quot;&gt;applications/extensions/init_template_directives.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="310" y="610" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-46" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-43" target="oXrC6FassujB1rqgt1jG-45">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-43" value="&lt;div&gt;初始化&lt;font style=&quot;font-size: 9px;&quot;&gt; Migrate &lt;/font&gt;数据库迁移组件&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;color: rgb(77, 77, 77); font-size: 9px;&quot;&gt;applications/extensions/init_migrate.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="310" y="490" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-47" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-45" target="oXrC6FassujB1rqgt1jG-41">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-45" value="&lt;div&gt;初始化&lt;font size=&quot;1&quot;&gt;&amp;nbsp;Session 会话&lt;/font&gt;组件&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;color: rgb(77, 77, 77); font-size: 9px;&quot;&gt;applications/extensions/init_session.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="310" y="550" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-54" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=none;endFill=0;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-49" target="oXrC6FassujB1rqgt1jG-52">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-49" value="&lt;div&gt;注册应用子页面路由&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;font-size: 9px; color: rgb(77, 77, 77);&quot;&gt;applications/view/__init__.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="496" y="190" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-63" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=none;endFill=0;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-51" target="oXrC6FassujB1rqgt1jG-62">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-51" value="&lt;div&gt;广播插件&amp;nbsp;event_init 事件&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(77, 77, 77); font-size: 9px;&quot;&gt;applications/view/__init__.py&lt;/span&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;dashed=1;" vertex="1" parent="1">
<mxGeometry x="496" y="610" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-56" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-52" target="oXrC6FassujB1rqgt1jG-55">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-52" value="&lt;div&gt;注册 用户管理 蓝图&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;font-size: 9px; color: rgb(77, 77, 77);&quot;&gt;applications/view/system/__init__.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="496" y="250" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-58" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-55" target="oXrC6FassujB1rqgt1jG-57">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-55" value="&lt;div&gt;注册 文件上传 蓝图&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;font-size: 9px; color: rgb(77, 77, 77);&quot;&gt;applications/view/system/__init__.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="496" y="310" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-60" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;dashed=1;endArrow=none;endFill=0;dashPattern=1 4;strokeWidth=4;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="575.66" y="428" as="sourcePoint" />
<mxPoint x="575.66" y="478" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-57" value="&lt;div&gt;注册 系统监控 蓝图&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;font-size: 9px; color: rgb(77, 77, 77);&quot;&gt;applications/view/system/__init__.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="496" y="370" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-61" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-59" target="oXrC6FassujB1rqgt1jG-51">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-59" value="&lt;div&gt;注册 后台首页 蓝图&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;font-size: 9px; color: rgb(77, 77, 77);&quot;&gt;applications/view/system/__init__.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="496" y="550" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-62" value="&lt;div&gt;注册 启用插件所提供的 蓝图&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;font-size: 9px; color: rgb(77, 77, 77);&quot;&gt;plugins/*/__init__.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="496" y="670" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-65" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-64" target="oXrC6FassujB1rqgt1jG-59">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-64" value="&lt;div&gt;注册 部门管理 蓝图&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;font-size: 9px; color: rgb(77, 77, 77);&quot;&gt;applications/view/system/__init__.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="496" y="490" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-69" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=none;endFill=0;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-66" target="oXrC6FassujB1rqgt1jG-68">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-66" value="&lt;div&gt;注册 应用 cli 命令&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;font-size: 9px; color: rgb(77, 77, 77);&quot;&gt;applications/view/__init__.py&lt;/font&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="680" y="190" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-68" value="&lt;div&gt;广播插件&amp;nbsp;event_finish 事件&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgb(77, 77, 77); font-size: 9px;&quot;&gt;applications/view/__init__.py&lt;/span&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;dashed=1;" vertex="1" parent="1">
<mxGeometry x="680" y="250" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-81" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=none;endFill=0;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-71" target="oXrC6FassujB1rqgt1jG-80">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-71" value="&lt;div&gt;初始化完成&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="700" y="310" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-75" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-72" target="oXrC6FassujB1rqgt1jG-1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-72" value="&lt;div&gt;初始化开始&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;" vertex="1" parent="1">
<mxGeometry x="-20" y="310" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-78" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;dashed=1;strokeColor=#007FFF;strokeWidth=2;" vertex="1" parent="1">
<mxGeometry x="490" y="245" width="172" height="355" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-79" value="&lt;font style=&quot;color: rgb(0, 127, 255);&quot;&gt;注册项目的视图函数,&lt;/font&gt;&lt;div&gt;&lt;font style=&quot;color: rgb(0, 127, 255);&quot;&gt;比如用户管理、文件上传等&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;color: rgb(0, 127, 255);&quot;&gt;功能都是在这里初始化的&lt;/font&gt;&lt;/div&gt;" style="text;html=1;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="720" y="550" width="160" height="60" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-80" value="&lt;div&gt;广播插件&amp;nbsp;event_context 事件&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=center;dashed=1;" vertex="1" parent="1">
<mxGeometry x="680" y="370" width="160" height="40" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-82" value="&lt;font style=&quot;color: rgb(153, 153, 153);&quot;&gt;等同于 with app.app_context()&lt;/font&gt;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="800" y="430" width="170" height="30" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-84" value="&lt;font style=&quot;color: rgb(255, 128, 0);&quot;&gt;flask admin init 数据库&lt;/font&gt;&lt;div&gt;&lt;font style=&quot;color: rgb(255, 128, 0);&quot;&gt;初始化的&lt;span style=&quot;background-color: transparent;&quot;&gt;命令是在这里注册的&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;strokeColor=none;strokeWidth=1;" vertex="1" parent="1">
<mxGeometry x="880" y="230" width="170" height="30" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-86" value="" style="endArrow=none;html=1;rounded=0;dashed=1;endFill=0;entryX=0;entryY=0.25;entryDx=0;entryDy=0;strokeColor=#FF8000;" edge="1" parent="1" target="oXrC6FassujB1rqgt1jG-84">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="840" y="210" as="sourcePoint" />
<mxPoint x="880" y="240" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-88" value="" style="endArrow=none;html=1;rounded=0;dashed=1;endFill=0;strokeColor=#999999;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="840" y="412.5" as="sourcePoint" />
<mxPoint x="873" y="432.5" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-89" value="" style="endArrow=none;html=1;rounded=0;dashed=1;endFill=0;strokeColor=#007FFF;exitX=1;exitY=0.75;exitDx=0;exitDy=0;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-78">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="670" y="520" as="sourcePoint" />
<mxPoint x="720" y="550" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-90" value="&lt;font style=&quot;color: rgb(0, 153, 0);&quot;&gt;开发插件的蓝图在这里注册&lt;/font&gt;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="700" y="650" width="150" height="30" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-92" value="" style="endArrow=none;html=1;rounded=0;dashed=1;endFill=0;strokeColor=#009900;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="662" y="630" as="sourcePoint" />
<mxPoint x="720" y="649" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-93" value="&lt;font style=&quot;color: rgb(150, 150, 150);&quot;&gt;默认读取的是&lt;/font&gt;&lt;div&gt;&lt;font style=&quot;color: rgb(150, 150, 150);&quot;&gt;&amp;nbsp;BaseConfig 类中的配置。&lt;/font&gt;&lt;div&gt;&lt;span style=&quot;background-color: transparent; color: light-dark(rgb(150, 150, 150), rgb(108, 108, 108));&quot;&gt;修改其他类请先在文件&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;font style=&quot;color: rgb(150, 150, 150);&quot;&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;applications/__init__.py&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font style=&quot;color: rgb(150, 150, 150);&quot;&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;中进行修改&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="125" y="260" width="145" height="90" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-95" value="" style="endArrow=none;html=1;rounded=0;dashed=1;endFill=0;strokeColor=#999999;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-22" target="oXrC6FassujB1rqgt1jG-93">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="200" y="240" as="sourcePoint" />
<mxPoint x="233" y="260" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-96" value="&lt;font style=&quot;color: rgb(204, 0, 0);&quot;&gt;404 500 等请求、服务器错误的视图会在这里注册&lt;/font&gt;" style="text;html=1;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="130" y="620" width="140" height="60" as="geometry" />
</mxCell>
<mxCell id="oXrC6FassujB1rqgt1jG-97" value="" style="endArrow=none;html=1;rounded=0;dashed=1;endFill=0;strokeColor=#CC0000;exitX=0.709;exitY=0.962;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitPerimeter=0;" edge="1" parent="1" source="oXrC6FassujB1rqgt1jG-96" target="oXrC6FassujB1rqgt1jG-39">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="240" y="670" as="sourcePoint" />
<mxPoint x="298" y="709" as="targetPoint" />
</mxGeometry>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
Binary file not shown.

After

Width:  |  Height:  |  Size: 827 KiB

+27
View File
@@ -0,0 +1,27 @@
后端页面编写
======================
该章节将介绍如何在 Pear Admin Flask 中编写一个新后端页面,此章节将会以编写积分兑奖系统为例,编写一个兑换码管理的后台页面。
.. _项目初始化逻辑:
项目初始化逻辑
-----------------------
我们知道,一个简单的 Flask 项目是从 `app = Flask(__name__)` 开始的,而 Pear Admin Flask 的初始化的逻辑同理也是在此基础上,不过稍加复杂了一点。
下面这张图片将会揭示项目初始化的逻辑。(点击可查看大图)
|
.. image:: ../_static/Pear\ Admin\ Flask\ 启动流程图.png
:target: ../_static/Pear\ Admin\ Flask\ 启动流程图.png
:align: center
|
由此可以看出,我们想要添加自己的后端页面,可以在 “注册项目的视图函数”(蓝框) 的地方添加,当然,同样页面可以作为插件的方式接入以提高项目的拓展性。
下面将介绍如何在这两种方式下添加自己的后台页面。
+1
View File
@@ -8,3 +8,4 @@
plugin
trick
frontend
backend
+5
View File
@@ -133,8 +133,13 @@
pass
def event_context(app: Flask): # Flask 初始化完成,等待第一个请求之前,等同于 with app.app_context():
# 此时数据库已经初始化完成,尝试读取
pass
.. note::
事件的时机调用可以参考 :ref:`项目初始化逻辑` 章节。
.. important::
注意不要直接在 `__init__.py` 的函数外直接写存在阻塞的代码,不然项目 Flask 将不能初始化完成。
+6 -1
View File
@@ -35,6 +35,11 @@
使用不同的数据库需要安装另外的库,比如 mysql 要安装 pymysql 库(不同平台可能名称不一样),请自行查询资料而后进行配置。
添加后台菜单
------------
在 Pear Admin Flask 中,菜单的管理归属于 “权限管理” ,这样做的原因是为了使不同用户可以使用不同的访问控制。所以需要修改菜单,需要在 “权限管理” 页面编辑即可。
权限效验
------------
@@ -186,7 +191,7 @@ Schema 序列化
详情查看 :ref:`JSON 响应正文生成模块` 章节。
发送
发送
-----------------------
程序提供了发送邮件的模块,前提是需要正确在 `applications/config.py` 中配置 SMTP 服务器。详情查看 ref:`邮件模块` 章节。
+1 -1
View File
@@ -27,7 +27,7 @@
<p align="center">
<a href="#">
<img src="https://img.shields.io/badge/pear%20admin%20flask-1.0.0-green" alt="Pear Admin Layui Version">
<img src="https://img.shields.io/badge/pear%20admin%20flask-2.0.0-green" alt="Pear Admin Layui Version">
</a>
<a href="#">
<img src="https://img.shields.io/badge/Python-3.8+-green.svg" alt="Python Version">
+17
View File
@@ -111,3 +111,20 @@
.. code-block:: python
from applications.common.admin import admin_log
验证码生成路由修改
~~~~~~~~~~~~~~~~~~~~~~~~
为了优化代码,将验证码生成路由改为了 system.passport.captcha 。这主要会影响前端模板渲染。
例如:
.. code-block:: html
url_for('system.passport.get_captcha')
改为:
.. code-block:: python
url_for('system.passport.captcha')
+2
View File
@@ -40,6 +40,8 @@
* 更正登录之后重定向由于路由更改从而设置错误的问题
* 将 applications/common/admin_log.py 与 applications/common/admin.py 合并,仅留下 applications/common/admin.py
* 优化代码结构,新增函数 `normal_log` 减少代码复用
* 添加了新插件的事件
* 修改了验证码生成路由
已知问题以及解决方式
~~~~~~~~~~~~~~~~~~~~~~~
+2 -1
View File
@@ -32,7 +32,8 @@ def event_finish(app: Flask): # 在项目所有功能注册之后调用(插
def event_context(app: Flask): # Flask 初始化完成,等待第一个请求之前,等同于 with app.app_context():
print("第一个请求来之前加载")
# 数据库已经初始化完成,尝试读取
dept = Dept.query.order_by(Dept.sort).all()
power_data = curd.model_to_dicts(schema=DeptSchema, data=dept)
print(power_data)
# print(power_data)
+1 -1
View File
@@ -96,7 +96,7 @@
var popup = layui.popup;
let layer = layui.layer;
let $ = layui.jquery;
let captchaPath = "{{ url_for('system.passport.get_captcha') }}";
let captchaPath = "{{ url_for('system.passport.captcha') }}";
/**