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; }