From 349752b47372e966e8e9329b7eb31bc3479cb711 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 22 Aug 2026 18:55:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(agent):=20=E4=BA=A7=E7=BA=BF=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E8=8F=9C=E5=8D=95=E6=8C=89=20require=5Fproject=20?= =?UTF-8?q?=E6=A0=87=E8=AE=B0=EF=BC=8C=E6=97=A0=E4=BC=9A=E8=AF=9D=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E9=A1=B9=E7=9B=AE=E6=97=B6=E7=82=B9=E5=87=BB=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/api/agent_menus.dspy | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/wwwroot/api/agent_menus.dspy b/wwwroot/api/agent_menus.dspy index c70c394..6c3009e 100644 --- a/wwwroot/api/agent_menus.dspy +++ b/wwwroot/api/agent_menus.dspy @@ -9,6 +9,7 @@ if not uid: # 1. 解析当前产线:用户当前项目 → sd_projects.pipeline_id pipeline_id = '' +pid = '' try: dbname = get_module_dbname('pipeline_core') async with DBPools().sqlorContext(dbname) as sor: @@ -45,14 +46,25 @@ except Exception: buttons = [] -# 固定「工作空间」按钮(通用能力,所有 agent 都有) +# 无当前项目时,点击「需要项目」的按钮弹报错(不打开页面) +_no_proj_script = "var m=new bricks.Message({title:'提示',message:'请先在会话中切换项目'});m.open();" + +def _bind(url, require_project): + if require_project and not pid: + return { + "wid": "self", "event": "click", "actiontype": "script", "target": "self", + "script": _no_proj_script, + } + return { + "wid": "self", "event": "click", "actiontype": "urlwidget", + "target": "self", "options": {"url": url}, + } + +# 固定「工作空间」按钮(通用能力,所有 agent 都有;依赖当前项目) buttons.append({ "widgettype": "Button", "options": {"label": "🗂 工作空间", "css": "small", "id": "menu_btn_ws"}, - "binds": [{ - "wid": "self", "event": "click", "actiontype": "urlwidget", - "target": "self", "options": {"url": entire_url("/pipeline-sdlc/api/workspace_popup.dspy")}, - }], + "binds": [_bind(entire_url("/pipeline-sdlc/api/workspace_popup.dspy"), True)], }) for i, m in enumerate(menus): @@ -60,16 +72,14 @@ for i, m in enumerate(menus): url = str(m.get("url", "") or "") if not url: continue + require_project = bool(m.get("require_project", False)) width = str(m.get("width", "85%") or "85%") height = str(m.get("height", "80%") or "80%") open_url = entire_url("/pipeline_core/api/agent_menu_open.dspy") + "?url=" + url + "&title=" + label + "&width=" + width + "&height=" + height buttons.append({ "widgettype": "Button", "options": {"label": label, "css": "small", "id": "menu_btn_%d" % i}, - "binds": [{ - "wid": "self", "event": "click", "actiontype": "urlwidget", - "target": "self", "options": {"url": open_url}, - }], + "binds": [_bind(open_url, require_project)], }) return _json.dumps({