feat(ui): 首页实装历史净值面积走势图,并挂载自动化快照触发逻辑
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user