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 弹窗。 + * 逻辑:页面加载后拉取应用/用户/排程数据;主区域展示应用列表,新增和编辑通过弹窗表单完成。 */ + + + + + + + {{ isEditing ? t('admin.agent.edit') : t('admin.agent.create') }} + {{ t('admin.agent.subtitle') }} + + + + + + + + + + {{ t('admin.agent.fields.name') }} + + + + {{ t('admin.agent.fields.type') }} + + {{ t('admin.agent.fields.types.api') }} + {{ t('admin.agent.fields.types.iframe') }} + + + + + + Dify应用类型 + + Chatflow + Workflow + + + + {{ t('admin.agent.fields.appId') }} + + + + {{ t('admin.agent.fields.baseUrl') }} + + + + {{ t('admin.agent.fields.apiKey') }} + + + + + + + {{ t('admin.agent.fields.iframeUrl') }} + + + + + + {{ t('admin.agent.fields.description') }} + + + + + + 常见问题 + + + 添加问题 + + + + + + + 无样式 + + + + 有样式 + + + + + 暂未配置常见问题,点击“添加问题”后会同步到对应 Agent 的 Chat 欢迎页。 + + + + + + + + + + + + + + + + + + + + + + {{ t('admin.cancel') }} + + + + {{ isEditing ? t('admin.update') : t('admin.add') }} + + + + + 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; }
{{ t('admin.agent.subtitle') }}