feat: 功能菜单按钮改urlwidget事件+通用弹窗agent_menu_open控制大小+固定工作空间按钮

This commit is contained in:
yumoqing 2026-08-16 18:34:10 +08:00
parent c55a01241b
commit b62390ccde
2 changed files with 53 additions and 11 deletions

View File

@ -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)

View File

@ -38,30 +38,39 @@ try:
except Exception: except Exception:
menus = [] menus = []
# 3. 构建菜单按钮(点击 → Popup 打开功能 .ui) # 3. 构建菜单按钮(actiontype=urlwidget 打开通用弹窗 agent_menu_open,控制弹窗大小)
import urllib.parse as _urlparse
buttons = [] 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): for i, m in enumerate(menus):
label = str(m.get("label", "") or "") label = str(m.get("label", "") or "")
url = str(m.get("url", "") or "") url = str(m.get("url", "") or "")
if not url: if not url:
continue continue
script = ( cwidth = str(m.get("cwidth", "62") or "62")
"var pw=new bricks.PopupWindow({title:" + _json.dumps(label) + cheight = str(m.get("cheight", "32") or "32")
",cwidth:62,cheight:32,auto_open:true});" query = _urlparse.urlencode({"url": url, "title": label, "cwidth": cwidth, "cheight": cheight})
"pw.content_w.add_widget(new bricks.urlwidget({url:" + _json.dumps(url) + "}));" open_url = "/pipeline_core/api/agent_menu_open.dspy?" + query
)
buttons.append({ buttons.append({
"widgettype": "Button", "widgettype": "Button",
"options": {"label": label, "css": "small", "id": "menu_btn_%d" % i}, "options": {"label": label, "css": "small", "id": "menu_btn_%d" % i},
"binds": [{ "binds": [{
"wid": "self", "event": "click", "actiontype": "script", "wid": "self", "event": "click", "actiontype": "urlwidget",
"target": "self", "script": script, "target": "self", "options": {"url": open_url},
}], }],
}) })
if not buttons:
return _json.dumps({"widgettype": "HBox", "options": {"cheight": 0}, "subwidgets": []})
return _json.dumps({ return _json.dumps({
"widgettype": "HBox", "widgettype": "HBox",
"options": {"width": "100%", "padding": "0 24px 8px 24px", "gap": "8px", "alignItems": "center"}, "options": {"width": "100%", "padding": "0 24px 8px 24px", "gap": "8px", "alignItems": "center"},