feat(ui): 首页挂载重构历史触发按钮,打通历史净值回溯全链路

This commit is contained in:
2026-04-30 11:26:21 +08:00
parent fd0ef345dd
commit c38d3fe30f
2 changed files with 32 additions and 3 deletions
+24 -2
View File
@@ -22,7 +22,7 @@ import {
import { toast } from 'sonner';
import { getPortfolioSummary } from '@/actions/portfolio';
import { getAssets } from '@/actions/asset';
import { recordDailySnapshot, getSnapshots } from '@/actions/snapshots';
import { recordDailySnapshot, getSnapshots, reconstructPortfolioHistory } from '@/actions/snapshots';
import { formatQuantity, formatAmount } from '@/lib/formatters';
import AllocationChart from '@/components/dashboard/allocation-chart';
import NetWorthChart from '@/components/dashboard/net-worth-chart';
@@ -201,7 +201,29 @@ export default function DashboardPage() {
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium"></CardTitle>
<SyncButton />
<div className="flex items-center gap-2">
<Button
variant="outline"
size="sm"
onClick={() => {
startTransition(async () => {
toast.loading('正在重构历史走势...');
const result = await reconstructPortfolioHistory();
toast.dismiss();
if (result.success) {
toast.success(`重构成功,已填充 ${result.daysReconstructed} 天历史数据`);
setSnapshots(await getSnapshots({ limit: 30 }));
} else if (result.message) {
toast.info(result.message);
}
});
}}
disabled={isPending}
>
{isPending ? '重构中...' : '重构历史走势'}
</Button>
<SyncButton />
</div>
</CardHeader>
<CardContent className="pt-6 pb-6">
<div className="flex items-center gap-3">