fix(dashboard): remove failing evolution/health API calls

The useEvolutionStatistics and useSystemHealth hooks call endpoints that
depend on a non-existent knowledge-service internal API. Removed these
calls and the related UI sections to prevent 500 errors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-25 08:33:08 -08:00
parent ccb0648f6c
commit f95bc71254
1 changed files with 2 additions and 127 deletions

View File

@ -1,12 +1,10 @@
import { useMemo } from 'react';
import { Card, Row, Col, Statistic, Tag, Progress, List, Typography, Spin } from 'antd';
import { Card, Row, Col, Statistic, Typography, Spin } from 'antd';
import {
UserOutlined,
MessageOutlined,
DollarOutlined,
RobotOutlined,
CheckCircleOutlined,
ClockCircleOutlined,
} from '@ant-design/icons';
import {
LineChart,
@ -20,11 +18,9 @@ import {
Pie,
Cell,
} from 'recharts';
import { useEvolutionStatistics, useSystemHealth } from '../../application';
import { useTodayStatistics, useTrendData, useStatisticsByCategory } from '../../../analytics/application';
import type { HealthMetric } from '../../infrastructure';
const { Title, Text } = Typography;
const { Title } = Typography;
// Category color mapping
const CATEGORY_COLORS: Record<string, string> = {
@ -39,9 +35,6 @@ const CATEGORY_COLORS: Record<string, string> = {
};
export function DashboardPage() {
const { data: evolutionStats } = useEvolutionStatistics();
const { data: healthReport } = useSystemHealth();
// Analytics data from real API
const { data: todayStats, isLoading: loadingToday } = useTodayStatistics();
const { data: trendData, isLoading: loadingTrend } = useTrendData(7, ['newConversations', 'newUsers']);
@ -92,19 +85,6 @@ export function DashboardPage() {
})).filter(d => d.value > 0);
}, [categoryStats]);
const getHealthColor = (status: string) => {
switch (status) {
case 'healthy':
return 'success';
case 'warning':
return 'warning';
case 'critical':
return 'error';
default:
return 'default';
}
};
return (
<div className="p-6">
<Title level={4} className="mb-6"></Title>
@ -232,111 +212,6 @@ export function DashboardPage() {
</Col>
</Row>
{/* System Status */}
<Row gutter={[16, 16]} className="mt-4">
<Col xs={24} lg={12}>
<Card
title={
<div className="flex items-center justify-between">
<span></span>
<Tag color={getHealthColor(healthReport?.overall || 'healthy')}>
{healthReport?.overall === 'healthy'
? '健康'
: healthReport?.overall === 'warning'
? '警告'
: '异常'}
</Tag>
</div>
}
>
<List
dataSource={healthReport?.metrics || []}
renderItem={(item: HealthMetric) => (
<List.Item>
<div className="w-full">
<div className="flex justify-between mb-1">
<Text>{item.name}</Text>
<Text type="secondary">
{item.value} / {item.threshold}
</Text>
</div>
<Progress
percent={Math.min(100, (item.value / item.threshold) * 100)}
status={
item.status === 'good'
? 'success'
: item.status === 'warning'
? 'exception'
: 'active'
}
showInfo={false}
size="small"
/>
</div>
</List.Item>
)}
/>
{(healthReport?.recommendations?.length ?? 0) > 0 && (
<div className="mt-4 p-3 bg-yellow-50 rounded">
<Text type="warning"></Text>
<ul className="mt-2 ml-4 text-sm text-gray-600">
{healthReport?.recommendations?.map((rec: string, i: number) => (
<li key={i}>{rec}</li>
))}
</ul>
</div>
)}
</Card>
</Col>
<Col xs={24} lg={12}>
<Card title="经验学习进度">
<Row gutter={[16, 16]}>
<Col span={12}>
<Statistic
title="总经验"
value={evolutionStats?.totalExperiences || 0}
prefix={<RobotOutlined />}
/>
</Col>
<Col span={12}>
<Statistic
title="活跃经验"
value={evolutionStats?.activeExperiences || 0}
prefix={<CheckCircleOutlined />}
valueStyle={{ color: '#52c41a' }}
/>
</Col>
<Col span={12}>
<Statistic
title="待审核"
value={evolutionStats?.pendingExperiences || 0}
prefix={<ClockCircleOutlined />}
valueStyle={{ color: '#faad14' }}
/>
</Col>
<Col span={12}>
<Statistic
title="已审核"
value={evolutionStats?.approvedExperiences || 0}
prefix={<CheckCircleOutlined />}
/>
</Col>
</Row>
<div className="mt-4">
<Text type="secondary"></Text>
<div className="mt-2">
{evolutionStats?.topExperienceTypes?.map(
(item: { type: string; count: number }) => (
<Tag key={item.type} className="mb-1">
{item.type}: {item.count}
</Tag>
)
)}
</div>
</div>
</Card>
</Col>
</Row>
</div>
);
}