diff --git a/web/src/components/dashboard/BentoTrend.jsx b/web/src/components/dashboard/BentoTrend.jsx index 9f5cde0..2e55665 100644 --- a/web/src/components/dashboard/BentoTrend.jsx +++ b/web/src/components/dashboard/BentoTrend.jsx @@ -48,9 +48,10 @@ const BentoTrend = ({ className = '', onRefresh, loading = false, + rangeKey = '7d', + onRangeChange, }) => { const [rangeOpen, setRangeOpen] = useState(false); - const [selectedKey, setSelectedKey] = useState('7d'); const [customStart, setCustomStart] = useState(''); const [customEnd, setCustomEnd] = useState(''); const [tooltip, setTooltip] = useState(null); // { dayIdx, x, y } or null @@ -67,11 +68,11 @@ const BentoTrend = ({ return () => document.removeEventListener('mousedown', handler); }, []); - const selectedLabel = RANGE_OPTIONS.find((r) => r.key === selectedKey)?.label || '近 7 天'; + const selectedLabel = RANGE_OPTIONS.find((r) => r.key === rangeKey)?.label || '近 7 天'; const handleApply = () => { if (customStart && customEnd) { - setSelectedKey('custom'); + onRangeChange('custom'); } setRangeOpen(false); }; @@ -150,13 +151,13 @@ const BentoTrend = ({