From b62390ccdeb75edc46ff9f7bb2798cc0f8e0cf13 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 16 Aug 2026 18:34:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8A=9F=E8=83=BD=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E6=94=B9urlwidget=E4=BA=8B=E4=BB=B6+?= =?UTF-8?q?=E9=80=9A=E7=94=A8=E5=BC=B9=E7=AA=97agent=5Fmenu=5Fopen?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=A4=A7=E5=B0=8F+=E5=9B=BA=E5=AE=9A?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=A9=BA=E9=97=B4=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/api/agent_menu_open.dspy | 33 ++++++++++++++++++++++++++++++++ wwwroot/api/agent_menus.dspy | 31 +++++++++++++++++++----------- 2 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 wwwroot/api/agent_menu_open.dspy diff --git a/wwwroot/api/agent_menu_open.dspy b/wwwroot/api/agent_menu_open.dspy new file mode 100644 index 0000000..ac90b9c --- /dev/null +++ b/wwwroot/api/agent_menu_open.dspy @@ -0,0 +1,33 @@ +# 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) diff --git a/wwwroot/api/agent_menus.dspy b/wwwroot/api/agent_menus.dspy index caaa59a..aea96de 100644 --- a/wwwroot/api/agent_menus.dspy +++ b/wwwroot/api/agent_menus.dspy @@ -38,30 +38,39 @@ try: except Exception: menus = [] -# 3. 构建菜单按钮(点击 → Popup 打开功能 .ui) +# 3. 构建菜单按钮(actiontype=urlwidget 打开通用弹窗 agent_menu_open,控制弹窗大小) +import urllib.parse as _urlparse + buttons = [] + +# 固定「工作空间」按钮(通用能力,所有 agent 都有) +buttons.append({ + "widgettype": "Button", + "options": {"label": "🗂 工作空间", "css": "small", "id": "menu_btn_ws"}, + "binds": [{ + "wid": "self", "event": "click", "actiontype": "urlwidget", + "target": "self", "options": {"url": "/pipeline-sdlc/api/workspace_popup.dspy"}, + }], +}) + for i, m in enumerate(menus): label = str(m.get("label", "") or "") url = str(m.get("url", "") or "") if not url: continue - script = ( - "var pw=new bricks.PopupWindow({title:" + _json.dumps(label) + - ",cwidth:62,cheight:32,auto_open:true});" - "pw.content_w.add_widget(new bricks.urlwidget({url:" + _json.dumps(url) + "}));" - ) + cwidth = str(m.get("cwidth", "62") or "62") + cheight = str(m.get("cheight", "32") or "32") + query = _urlparse.urlencode({"url": url, "title": label, "cwidth": cwidth, "cheight": cheight}) + open_url = "/pipeline_core/api/agent_menu_open.dspy?" + query buttons.append({ "widgettype": "Button", "options": {"label": label, "css": "small", "id": "menu_btn_%d" % i}, "binds": [{ - "wid": "self", "event": "click", "actiontype": "script", - "target": "self", "script": script, + "wid": "self", "event": "click", "actiontype": "urlwidget", + "target": "self", "options": {"url": open_url}, }], }) -if not buttons: - return _json.dumps({"widgettype": "HBox", "options": {"cheight": 0}, "subwidgets": []}) - return _json.dumps({ "widgettype": "HBox", "options": {"width": "100%", "padding": "0 24px 8px 24px", "gap": "8px", "alignItems": "center"},