feat: 提取常量配置
This commit is contained in:
@@ -92,281 +92,22 @@ import {
|
||||
Users,
|
||||
} from 'lucide-react';
|
||||
|
||||
/**
|
||||
* Framer Motion 动画变体配置
|
||||
*/
|
||||
const animations = {
|
||||
slideInLeft: {
|
||||
initial: { x: -320, opacity: 0 },
|
||||
animate: {
|
||||
x: 0,
|
||||
opacity: 1,
|
||||
transition: {
|
||||
type: 'spring',
|
||||
stiffness: 300,
|
||||
damping: 30,
|
||||
},
|
||||
},
|
||||
exit: {
|
||||
x: -320,
|
||||
opacity: 0,
|
||||
transition: { duration: 0.2 },
|
||||
},
|
||||
},
|
||||
slideInRight: {
|
||||
initial: { x: 320, opacity: 0 },
|
||||
animate: {
|
||||
x: 0,
|
||||
opacity: 1,
|
||||
transition: {
|
||||
type: 'spring',
|
||||
stiffness: 300,
|
||||
damping: 30,
|
||||
},
|
||||
},
|
||||
exit: {
|
||||
x: 320,
|
||||
opacity: 0,
|
||||
transition: { duration: 0.2 },
|
||||
},
|
||||
},
|
||||
fadeInUp: {
|
||||
initial: { opacity: 0, y: 20 },
|
||||
animate: {
|
||||
opacity: 1,
|
||||
y: 0,
|
||||
transition: {
|
||||
type: 'spring',
|
||||
stiffness: 400,
|
||||
damping: 25,
|
||||
},
|
||||
},
|
||||
},
|
||||
staggerItem: {
|
||||
initial: { opacity: 0, y: 10 },
|
||||
animate: { opacity: 1, y: 0 },
|
||||
},
|
||||
staggerContainer: {
|
||||
animate: {
|
||||
transition: {
|
||||
staggerChildren: 0.05,
|
||||
},
|
||||
},
|
||||
},
|
||||
pressScale: {
|
||||
whileTap: { scale: 0.95 },
|
||||
whileHover: { scale: 1.05 },
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
const MessageTypes = {
|
||||
USER: 'user',
|
||||
AGENT_THINKING: 'agent_thinking',
|
||||
AGENT_PLAN: 'agent_plan',
|
||||
AGENT_EXECUTING: 'agent_executing',
|
||||
AGENT_RESPONSE: 'agent_response',
|
||||
ERROR: 'error',
|
||||
};
|
||||
|
||||
/**
|
||||
* 可用模型配置
|
||||
*/
|
||||
const AVAILABLE_MODELS = [
|
||||
{
|
||||
id: 'kimi-k2-thinking',
|
||||
name: 'Kimi K2 Thinking',
|
||||
description: '深度思考模型,适合复杂分析',
|
||||
icon: <Brain className="w-5 h-5" />,
|
||||
color: 'purple',
|
||||
},
|
||||
{
|
||||
id: 'kimi-k2',
|
||||
name: 'Kimi K2',
|
||||
description: '快速响应模型,适合简单查询',
|
||||
icon: <Zap className="w-5 h-5" />,
|
||||
color: 'blue',
|
||||
},
|
||||
{
|
||||
id: 'deepmoney',
|
||||
name: 'DeepMoney',
|
||||
description: '金融专业模型',
|
||||
icon: <TrendingUp className="w-5 h-5" />,
|
||||
color: 'green',
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* MCP 工具配置(完整列表)
|
||||
*/
|
||||
const MCP_TOOLS = [
|
||||
// 新闻搜索类
|
||||
{
|
||||
id: 'search_news',
|
||||
name: '全球新闻搜索',
|
||||
icon: <Globe className="w-4 h-4" />,
|
||||
category: '新闻资讯',
|
||||
description: '搜索全球新闻,支持关键词和日期过滤'
|
||||
},
|
||||
{
|
||||
id: 'search_china_news',
|
||||
name: '中国新闻搜索',
|
||||
icon: <Newspaper className="w-4 h-4" />,
|
||||
category: '新闻资讯',
|
||||
description: 'KNN语义搜索中国新闻'
|
||||
},
|
||||
{
|
||||
id: 'search_medical_news',
|
||||
name: '医疗健康新闻',
|
||||
icon: <Activity className="w-4 h-4" />,
|
||||
category: '新闻资讯',
|
||||
description: '医药、医疗设备、生物技术新闻'
|
||||
},
|
||||
|
||||
// 概念板块类
|
||||
{
|
||||
id: 'search_concepts',
|
||||
name: '概念板块搜索',
|
||||
icon: <PieChart className="w-4 h-4" />,
|
||||
category: '概念板块',
|
||||
description: '搜索股票概念板块及相关股票'
|
||||
},
|
||||
{
|
||||
id: 'get_concept_details',
|
||||
name: '概念详情',
|
||||
icon: <FileText className="w-4 h-4" />,
|
||||
category: '概念板块',
|
||||
description: '获取概念板块详细信息'
|
||||
},
|
||||
{
|
||||
id: 'get_stock_concepts',
|
||||
name: '股票概念',
|
||||
icon: <BarChart3 className="w-4 h-4" />,
|
||||
category: '概念板块',
|
||||
description: '查询股票相关概念板块'
|
||||
},
|
||||
{
|
||||
id: 'get_concept_statistics',
|
||||
name: '概念统计',
|
||||
icon: <LineChart className="w-4 h-4" />,
|
||||
category: '概念板块',
|
||||
description: '涨幅榜、跌幅榜、活跃榜等'
|
||||
},
|
||||
|
||||
// 涨停分析类
|
||||
{
|
||||
id: 'search_limit_up_stocks',
|
||||
name: '涨停股票搜索',
|
||||
icon: <TrendingUp className="w-4 h-4" />,
|
||||
category: '涨停分析',
|
||||
description: '搜索涨停股票,支持多条件筛选'
|
||||
},
|
||||
{
|
||||
id: 'get_daily_stock_analysis',
|
||||
name: '涨停日报',
|
||||
icon: <Calendar className="w-4 h-4" />,
|
||||
category: '涨停分析',
|
||||
description: '每日涨停股票分析报告'
|
||||
},
|
||||
|
||||
// 研报路演类
|
||||
{
|
||||
id: 'search_research_reports',
|
||||
name: '研报搜索',
|
||||
icon: <BookOpen className="w-4 h-4" />,
|
||||
category: '研报路演',
|
||||
description: '搜索研究报告,支持语义搜索'
|
||||
},
|
||||
{
|
||||
id: 'search_roadshows',
|
||||
name: '路演活动',
|
||||
icon: <Briefcase className="w-4 h-4" />,
|
||||
category: '研报路演',
|
||||
description: '上市公司路演、投资者交流活动'
|
||||
},
|
||||
|
||||
// 股票数据类
|
||||
{
|
||||
id: 'get_stock_basic_info',
|
||||
name: '股票基本信息',
|
||||
icon: <FileText className="w-4 h-4" />,
|
||||
category: '股票数据',
|
||||
description: '公司名称、行业、主营业务等'
|
||||
},
|
||||
{
|
||||
id: 'get_stock_financial_index',
|
||||
name: '财务指标',
|
||||
icon: <DollarSign className="w-4 h-4" />,
|
||||
category: '股票数据',
|
||||
description: 'EPS、ROE、营收增长率等'
|
||||
},
|
||||
{
|
||||
id: 'get_stock_trade_data',
|
||||
name: '交易数据',
|
||||
icon: <BarChart3 className="w-4 h-4" />,
|
||||
category: '股票数据',
|
||||
description: '价格、成交量、涨跌幅等'
|
||||
},
|
||||
{
|
||||
id: 'get_stock_balance_sheet',
|
||||
name: '资产负债表',
|
||||
icon: <PieChart className="w-4 h-4" />,
|
||||
category: '股票数据',
|
||||
description: '资产、负债、所有者权益'
|
||||
},
|
||||
{
|
||||
id: 'get_stock_cashflow',
|
||||
name: '现金流量表',
|
||||
icon: <LineChart className="w-4 h-4" />,
|
||||
category: '股票数据',
|
||||
description: '经营、投资、筹资现金流'
|
||||
},
|
||||
{
|
||||
id: 'search_stocks_by_criteria',
|
||||
name: '条件选股',
|
||||
icon: <Search className="w-4 h-4" />,
|
||||
category: '股票数据',
|
||||
description: '按行业、地区、市值筛选'
|
||||
},
|
||||
{
|
||||
id: 'get_stock_comparison',
|
||||
name: '股票对比',
|
||||
icon: <BarChart3 className="w-4 h-4" />,
|
||||
category: '股票数据',
|
||||
description: '多只股票财务指标对比'
|
||||
},
|
||||
|
||||
// 用户数据类
|
||||
{
|
||||
id: 'get_user_watchlist',
|
||||
name: '自选股列表',
|
||||
icon: <Users className="w-4 h-4" />,
|
||||
category: '用户数据',
|
||||
description: '用户关注的股票及行情'
|
||||
},
|
||||
{
|
||||
id: 'get_user_following_events',
|
||||
name: '关注事件',
|
||||
icon: <Activity className="w-4 h-4" />,
|
||||
category: '用户数据',
|
||||
description: '用户关注的重大事件'
|
||||
},
|
||||
];
|
||||
|
||||
// 按类别分组工具
|
||||
const TOOL_CATEGORIES = {
|
||||
'新闻资讯': MCP_TOOLS.filter(t => t.category === '新闻资讯'),
|
||||
'概念板块': MCP_TOOLS.filter(t => t.category === '概念板块'),
|
||||
'涨停分析': MCP_TOOLS.filter(t => t.category === '涨停分析'),
|
||||
'研报路演': MCP_TOOLS.filter(t => t.category === '研报路演'),
|
||||
'股票数据': MCP_TOOLS.filter(t => t.category === '股票数据'),
|
||||
'用户数据': MCP_TOOLS.filter(t => t.category === '用户数据'),
|
||||
};
|
||||
// 常量配置 - 从 TypeScript 模块导入
|
||||
import { animations } from './constants/animations';
|
||||
import { MessageTypes } from './constants/messageTypes';
|
||||
import { AVAILABLE_MODELS, DEFAULT_MODEL_ID } from './constants/models';
|
||||
import { MCP_TOOLS, TOOL_CATEGORIES, DEFAULT_SELECTED_TOOLS } from './constants/tools';
|
||||
import { quickQuestions } from './constants/quickQuestions';
|
||||
|
||||
/**
|
||||
* Agent Chat - 主组件(HeroUI v3 深色主题)
|
||||
*
|
||||
* 注意:所有常量配置已提取到 constants/ 目录:
|
||||
* - animations: constants/animations.ts
|
||||
* - MessageTypes: constants/messageTypes.ts
|
||||
* - AVAILABLE_MODELS: constants/models.ts
|
||||
* - MCP_TOOLS, TOOL_CATEGORIES: constants/tools.ts
|
||||
* - quickQuestions: constants/quickQuestions.ts
|
||||
*/
|
||||
const AgentChat = () => {
|
||||
const { user } = useAuth();
|
||||
@@ -385,14 +126,8 @@ const AgentChat = () => {
|
||||
|
||||
// UI 状态
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const [selectedModel, setSelectedModel] = useState('kimi-k2-thinking');
|
||||
const [selectedTools, setSelectedTools] = useState([
|
||||
'search_news',
|
||||
'search_china_news',
|
||||
'search_concepts',
|
||||
'search_limit_up_stocks',
|
||||
'search_research_reports',
|
||||
]);
|
||||
const [selectedModel, setSelectedModel] = useState(DEFAULT_MODEL_ID);
|
||||
const [selectedTools, setSelectedTools] = useState(DEFAULT_SELECTED_TOOLS);
|
||||
const [isLeftSidebarOpen, setIsLeftSidebarOpen] = useState(true);
|
||||
const [isRightSidebarOpen, setIsRightSidebarOpen] = useState(true);
|
||||
|
||||
@@ -666,16 +401,11 @@ const AgentChat = () => {
|
||||
)
|
||||
: sessions;
|
||||
|
||||
const quickQuestions = [
|
||||
{ text: '今日涨停板块分析', emoji: '🔥' },
|
||||
{ text: '新能源概念机会', emoji: '⚡' },
|
||||
{ text: '半导体行业动态', emoji: '💾' },
|
||||
{ text: '本周热门研报', emoji: '📊' },
|
||||
];
|
||||
// quickQuestions 已移动到 constants/quickQuestions.ts
|
||||
|
||||
return (
|
||||
<Box minH="100vh" bg="gray.900">
|
||||
<Flex h="calc(100vh - 72px)" overflow="hidden" position="relative">
|
||||
<Box flex={1} bg="gray.900">
|
||||
<Flex h="100%" overflow="hidden" position="relative">
|
||||
{/* 背景渐变层 - 移到 Flex 内部 */}
|
||||
<Box
|
||||
position="absolute"
|
||||
|
||||
Reference in New Issue
Block a user