| 30 | } |
| 31 | |
| 32 | function formatTime(isoString: string): string { |
| 33 | const date = new Date(isoString); |
| 34 | const now = new Date(); |
| 35 | const diff = now.getTime() - date.getTime(); |
| 36 | if (diff < 24 * 60 * 60 * 1000 && date.getDate() === now.getDate()) { |
| 37 | return date.toLocaleTimeString('zh-CN', {hour: '2-digit', minute: '2-digit'}); |
| 38 | } |
| 39 | const yesterday = new Date(now); |
| 40 | yesterday.setDate(yesterday.getDate() - 1); |
| 41 | if (date.getDate() === yesterday.getDate() && |
| 42 | date.getMonth() === yesterday.getMonth() && |
| 43 | date.getFullYear() === yesterday.getFullYear()) { |
| 44 | return '昨天'; |
| 45 | } |
| 46 | return date.toLocaleDateString('zh-CN', {month: 'numeric', day: 'numeric'}); |
| 47 | } |
| 48 | |
| 49 | export default function SessionPanel({ |
| 50 | sessions, activeSessionId, loading = false, |