@@ -64,11 +64,20 @@ const StatisticsCalendar: React.FC<StatisticsCalendarProps> = ({ year, month, da
6464 return `${ y } -${ m } -${ d } `
6565 }
6666
67- // 獲取某天的统计數據
67+ /** 後端僅在有成交/記錄時返回該日;無記錄視為當日盈虧 0,避免日曆滿屏「無數據」。 */
68+ const emptyDayStats = ( dateStr : string ) : DailyStatistics => ( {
69+ date : dateStr ,
70+ total_trades : 0 ,
71+ total_volume : 0 ,
72+ total_pnl : 0 ,
73+ win_rate : 0 ,
74+ } )
75+
76+ // 獲取某天的统计數據(當月有效日期必有對象,月初空白格為 null)
6877 const getDayStats = ( date : Date | null ) : DailyStatistics | null => {
6978 if ( ! date ) return null
7079 const dateStr = formatDate ( date )
71- return statsMap . get ( dateStr ) || null
80+ return statsMap . get ( dateStr ) ?? emptyDayStats ( dateStr )
7281 }
7382
7483 // 今日日期字串(使用本地時區,與日曆格子一致,避免 UTC 導致焦點錯位)
@@ -110,8 +119,7 @@ const StatisticsCalendar: React.FC<StatisticsCalendarProps> = ({ year, month, da
110119 const stats = getDayStats ( date )
111120 const isToday = date ? formatDate ( date ) === todayStr : false
112121 const dateStr = date ? formatDate ( date ) : ''
113- const hasData = ! ! stats
114- const isClickable = hasData && onDayClick
122+ const isClickable = ! ! date && ! ! onDayClick
115123
116124 return (
117125 < div
@@ -159,8 +167,8 @@ const StatisticsCalendar: React.FC<StatisticsCalendarProps> = ({ year, month, da
159167 { date . getDate ( ) }
160168 </ div >
161169
162- { /* 统计數據 */ }
163- { stats ? (
170+ { /* 统计數據(無後端記錄時已補 0,不再顯示「無數據」) */ }
171+ { stats && (
164172 < div style = { { flex : 1 , fontSize : '11px' , lineHeight : '1.4' } } >
165173 < div style = { {
166174 color : stats . total_pnl >= 0 ? '#52c41a' : '#ff4d4f' ,
@@ -223,10 +231,6 @@ const StatisticsCalendar: React.FC<StatisticsCalendarProps> = ({ year, month, da
223231 </ div >
224232 ) }
225233 </ div >
226- ) : (
227- < div style = { { flex : 1 , fontSize : '11px' , color : '#bfbfbf' } } >
228- { t ( 'statistics.noData' ) }
229- </ div >
230234 ) }
231235 </ >
232236 ) : null }
0 commit comments