pipeline_core/wwwroot/api/agent_menu_open.dspy

34 lines
1.0 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# agent_menu_open.dspy - 通用功能弹窗:返回 PopupWindow,内嵌 urlwidget 加载目标 .ui
# 供 AgentIO 上方功能菜单按钮用(按钮 actiontype=urlwidget 打开本 dspy,通过参数控制弹窗大小)
# 参数:url(必填) title cwidth cheight
import json
url = (params_kw or {}).get('url', '') or ''
title = (params_kw or {}).get('title', '') or '功能'
cwidth = (params_kw or {}).get('cwidth', '') or '62'
cheight = (params_kw or {}).get('cheight', '') or '32'
if not url:
return json.dumps({
"widgettype": "Text",
"options": {"text": "缺少 url 参数", "cfontsize": 1, "color": "#64748b", "padding": "20px"}
}, ensure_ascii=False)
try:
cw = float(cwidth)
except Exception:
cw = 62
try:
ch = float(cheight)
except Exception:
ch = 32
return json.dumps({
"widgettype": "PopupWindow",
"options": {"title": title, "cwidth": cw, "cheight": ch, "auto_open": True},
"subwidgets": [
{"widgettype": "urlwidget", "options": {"url": url}}
]
}, ensure_ascii=False)