'use client';
import { SiteHeader, PageInfo } from '@/components/site-header';
import { SidebarInset, SidebarProvider } from '@nice/ui/components/sidebar';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@nice/ui/components/card';
import { Badge } from '@nice/ui/components/badge';
import { Button } from '@nice/ui/components/button';
import { Progress } from '@nice/ui/components/progress';
import {
IconServer,
IconUsers,
IconFiles,
IconCloudUpload,
IconTrendingUp,
IconTrendingDown,
IconActivity,
IconDatabase,
IconCpu,
IconShield,
IconBell,
IconCalendar,
IconClock,
IconAlertTriangle,
IconCircleCheck,
IconCircleX,
IconRefresh,
IconNetwork,
IconBrain,
IconFolder,
} from '@tabler/icons-react';
import { useTRPC } from '@fenghuo/client';
import { useQuery } from '@tanstack/react-query';
import { useEffect } from 'react';
import { SystemStatus } from '@fenghuo/common';
import { useSetPageInfo } from '@/components/providers/dashboard-provider';
// 用户和文件数据的模拟数据(保留,因为这部分数据不在systemStatus中)
const additionalStats = {
users: {
total: 1248,
online: 89,
newToday: 12,
activeThisWeek: 324,
growth: '+5.2%',
peakOnline: 156,
},
files: {
total: 45280,
size: '2.4TB',
uploaded: 156,
shared: 89,
downloadedToday: 1289,
uploadedToday: 234,
growth: '+8.1%',
},
database: {
connections: 45,
maxConnections: 200,
queryTime: 2.3,
status: 'healthy',
size: '890MB',
backupStatus: 'completed',
lastBackup: '4小时前',
},
};
const recentActivities = [
{
id: 1,
user: '张三',
action: '上传了文件',
target: 'project.pdf',
time: '5分钟前',
type: 'upload',
ip: '192.168.1.100',
},
{
id: 2,
user: '李四',
action: '创建了文章',
target: 'API设计指南',
time: '10分钟前',
type: 'create',
ip: '192.168.1.101',
},
];
const systemAlerts = [
{ id: 1, type: 'warning', level: 'medium', message: '磁盘空间使用率超过80%', time: '1小时前', resolved: false },
{ id: 2, type: 'info', level: 'low', message: '系统备份已完成', time: '2小时前', resolved: true },
{ id: 3, type: 'success', level: 'low', message: '安全扫描未发现威胁', time: '3小时前', resolved: true },
{ id: 4, type: 'error', level: 'high', message: 'Email服务响应异常', time: '4小时前', resolved: false },
];
function StatsCard({
title,
value,
description,
icon: Icon,
trend,
trendValue,
className = '',
status,
}: {
title: string;
value: string | number;
description: string;
icon: any;
trend?: 'up' | 'down';
trendValue?: string;
className?: string;
status?: 'good' | 'warning' | 'error';
}) {
const getStatusColor = () => {
switch (status) {
case 'good':
return 'text-green-500';
case 'warning':
return 'text-yellow-500';
case 'error':
return 'text-red-500';
default:
return 'text-muted-foreground';
}
};
return (
{activity.user} {activity.action}{' '}
{activity.target}
{alert.message} {alert.time}