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:
parent
ccb0648f6c
commit
f95bc71254
|
|
@ -1,12 +1,10 @@
|
||||||
import { useMemo } from 'react';
|
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 {
|
import {
|
||||||
UserOutlined,
|
UserOutlined,
|
||||||
MessageOutlined,
|
MessageOutlined,
|
||||||
DollarOutlined,
|
DollarOutlined,
|
||||||
RobotOutlined,
|
RobotOutlined,
|
||||||
CheckCircleOutlined,
|
|
||||||
ClockCircleOutlined,
|
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import {
|
import {
|
||||||
LineChart,
|
LineChart,
|
||||||
|
|
@ -20,11 +18,9 @@ import {
|
||||||
Pie,
|
Pie,
|
||||||
Cell,
|
Cell,
|
||||||
} from 'recharts';
|
} from 'recharts';
|
||||||
import { useEvolutionStatistics, useSystemHealth } from '../../application';
|
|
||||||
import { useTodayStatistics, useTrendData, useStatisticsByCategory } from '../../../analytics/application';
|
import { useTodayStatistics, useTrendData, useStatisticsByCategory } from '../../../analytics/application';
|
||||||
import type { HealthMetric } from '../../infrastructure';
|
|
||||||
|
|
||||||
const { Title, Text } = Typography;
|
const { Title } = Typography;
|
||||||
|
|
||||||
// Category color mapping
|
// Category color mapping
|
||||||
const CATEGORY_COLORS: Record<string, string> = {
|
const CATEGORY_COLORS: Record<string, string> = {
|
||||||
|
|
@ -39,9 +35,6 @@ const CATEGORY_COLORS: Record<string, string> = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function DashboardPage() {
|
export function DashboardPage() {
|
||||||
const { data: evolutionStats } = useEvolutionStatistics();
|
|
||||||
const { data: healthReport } = useSystemHealth();
|
|
||||||
|
|
||||||
// Analytics data from real API
|
// Analytics data from real API
|
||||||
const { data: todayStats, isLoading: loadingToday } = useTodayStatistics();
|
const { data: todayStats, isLoading: loadingToday } = useTodayStatistics();
|
||||||
const { data: trendData, isLoading: loadingTrend } = useTrendData(7, ['newConversations', 'newUsers']);
|
const { data: trendData, isLoading: loadingTrend } = useTrendData(7, ['newConversations', 'newUsers']);
|
||||||
|
|
@ -92,19 +85,6 @@ export function DashboardPage() {
|
||||||
})).filter(d => d.value > 0);
|
})).filter(d => d.value > 0);
|
||||||
}, [categoryStats]);
|
}, [categoryStats]);
|
||||||
|
|
||||||
const getHealthColor = (status: string) => {
|
|
||||||
switch (status) {
|
|
||||||
case 'healthy':
|
|
||||||
return 'success';
|
|
||||||
case 'warning':
|
|
||||||
return 'warning';
|
|
||||||
case 'critical':
|
|
||||||
return 'error';
|
|
||||||
default:
|
|
||||||
return 'default';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-6">
|
<div className="p-6">
|
||||||
<Title level={4} className="mb-6">仪表盘</Title>
|
<Title level={4} className="mb-6">仪表盘</Title>
|
||||||
|
|
@ -232,111 +212,6 @@ export function DashboardPage() {
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</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>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue