geo/frontend/types/dashboard-health.ts

168 lines
3.5 KiB
TypeScript

/**
* 健康状态Dashboard类型定义
*/
// 健康等级
export type HealthLevel = "excellent" | "good" | "pass" | "danger";
// 健康等级配置
export interface HealthLevelConfig {
level: HealthLevel;
label: string;
icon: string;
color: {
bg: string;
text: string;
border: string;
};
minScore: number;
maxScore: number;
}
// 健康等级配置映射
export const HEALTH_LEVEL_CONFIG: Record<HealthLevel, HealthLevelConfig> = {
excellent: {
level: "excellent",
label: "优秀",
icon: "✓",
color: {
bg: "bg-emerald-50",
text: "text-emerald-600",
border: "border-emerald-200",
},
minScore: 80,
maxScore: 100,
},
good: {
level: "good",
label: "良好",
icon: "~",
color: {
bg: "bg-yellow-50",
text: "text-yellow-600",
border: "border-yellow-200",
},
minScore: 60,
maxScore: 79,
},
pass: {
level: "pass",
label: "及格",
icon: "!",
color: {
bg: "bg-orange-50",
text: "text-orange-600",
border: "border-orange-200",
},
minScore: 40,
maxScore: 59,
},
danger: {
level: "danger",
label: "危险",
icon: "⚠",
color: {
bg: "bg-red-50",
text: "text-red-600",
border: "border-red-200",
},
minScore: 0,
maxScore: 39,
},
};
// 平台评分(带竞品对比)
export interface PlatformScoreWithCompetitor {
platform: string;
score: number;
competitor_score?: number;
competitor_name?: string;
// 兼容旧字段名
competitorScore?: number;
competitorName?: string;
}
// 维度评分项
export interface DimensionScore {
name: string;
score: number;
max_score: number;
percentage: number;
}
// Dashboard统计数据
export interface DashboardStats {
overall_score: number;
health_level?: HealthLevel;
score_change: number;
platform_scores: PlatformScoreWithCompetitor[];
recent_queries: RecentQuery[];
// V2新增字段
dimensions?: DimensionScore[];
brand_name?: string;
competitors_ahead?: number; // 领先的竞品数
competitors_behind?: number; // 落后的竞品数
monitored_platforms?: number;
total_platforms?: number;
}
// 最近查询记录
export interface RecentQuery {
id: string;
keyword: string;
target_brand: string;
citation_count: number;
queried_at: string;
}
// 行动建议
export interface ActionSuggestion {
id: string;
type: "primary" | "secondary" | "optional";
title: string;
description: string;
icon: string;
href: string;
priority: number;
}
// 平台中文名称映射
export const PLATFORM_LABELS: Record<string, string> = {
wenxin: "文心一言",
kimi: "Kimi",
tongyi: "通义千问",
doubao: "豆包",
xinghuo: "讯飞星火",
tiangong: "天工AI",
qingyan: "智谱清言",
};
// 平台图标映射
export const PLATFORM_ICONS: Record<string, string> = {
wenxin: "🧠",
kimi: "📖",
tongyi: "🏔️",
doubao: "🥟",
xinghuo: "🔥",
tiangong: "⚔️",
qingyan: "💎",
};
// 维度名称映射
export const DIMENSION_LABELS: Record<string, string> = {
"提及率": "提及率",
"推荐排名": "推荐排名",
"情感倾向": "情感倾向",
"引用质量": "引用质量",
"竞品对比": "竞品对比",
};
// 维度颜色映射
export const DIMENSION_COLORS: Record<string, string> = {
"提及率": "bg-blue-500",
"推荐排名": "bg-purple-500",
"情感倾向": "bg-emerald-500",
"引用质量": "bg-amber-500",
"竞品对比": "bg-rose-500",
};