()
| 2626 | } |
| 2627 | |
| 2628 | function exportCurrentToCSV() { |
| 2629 | const connection = state.connections[state.selectedConnectionId]; |
| 2630 | if (!connection) { |
| 2631 | alert('请先选择一个连接'); |
| 2632 | return; |
| 2633 | } |
| 2634 | |
| 2635 | const messages = getVisibleMessages(connection.messages); |
| 2636 | if (messages.length === 0) { |
| 2637 | alert('当前连接没有消息可导出'); |
| 2638 | return; |
| 2639 | } |
| 2640 | |
| 2641 | const formattedMessages = messages.map(msg => ({ |
| 2642 | ...msg, |
| 2643 | timestamp: formatTimestampForExport(msg.timestamp) |
| 2644 | })); |
| 2645 | |
| 2646 | const csv = messagesToCSV(formattedMessages, getConnectionExportInfo(connection)); |
| 2647 | const filename = `stream-messages-${connection.id.substring(0, 8)}-${Date.now()}.csv`; |
| 2648 | downloadFile(csv, filename, 'text/csv'); |
| 2649 | } |
| 2650 | |
| 2651 | function exportAllToCSV() { |
| 2652 | const connections = Object.values(state.connections); |
no test coverage detected