Files
NovaBlog/src/components/react/MicroPage.tsx
2026-03-01 21:30:26 +08:00

60 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { useState, useCallback } from 'react';
import MicroList from './MicroList';
import MicroComposer from './MicroComposer';
import Heatmap from './Heatmap';
interface MicroPageProps {
apiBaseUrl?: string;
}
const API_BASE = typeof window !== 'undefined'
? (import.meta.env.VITE_API_BASE || 'http://localhost:8080/api')
: 'http://localhost:8080/api';
export default function MicroPage({ apiBaseUrl }: MicroPageProps) {
const baseUrl = apiBaseUrl || API_BASE;
const [refreshKey, setRefreshKey] = useState(0);
const [heatmapKey, setHeatmapKey] = useState(0);
const handlePostSuccess = useCallback(() => {
setRefreshKey(prev => prev + 1);
setHeatmapKey(prev => prev + 1);
}, []);
return (
<div className="grid grid-cols-1 xl:grid-cols-3 gap-8">
<div className="xl:col-span-2">
<div className="mb-8">
<MicroComposer
apiBaseUrl={baseUrl}
onSuccess={handlePostSuccess}
/>
</div>
<MicroList
key={refreshKey}
apiBaseUrl={baseUrl}
/>
</div>
<div className="xl:col-span-1">
<div className="sticky top-24 space-y-6">
<div className="card">
<Heatmap
key={heatmapKey}
apiBaseUrl={baseUrl}
/>
</div>
<div className="card">
<h3 className="text-lg font-semibold text-foreground mb-4"></h3>
<p className="text-sm text-muted-foreground leading-relaxed">
</p>
</div>
</div>
</div>
</div>
);
}