import {PageHeader} from './UI'; import { RefreshCw, Activity, ArrowRight, Cpu, Database, HardDrive, Network } from 'lucide-react'; import { formatBytes, usagePercent } from '../format'; import type { ActivityEntry, Plan, Project, Usage } from '../types'; import { MetricCard } from './MetricCard'; import { ProjectTable } from './ProjectTable'; const resourceLabels: Record = { file: '文件管理', database: '数据库', project: '虚拟主机', domain: '域名', ftp: 'FTP', session:'会话', site:'网站', startup:'启动设置', website_settings:'网站设置', schedule:'计划任务', run_path:'运行目录', host_password:'主机密码', account_password:'账号密码', account_mfa:'双重认证', deployment:'部署', manual_certificate:'手动证书', automatic_certificate:'自动证书', certificate:'证书', dns_certificate:'DNS 证书', dns_credential:'DNS 凭据', domain_dns:'域名解析', oidc_identity:'第三方绑定', oidc_session:'第三方会话', project_network:'主机网络', panel_site:'站点接管', host_subscription:'主机套餐' }; interface OverviewProps { onRefresh?:()=>void;refreshing?:boolean; onEnterHost:(project:Project)=>void; onSchedules?:()=>void; projects: Project[]; plan: Plan; usage: Usage; activities: ActivityEntry[]; hostScoped: boolean; onCreate: () => void; canCreate: boolean; onLogs?: () => void; } export function Overview({ onRefresh,refreshing,projects, plan, usage, activities, hostScoped, onCreate, onEnterHost, onSchedules, canCreate, onLogs }: OverviewProps) { const resources = [ { label: '存储空间', value: usage.storageBytes, limit: plan.storageBytes }, { label: '本月流量', value: usage.bandwidthBytes, limit: plan.bandwidthBytes }, { label: '进程数量', value: usage.processCount, limit: plan.processLimit, count: true }, { label: '数据库大小', value: usage.databaseBytes, limit: plan.databaseBytes }, ]; return (
{onSchedules?:null}{onRefresh?:null}
}/> {!hostScoped ?
: null} {!hostScoped ?

最近操作日志

{onLogs?:null}
{activities.map((entry) =>
{formatTime(entry.createdAt)}{resourceLabels[entry.resourceType] ?? entry.resourceType}

{entry.detail}

{entry.success ? '成功' : '失败'}
)} {activities.length === 0 ?
暂无操作记录
: null}

资源使用详情

{resources.map((resource) => { const percent = usagePercent(resource.value, resource.limit); const value = resource.count ? `${resource.value} / ${resource.limit}` : `${formatBytes(resource.value)} / ${formatBytes(resource.limit)}`; return
{resource.label}{value}
{percent}%
; })}
: null} ); } function formatTime(value: string) { const date = new Date(value); if (Number.isNaN(date.getTime())) return value; return new Intl.DateTimeFormat('zh-CN', { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', hour12: false }).format(date).replace('/', '-'); }