diff --git a/dashboard/src/routes/config/bot.tsx b/dashboard/src/routes/config/bot.tsx index ece9c37d..0deac66a 100644 --- a/dashboard/src/routes/config/bot.tsx +++ b/dashboard/src/routes/config/bot.tsx @@ -69,6 +69,11 @@ import { useAutoSave, useConfigAutoSave } from './bot/hooks' import { useCallback, useEffect, useRef, useState } from 'react' import { Button } from '@/components/ui/button' +// 导入动态表单和 Hook 系统 +import { DynamicConfigForm } from '@/components/dynamic-form' +import { fieldHooks } from '@/lib/field-hooks' +import { ChatSectionHook } from '@/routes/config/bot/hooks' + // ==================== 常量定义 ==================== /** Toast 显示前的延迟时间 (毫秒) */ const TOAST_DISPLAY_DELAY = 500 @@ -308,6 +313,13 @@ function BotConfigPageContent() { loadConfig() }, [loadConfig]) + useEffect(() => { + fieldHooks.register('chat', ChatSectionHook, 'replace') + return () => { + fieldHooks.unregister('chat') + } + }, []) + // 使用模块化的 useAutoSave hook const { triggerAutoSave, cancelPendingAutoSave } = useAutoSave( initialLoadRef.current, @@ -652,7 +664,24 @@ function BotConfigPageContent() { {/* 聊天配置 */} - {chatConfig && } + {chatConfig && ( + { + if (field === 'chat') { + setChatConfig(value as ChatConfig) + setHasUnsavedChanges(true) + } + }} + hooks={fieldHooks} + /> + )} {/* 表达配置 */}