- app/portal.py: 主入口,通过from cms.init import load_cms加载业务模块 - conf/config.json: 应用配置(ocai_cms数据库, 端口9090, cms模块wwwroot挂载到/cms) - wwwroot/: 公开页面(index/news/cases/products)和公开API - build.sh: 构建脚本(安装基础设施包+pip install cms模块+DDL/CRUD生成) - deploy.sh: 一键部署脚本(构建→建表→初始数据→权限→启动) - init_data.py: 从cms模块init/data.yaml加载初始数据 - init_any/superuser_permissions.py: RBAC权限初始化
57 lines
1.4 KiB
Python
57 lines
1.4 KiB
Python
"""
|
|
Portal全局函数 — 注册到ServerEnv供.dspy和.ui调用
|
|
"""
|
|
from ahserver.serverenv import ServerEnv
|
|
|
|
def get_module_dbname(mname):
|
|
"""Portal应用统一使用ocai_cms数据库"""
|
|
return 'ocai_cms'
|
|
|
|
def UiWindow(title, icon, content, cheight=10, cwidth=15):
|
|
return {
|
|
"widgettype": "PopupWindow",
|
|
"options": {
|
|
"author": "portal",
|
|
"cwidth": cwidth,
|
|
"cheight": cheight,
|
|
"title": title,
|
|
"content": content,
|
|
"icon": icon or entire_url('/bricks/imgs/app.png'),
|
|
"movable": True,
|
|
"auto_open": True
|
|
}
|
|
}
|
|
|
|
def UiError(title="出错", message="出错啦", timeout=5):
|
|
return {
|
|
"widgettype": "Error",
|
|
"options": {
|
|
"author": "portal",
|
|
"timeout": timeout,
|
|
"cwidth": 15,
|
|
"cheight": 10,
|
|
"title": title,
|
|
"message": message
|
|
}
|
|
}
|
|
|
|
def UiMessage(title="消息", message="后台消息", timeout=5):
|
|
return {
|
|
"widgettype": "Message",
|
|
"options": {
|
|
"author": "portal",
|
|
"timeout": timeout,
|
|
"cwidth": 15,
|
|
"cheight": 10,
|
|
"title": title,
|
|
"message": message
|
|
}
|
|
}
|
|
|
|
def set_globalvariable():
|
|
g = ServerEnv()
|
|
g.get_module_dbname = get_module_dbname
|
|
g.UiError = UiError
|
|
g.UiMessage = UiMessage
|
|
g.UiWindow = UiWindow
|