"use client"; import { useState } from "react"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Loader2, Sparkles, ArrowRight, Activity, AlertTriangle, } from "lucide-react"; import { healthScoreApi, type HealthScoreResponse, type HealthScoreDimension, } from "@/lib/api/health-score"; import { round, getStatusColor, getProgressBg, DIMENSION_ICONS, } from "@/lib/utils/health-score"; interface Step0HealthScoreProps { onNext: (brandName: string, healthScore: HealthScoreResponse | null) => void; initialBrandName?: string; } export function Step0HealthScore({ onNext, initialBrandName = "", }: Step0HealthScoreProps) { const [brandName, setBrandName] = useState(initialBrandName); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [result, setResult] = useState(null); const handleCheck = async () => { const trimmed = brandName.trim(); if (!trimmed || trimmed.length < 2) { setError("请输入至少2个字符的品牌名称"); return; } setLoading(true); setError(null); try { const data = await healthScoreApi.getHealthScore(trimmed); setResult(data); } catch (err) { setError(err instanceof Error ? err.message : "检测失败,请重试"); } finally { setLoading(false); } }; const handleNext = () => { onNext(brandName.trim(), result); }; return (

免费检测您的GEO健康分

输入品牌名称,即刻查看您的品牌在AI搜索中的表现

{ setBrandName(e.target.value); setError(null); }} placeholder="输入品牌名称,例如:华为" className="h-12 text-base" maxLength={50} autoFocus onKeyDown={(e) => { if (e.key === "Enter" && !loading) { handleCheck(); } }} />
{error && (
{error}
)}
{result && (
{result.overall_score} /100
{result.health_level_label}

{result.brand_name} 的GEO健康分

核心维度评分

{result.dimensions.map((dim: HealthScoreDimension) => { const Icon = DIMENSION_ICONS[dim.name] || Activity; return (
{dim.name}
{round(dim.percentage, 1)}%
); })} {result.recommendations.length > 0 && (

关键问题

{result.recommendations.slice(0, 3).map((rec, i) => (
{rec.title}
))}
)}

免费版仅展示3个核心维度 · 升级Pro解锁完整6维度诊断

免费注册即可保存品牌并获取持续监控

)} {!result && !loading && (
无需注册,即刻查看您的GEO健康分
)}
); }