feat(ui): 首页实装历史净值面积走势图,并挂载自动化快照触发逻辑

This commit is contained in:
2026-04-29 11:50:42 +08:00
parent 4c4e6ab565
commit e70c0602c8
3 changed files with 163 additions and 0 deletions
+21
View File
@@ -22,8 +22,10 @@ import {
import { toast } from 'sonner';
import { getPortfolioSummary } from '@/actions/portfolio';
import { getAssets } from '@/actions/asset';
import { recordDailySnapshot, getSnapshots } from '@/actions/snapshots';
import { formatQuantity, formatAmount } from '@/lib/formatters';
import AllocationChart from '@/components/dashboard/allocation-chart';
import NetWorthChart from '@/components/dashboard/net-worth-chart';
import { SyncButton } from '@/components/assets/sync-button';
import { AddTransactionDialog } from '@/components/transactions/add-transaction-dialog';
import { UpdateTransactionDialog } from '@/components/transactions/update-transaction-dialog';
@@ -84,6 +86,7 @@ export default function DashboardPage() {
const [isPending, startTransition] = useTransition();
const [updateTarget, setUpdateTarget] = useState<any>(null);
const [deleteTarget, setDeleteTarget] = useState<any>(null);
const [snapshots, setSnapshots] = useState<any[]>([]);
useEffect(() => {
async function loadData() {
@@ -99,6 +102,15 @@ export default function DashboardPage() {
loadData();
}, []);
useEffect(() => {
async function loadSnapshots() {
await recordDailySnapshot();
const data = await getSnapshots({ limit: 30 });
setSnapshots(data);
}
loadSnapshots();
}, []);
const toggleExpand = (id: string) => {
setExpandedIds(prev => ({ ...prev, [id]: !prev[id] }));
};
@@ -170,6 +182,15 @@ export default function DashboardPage() {
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle className="text-base font-medium"></CardTitle>
</CardHeader>
<CardContent>
<NetWorthChart snapshots={snapshots} />
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle></CardTitle>