Files
memind/ops/src/pages/AnalyticsPage.tsx
John 2e14873f2d Initial commit: Memind H5 portal with MindSpace, Plaza, and agent jobs.
Track application source and tests; exclude local env, user workspaces, and runtime data via .gitignore.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-15 15:04:43 -07:00

57 lines
1.8 KiB
TypeScript

import { useEffect, useState } from 'react';
import { fetchAnalytics } from '../api/client';
export function AnalyticsPage() {
const [data, setData] = useState<Awaited<ReturnType<typeof fetchAnalytics>> | null>(null);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
void fetchAnalytics()
.then(setData)
.catch((err) => setError(err instanceof Error ? err.message : '加载失败'));
}, []);
if (error) return <p className="alert">{error}</p>;
if (!data) return <p></p>;
return (
<div className="grid">
<div className="card" style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit,minmax(160px,1fr))', gap: 12 }}>
<div>
<p></p>
<strong style={{ fontSize: 28 }}>{data.today.new_posts}</strong>
<p style={{ color: '#68716c', fontSize: 12 }}> {data.yesterday.new_posts}</p>
</div>
<div>
<p>广</p>
<strong style={{ fontSize: 28 }}>{data.today.plaza_signups}</strong>
</div>
<div>
<p></p>
<strong style={{ fontSize: 28 }}>{data.today.pending_review}</strong>
</div>
</div>
<div className="card">
<h3></h3>
<ul>
{data.categories.map((item) => (
<li key={item.name}>
{item.name}: {item.count}
</li>
))}
</ul>
</div>
<div className="card">
<h3>TOP </h3>
<ul>
{data.top_creators.map((creator) => (
<li key={creator.slug}>
{creator.display_name} · {creator.post_count} · {creator.total_likes}
</li>
))}
</ul>
</div>
</div>
);
}