# agent_menu_open.dspy - 通用功能弹窗:返回 PopupWindow,内嵌 urlwidget 加载目标 .ui # 供 AgentIO 上方功能菜单按钮用(按钮 actiontype=urlwidget 打开本 dspy,通过参数控制弹窗大小) # 参数:url(必填) title width height(百分比字符串,默认 85%/80%) # 注意:PopupWindow 用 width/height 百分比(cwidth/cheight 是字符单位,对列表页太小) import json url = (params_kw or {}).get('url', '') or '' title = (params_kw or {}).get('title', '') or '功能' width = (params_kw or {}).get('width', '') or '85%' height = (params_kw or {}).get('height', '') or '80%' if not url: return json.dumps({ "widgettype": "Text", "options": {"text": "缺少 url 参数", "cfontsize": 1, "color": "#64748b", "padding": "20px"} }, ensure_ascii=False) return json.dumps({ "widgettype": "PopupWindow", "options": {"title": title, "width": width, "height": height, "auto_open": True}, "subwidgets": [ {"widgettype": "urlwidget", "options": {"url": entire_url(url)}} ] }, ensure_ascii=False)