更新文档,完善插件功能

This commit is contained in:
wojiaoyishang
2025-01-27 21:34:42 +08:00
parent feed91dcd0
commit da5917344e
10 changed files with 119 additions and 41 deletions
+5
View File
@@ -0,0 +1,5 @@
{
"plugin_name": "Hello World",
"plugin_version": "1.0.0.1",
"plugin_description": "一个测试的插件。"
}
+22
View File
@@ -6,11 +6,33 @@ import os
from flask import Flask
from .main import helloworld_blueprint
from applications.models import Dept
from applications.common import curd
from applications.schemas import DeptSchema
# 获取插件所在的目录(结尾没有分割符号)
dir_path = os.path.dirname(__file__).replace("\\", "/")
folder_name = dir_path[dir_path.rfind("/") + 1:] # 插件文件夹名称
def event_begin(app: Flask): # 在项目所有功能注册之前调用
print("所有功能初始化之前加载")
def event_init(app: Flask):
"""初始化完成时会调用这里"""
print("初始插件初始化视图")
app.register_blueprint(helloworld_blueprint)
def event_finish(app: Flask): # 在项目所有功能注册之后调用(插件已经加载完毕)
print("所有初始化完毕")
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)