From cdd227d55001d9373b0b520c5ec4a82e6069903b Mon Sep 17 00:00:00 2001 From: sophie Date: Mon, 22 Jun 2026 16:24:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(admin):=20=E6=9B=B4=E6=96=B0=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=8E=A7=E5=88=B6=E5=8F=B0=E5=BA=94=E7=94=A8=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=B8=83=E5=B1=80=EF=BC=8C=E6=8A=BD=E7=A6=BB=E5=87=BA?= =?UTF-8?q?=E6=96=B0=E5=BB=BA=E7=BC=96=E8=BE=91=E5=BC=B9=E6=A1=86=E5=AD=90?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/modules/agents/AgentsPage.vue | 211 +++++------------- .../agents/components/AgentFormModal.vue | 189 ++++++++++++++++ .../agents/composables/useAgentsAdmin.ts | 13 +- 3 files changed, 261 insertions(+), 152 deletions(-) create mode 100644 frontend/src/features/admin/modules/agents/components/AgentFormModal.vue diff --git a/frontend/src/features/admin/modules/agents/AgentsPage.vue b/frontend/src/features/admin/modules/agents/AgentsPage.vue index 177861bd..8011c1bf 100644 --- a/frontend/src/features/admin/modules/agents/AgentsPage.vue +++ b/frontend/src/features/admin/modules/agents/AgentsPage.vue @@ -1,18 +1,19 @@ /** * features/admin/modules/agents/AgentsPage.vue * - * Agent 管理独立页面(Phase 1 首个拆分模块)。 - * 路由:/admin/agents + * 用途:管理控制台的应用管理页,提供应用列表、创建/编辑弹窗、测试与授权入口。 + * 依赖:useAgentsAdmin 业务编排、AgentFormModal/AgentTestModal/AgentPermissionModal 弹窗。 + * 逻辑:页面加载后拉取应用/用户/排程数据;主区域展示应用列表,新增和编辑通过弹窗表单完成。 */ + + diff --git a/frontend/src/features/admin/modules/agents/composables/useAgentsAdmin.ts b/frontend/src/features/admin/modules/agents/composables/useAgentsAdmin.ts index 3df94732..d9c4efef 100644 --- a/frontend/src/features/admin/modules/agents/composables/useAgentsAdmin.ts +++ b/frontend/src/features/admin/modules/agents/composables/useAgentsAdmin.ts @@ -205,15 +205,20 @@ export function useAgentsAdmin() { } }; - const submitAgent = async (): Promise => { + /** + * 提交应用创建或编辑表单,并向页面反馈是否成功。 + * 核心逻辑:先做必填与能力配置校验,再按编辑态调用新增/更新接口;成功后刷新列表并同步当前表单状态。 + * @returns true 表示保存成功,false 表示校验或接口失败,调用方可据此决定是否关闭弹窗。 + */ + const submitAgent = async (): Promise => { if (!form.value.name) { msg.warning(t('admin.dept.msg.nameRequired')); - return; + return false; } const supportsToolRunProgress = form.value.type === 'api' && form.value.dify_app_type !== 'workflow'; if (supportsToolRunProgress && form.value.tool_run_progress_enabled && !form.value.schedule_task_id) { msg.warning(t('admin.agent.toolRunProgress.scheduleTaskRequired')); - return; + return false; } isSaving.value = true; @@ -285,9 +290,11 @@ export function useAgentsAdmin() { } else { resetForm(); } + return true; } catch (e) { console.error(e); msg.error((e as Error).message || t('admin.msg.requestFailed')); + return false; } finally { isSaving.value = false; }