import { useHealth } from '@/hooks/useHealth'; import { useLoginStatus } from '@/hooks/useLoginStatus'; import { Card } from '@/components/ui/Card'; import { Badge } from '@/components/ui/Badge'; import { Spinner } from '@/components/ui/Spinner'; import { Button } from '@/components/ui/Button'; import { formatUptime } from '@/lib/formatters'; import { useNavigate } from 'react-router-dom'; export function DashboardPage() { const { health, loading: healthLoading, refresh: refreshHealth } = useHealth(10_000); const { status: loginStatus, loading: loginLoading, refresh: refreshLogin } = useLoginStatus(); const navigate = useNavigate(); return (

仪表盘

{/* Status cards row */}
{/* Server Status */}
服务器
{healthLoading ? ( ) : health ? (
{health.healthy ? '正常' : '异常'}

v{health.version}

) : ( 离线 )}
{/* Uptime */}
运行时间
{health ? (

{formatUptime(health.uptime)}

) : (

-

)}
{/* Login Status */}
小红书登录
{loginLoading ? ( ) : loginStatus ? (
{loginStatus.loggedIn ? '已登录' : '未登录'} {loginStatus.username && (

{loginStatus.username}

)}
) : ( )}
{/* Memory */}
内存
{health ? (

{health.memory.heapUsed} MB

共 {health.memory.heapTotal} MB 堆内存

) : (

-

)}
{/* Plugin Health */} {health && Object.keys(health.plugins).length > 0 && (

插件

{Object.entries(health.plugins).map(([name, info]) => (
{name} {info.healthy ? '正常' : info.message || '异常'}
))}
)} {/* Quick actions */}

快捷操作

{/* Raw health data */} {health && (

原始健康数据

            {JSON.stringify(health, null, 2)}
          
)}
); }