import React, { useState } from 'react'; import { Search, Loader2, FileText, TrendingUp, Layers, Zap } from 'lucide-react'; import { useNavigate } from 'react-router-dom'; import { Logo } from '../components/Logo'; // 评级模版数据 const RATING_TEMPLATES = [ { id: 'default', name: '默认评级模版', description: '包含估值、资金、宏观、基本面四大核心维度', icon: , bgColor: 'bg-blue-50', iconColor: 'text-blue-600', borderColor: 'border-blue-200', tags: ['通用', '全面'] }, { id: 'consumer', name: '消费股模版', description: '聚焦消费品估值体系、品牌溢价、渠道分析', icon: , bgColor: 'bg-purple-50', iconColor: 'text-purple-600', borderColor: 'border-purple-200', tags: ['消费', '品牌'] }, { id: 'tech', name: '科技股模版', description: '关注研发投入、技术壁垒、市场份额等科技指标', icon: , bgColor: 'bg-teal-50', iconColor: 'text-teal-600', borderColor: 'border-teal-200', tags: ['科技', '成长'] }, { id: 'quick', name: '快速诊断模版', description: '精简版模板,聚焦PE/PB band与短期资金流向', icon: , bgColor: 'bg-amber-50', iconColor: 'text-amber-600', borderColor: 'border-amber-200', tags: ['快速', '简洁'] }, ]; export const SearchPage: React.FC = () => { const navigate = useNavigate(); const [searchTerm, setSearchTerm] = useState(''); const [selectedTemplate, setSelectedTemplate] = useState('default'); const [isSearching, setIsSearching] = useState(false); const handleSearch = (e: React.FormEvent) => { e.preventDefault(); if (searchTerm.trim() && selectedTemplate) { setIsSearching(true); // Simulate loading setTimeout(() => navigate(`/dashboard?template=${selectedTemplate}`), 800); } }; const handleTemplateClick = (templateId: string) => { setSelectedTemplate(templateId); // 如果已经输入了股票名称,自动跳转 if (searchTerm.trim()) { setIsSearching(true); setTimeout(() => navigate(`/dashboard?template=${templateId}`), 800); } }; // 当输入框失去焦点时,如果有选中的模版,也可以直接跳转 const handleInputBlur = () => { // 延迟判断,避免点击搜索下拉项时触发 setTimeout(() => { if (searchTerm.trim() && selectedTemplate && !isSearching) { // 这里不自动跳转,让用户明确选择模版 } }, 200); }; return (
{/* Header */}
{/* Main Content */}
{/* Search Section */}
setSearchTerm(e.target.value)} onBlur={handleInputBlur} className="w-full pl-12 pr-4 py-4 bg-white border border-slate-200 rounded-2xl shadow-sm text-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition-all placeholder:text-slate-400" placeholder="搜索标的..." /> {searchTerm && (
SH

贵州茅台

600519.SH · Stock

)}
{/* 提示文字 */}
{!searchTerm ? (

先输入股票名称,然后从下方选择评级模版

) : !selectedTemplate ? (

✓ 已选择股票,请选择一个评级模版

) : (

✓ 已选择股票和模版,点击模版卡片或按回车进入

)}
{/* 模版标题 */}

选择评级模版

选择适合的模版进行资产评级分析

{/* Templates Grid */}
{RATING_TEMPLATES.map((template) => (
handleTemplateClick(template.id)} className={`bg-white p-6 rounded-2xl border-2 shadow-sm hover:shadow-md transition-all cursor-pointer group relative ${ selectedTemplate === template.id ? `${template.borderColor} ring-2 ring-offset-2 ${template.iconColor.replace('text-', 'ring-')}` : 'border-slate-200 hover:border-slate-300' }`} > {/* 选中标识 */} {selectedTemplate === template.id && (
)}
{/* Icon */}
{template.icon}
{/* Template Name */}

{template.name}

{/* Description */}

{template.description}

{/* Tags */}
{template.tags.map(tag => ( {tag} ))}
))}
{/* Loading indicator */} {isSearching && (

正在加载评级数据...

)}
); };