()
| 146 | } |
| 147 | |
| 148 | export function exportCurrentToCSV() { |
| 149 | const connection = state.connections[state.selectedConnectionId]; |
| 150 | if (!connection) { |
| 151 | alert('请先选择一个连接'); |
| 152 | return; |
| 153 | } |
| 154 | |
| 155 | const messages = getVisibleMessages(connection.messages); |
| 156 | if (messages.length === 0) { |
| 157 | alert('当前连接没有消息可导出'); |
| 158 | return; |
| 159 | } |
| 160 | |
| 161 | const formattedMessages = messages.map(msg => ({ |
| 162 | ...msg, |
| 163 | timestamp: formatTimestampForExport(msg.timestamp) |
| 164 | })); |
| 165 | |
| 166 | const csv = messagesToCSV(formattedMessages, getConnectionExportInfo(connection)); |
| 167 | const filename = `stream-messages-${connection.id.substring(0, 8)}-${Date.now()}.csv`; |
| 168 | downloadFile(csv, filename, 'text/csv'); |
| 169 | } |
| 170 | |
| 171 | export function exportAllToCSV() { |
| 172 | const connections = Object.values(state.connections); |
no test coverage detected